I am looking for a [pseudo-]code for the following task: given a [GMT] timestamp, tell which of Sydney, Tokyo, London and New York FOREX session were opened. Weekend, daylight saving time and holiday awareness are reqired.

So it's more or less what http://www.forex-market-hours.net/ does. From what I remember, daylight saving time is activated on different dates in their time zones.

I saw the answer in Forex Market Timezones, but coudn't access the ACI model code it refers to.

  • $\begingroup$ The "ACI model code" is a code of conduct for human beings involved in FX trading, it is not computer code. $\endgroup$
    – nbbo2
    Jan 12, 2018 at 13:24

2 Answers 2


I would write out the local business hours for each trading centre in a spreadsheet and get the pseudo code from that. As for holidays, for example when London is on holiday then Tokyo / New York will cover the London hours. You would have to put all GBP bank holidays in your spreadsheet.

For New York it’s USD holidays etc.

Otherwise your question seems to be related to this


Here is a snippet of an R script I use to append newly downloaded hourly data to historical data in a csv file on disk

# get London and New York times and weekdays 
london_time <- format( as.POSIXct( new_historical_data[ , 1 ] , tz = "UTC" ) , tz = "Europe/London" )      
london_weekday <- as.POSIXlt( london_time )
london_weekday + 1 # +1 to match Octave's weekday representation
new_york_time <- format( as.POSIXct( new_historical_data[ , 1 ] , tz = "UTC" ) , tz = "America/New_York" )
new_york_weekday <- as.POSIXlt( new_york_time )
new_york_weekday + 1 # +1 to match Octave's weekday representation

# add London and New York times columns 
new_historical_data <- cbind( new_historical_data[ , 1 ] , london_time , london_weekday , new_york_time , new_york_weekday , new_historical_data[ , 2 : 7 ] )

This changes the downloaded "new_historical_data" format from

UTC_date_time , open , high , ...


UTC_date_time , London_date_time , London_weekday_marker , New_York_date_time , New_York_weekday_marker , open , high , ... 


Because R references the installed time zone library on my system, the London and New York times are correctly adjusted for the appropriate daylight savings time

  • $\begingroup$ For this very reason my laptop's timezone is set not my local one but UTC, without DST. I just could not stand programs and functions implicitly assuming or guessing the timezome when unspecified. $\endgroup$
    – Xpector
    Jan 14, 2018 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.