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:

import sigtech.framework as sig

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:

import datetime as dtm
import pandas as pd
import numpy as np
import seaborn as sns

sig.init(env_date=dtm.datetime(2020, 7, 1, 11))
# this sets the env_date to July 1st 2020, at 11:00am

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:

sig.config.set(sig.config.FORCE_OFFSETTING_OTC_TRADES, True)
sig.config.set(sig.config.TM_TIMEZONE, 'Europe/London')

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.

FORCE_OFFSETTING_OTC_TRADES

False

Determines whether to force entry into offsetting trades for FX forwards and other initial zero-value trades when trading out of them.

DIVIDEND_TAX_OVERRIDE

{ }

Override dividend tax for equity groups.

CUSTOM_DATA_SOURCE_CONFIG

[ ]

Configure data providers. List of pairs: regex matching instrument names, data_source.

FUTURE_GROUP_SPLITS

{ }

Dict of splits occurring in futures groups to consider when constructing rolling future strategies.

HISTORY_START_DATE

None

Sets a date before which no history for any instrument will be returned.

RESTRICT_TO_CUSTOM_PROVIDER

False

Determines whether to restrict time series data retrieval to a specified data provider.

FX_SPOT_EXECUTION_DELAY

datetime.timedelta(0)

Sets time between the decision and execution of an FX Spot transaction.

FX_CROSS_DIRECT_PAIRS

[ ]

Trades FX pairs directly, as opposed to triangulating through USD.

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:

sig.init()
# The environment is now initialised

sig.init()
# The call above has no effect (default is 'warning')

sig.init(repeat_mode='reinit')
# The call above destroys the current environment and creates a new one

sig.init(repeat_mode='error')
# The execution terminates with an error

Last updated