Search…
Environment setup
This tutorial provides a guide to to the construction of the research environment within the SigTech platform. I also covers some of the most popular configurations available.

Framework import

The SigTech framework library holds a wealth of functionality, much of which can be accessed using the following import statement:
1
import sigtech.framework as sig
Copied!

Environment initialization

Following the importation of the sigtech.framework library, it is necessary to initialize the environment. Initialization is performed with the command sig.init().
The following example demonstrates the importation of several Python libraries followed by the initialization process:
1
import datetime as dtm
2
import pandas as pd
3
import numpy as np
4
import seaborn as sns
5
6
sig.init(env_date=dtm.datetime(2020, 7, 1, 11))
7
# this sets the env_date to July 1st 2020, at 11:00am
Copied!
The script %pip list lists all existing packages with corresponding version numbers. Learn more about the range of python packages available and the installation process, here.

Configuration parameters

The following parameters can be used during environment initialization:
Parameter
Default
Description
env_date
"today"
A Python date, datetime or string, for example ‘today’ or ‘yesterday’. This parameter sets the final date of the calculation engine. No calculations are made past this point.
data_date
"today"
A Python date, datetime or string, for example 'today' or 'yesterday'. This parameter sets the as-of date of the data being used. For example, if the env_date is set to 2010/01/01 and the data_date is set to 2011/01/01 the calculation engine will run until 2010/01/01 but will use data for that timeframe that was refreshed or updated as late as 2011/01/01. Any changes made to the data after the data_date will not be included.
log_level
"Error"
The log level determines the type of log message to display and the granularity of information to provide the user.
After the initialization of the environment, several additional configurations can be made.
In the following code block, FORCE_OFFSETTING_OTC_TRADES and TM_TIMEZONE have been included:
1
sig.config.set(sig.config.FORCE_OFFSETTING_OTC_TRADES, True)
2
sig.config.set(sig.config.TM_TIMEZONE, 'Europe/London')
Copied!
The following parameters can be used to further configure the environment:
Parameter
Default value
Explanation
HISTORY_SCHEDULE_BUILD_FROM_DATA
False
Determines whether to use calendars to build the history schedule of instruments.
HISTORY_DATA_FILL_MISSING
False
Determines whether to provide values for missing data points. If True, copies previous value.
IGNORE_T_COSTS
False
Determines whether to ignore transaction costs when running strategies.
DISABLE_T_COST_NETTING
False
Determines whether to treat all orders individually by disabling transaction cost netting.
ALLOWED_DAY_CA_DATA_GAP
10
Sets number of days before gathering data following a corporate action.
ALLOWED_MISSING_CA_DATA
False
Determines whether to ignore corporate actions with no adjustment factor or resulting stock symbol.
TM_CALENDAR
'London, CHR Calendar'
Sets trading manager calendar.
TM_TIMEZONE
'Europe/London'
Sets trading manager timezone.
TM_OPEN
datetime.time(7, 30, 0)
Sets trading manager opening time.
TM_CLOSE
datetime.time(18, 0, 0)
Sets trading manager closing time.
TM_DEFAULT_DATA_POINTS
[DataPoints.LONDON_1600, DataPoints.LAST]
Sets data point defaults according to Trading Manager Calendar.
TM_INTRADAY_OUT_OF_POINTS
False
Determines valuation when intraday data is available. If True use intraday data outside of instrument exchange trading hours, if False use EOD data.
TM_PREFERRED_DATA_POINTS
[ ]
Sets list of data points to prioritize over others.
T_COST_OVERRIDES
{ }
Facilitates overriding of transaction cost values.
T_COST_WARN_ON_DEFAULT
False
Determines whether to warn user if default transaction costs are used.
FORWARD_DISCOUNTING_INSTRUMENT
'FEDL01 INDEX'
Determines discounting instrument to be used for base currency discounting in FX forwards. Can be curve of overnight index.
FORWARD_BASE_CURRENCY
'USD'
Sets base currency to use in FX forward market.
FORWARD_SPLINE_POINTS
3
Sets order of the spline interpolation used by the point based FX forward market.
FORCE_ORDER_ROUNDING
False
Determines whether to force the rounding of all units for strategy generated orders.
Note: to destroy your configured environment and clear the cache in preparation for initializing a new environment, use sig.de_init().

Initialisation arguments

Attempts to initialise an already initialised environment will produce different behaviours based on the value of repeat_mode:
  • 'reinit' - Destroys the current environment and creates a new one. A warning message explaining these actions is printed
  • 'error' - The execution terminates and a clearer error message is printed
  • 'warning' - A warning is printed and the init() has no effect (default)
These behaviours are described in the code block below:
1
sig.init()
2
# The environment is now initialised
3
4
sig.init()
5
# The call above has no effect (default is 'warning')
6
7
sig.init(repeat_mode='reinit')
8
# The call above destroys the current environment and creates a new one
9
10
sig.init(repeat_mode='error')
11
# The execution terminates with an error
Copied!