Skip to content
All library documents

Mapping Forex Sessions Across Time Zones and Holidays

Article Quant Q&A · Author: Xpector

Summary

The document considers how to identify which major foreign-exchange trading sessions are open at a given UTC time, while accounting for weekends, daylight saving changes, and local holidays. One suggested approach is to maintain each centre’s local business hours and convert timestamps using its time zone. Holiday calendars must also be considered separately for relevant currencies and markets, since a holiday in one centre can change which other centres cover those hours.

A second response shows converting UTC timestamps to London and New York local times with the system’s time-zone database, which applies daylight saving adjustments, then recording local weekdays alongside historical price data. This illustrates the time conversion step but does not provide a complete session-detection algorithm. The example handles only two centres and does not implement the requested holiday awareness; a robust schedule would need calendars and operating hours for every session under consideration.

Key ideas

  • Convert UTC timestamps into each trading centre’s local time using time-zone rules.
  • Local time-zone databases can account for differing daylight saving schedules.
  • Session detection also requires local weekdays, business hours, weekends, and holiday calendars.
  • A holiday in one centre may change which other markets are active during those hours.
  • The example conversion covers London and New York but does not provide a complete multi-session holiday algorithm.

Tags

Full text
# given a timstamp, tell if Forex NY/Tokyo/London active


# given a timstamp, tell if Forex NY/Tokyo/London active












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.

## Answer by rupweb (score 1)

https://quant.stackexchange.com/a/37716

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

## Answer by babelproofreader (score 1)

https://quant.stackexchange.com/a/37723

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 , ...
```

to

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

format.

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

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.