Calendars & timezones
Introduction
This page demonstrates how to configure the timezone and calendar features when initializing your environment. It also explains how to search and work with the schedule and calendar functions available within the framework.
This information would be valuable for any SigTech user wanting to build strategies which trade outside of the UTC timezone and trading calendar.
Environment
When initializing your environment with the sig.init()
command, calendar and timezone settings will be configured by default.
Learn more: Configuration parameters.
TradingManager
A TradingManager
object is automatically created during environment initialization. These objects manage calendar, timezone and open/close time information for strategies. They also provide a collection of useful trading functionalities. Configuration parameters including the initials TM
are referencing the TradingManager
.
Relevant defaults
Parameter | Default |
---|---|
TM_CALENDAR | 'None' |
TM_TIMEZONE | 'Europe/London' |
TM_OPEN | datetime.time(7, 30, 0) |
TM_CLOSE | datetime.time(18, 0, 0) |
TM_DEFAULT_DATA_POINTS | [DataPoints.LONDON_1600, DataPoints.LAST] |
TM_INTRADAY_OUT_OF_HOURS | False |
Available options
Timezones
Available timezones are included in the standard python timezone library, pytz
. To generate a list of the available options, you can run the following command:
Calendars
Available calendars are listed in the Calendars folder of our Data browser: available calendars. The object name can be retrieved from the VIEW DETAILS page, under CODE EXAMPLE.
The most commonly used calendars are:
The Data Browser lists all available calendars, and provides sample code showing how to get them. For example, to get the A2X South Africa calendar:
FX market currency pairs
To identify relevant calendars for currency pairs, use FXMarket.instance()
to retrieve specific schedules.
Exchange & OTC calendars
For futures based strategies, you can retrieve exchange calendars directly from the futures group with the following code.
You can then retrieve their relevant holiday calendars.
For equities based strategies, you can retrieve exchange calendars with the following command.
For business days, you will need to fetch the holiday_calendar
object and then call business_days
, specifying a start
and end
date.
OTC instruments contain a .holiday
method which retrieves the relevant calendars without the need for calling sig.obj.get
.
Changing the default values
You can reconfigure the calendar and timezone values during initialization. However, if you have already initialized your environment the sig.de_init()
call will allow you to reset the values. The following code block will change the defaults.
This code block can be used if initializing your environment for the first time by simply removing the sig.de_init()
command.
You can check these changes have been successful by running the following commands:
Adjusting the date
You can add or adjust business day conventions, and retrieve month-end and IMM dates using sig.calendar
.
Rebalancing frequencies
SigTech supports the majority of common rebalancing schedules.
Using a BasketStrategy
as an example, the AVAILABLE_REBALANCE_FREQS
object can help you to locate the correct string to supply for rebalancing.
You can use the values outputted above to determine the correct input string:
The values outputted above are methods that take an input and return the correct string format. You can use the thursdays
method is an example:
The input n
determines how often, in terms of weeks, to rebalance. For instance, freqs.thursdays(2)
returns the string to input to rebalance a strategy every second Thursday.
The following cell block runs some of these methods and outputs the strings necessary for the rebalancing_frequency
.
Custom schedules
SigTech includes a range of rebalancing schedules; EOD, 1W, 2W, 1M, SOM, EOD, 2BD, 2DOM, 2W-FRI, 2W-THU, 2W.
The rebalancing schedules listed above are not exhaustive. The Rebalancing frequencies section of this page provides the necessary code to list all of the available options.
If your desired rebalancing frequency is unavailable, a custom schedule can be created from the SchedulePeriodic
class.
Last updated