Environment setup#

This tutorial guides you through configuring an environment within the SigTech platform before you begin your analysis.

Prerequisites#

This page assumes you have started a research environment on the Sigtech platform. If you have not:

  1. Login to Sigtech.

  2. Select Research.

  3. Select the workspace you want to initialize a research environment in. To configure a new workspace, refer to [Workspaces](/user-interface/workspaces.

  4. Configure your research environment using the Set up your Research Environment window.

  5. Select Start Research Environment.

  6. Open an instance of your preferred IDE.

Import our framework#

You are required to import the sigtech.framework library.

import sigtech.framework as sig

Import additional python libraries#

Import any python libraries you require. For example:

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

If you attempt to import a library and encounter the ModuleNotFoundError, you will need to install the library in your research environment. See [Python packages](/user-interface/python-packages#third-party-python-packages for more information.

To see the complete list of libraries you can import without installing, run help('modules'). To see a list of the supported libraries and versions run %pip install. Please note that %pip install does not show all supported Python libraries.

Initialize your environment#

After importing the necessary libraries, you must initialize your environment. Initialization is performed with the command sig.init().

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

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 last date for which results will be calculated.

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 results will be calculated up till 2010/01/01 but will be based on 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. For a list of the different log_levels, see the section below.

Arguments for log_level#

When configuring your environment, the log_level argument lets you set log messages and exactly what kind of information is displayed. There are four log levels:

  1. 'ERROR' - displays error messages that are fatal to the code operation.

  2. 'WARNING' - displays information that can explain application oddities or issues. These issues are not ‘fatal’ and will not disrupt the code.

    • Selecting this level will cause both 'ERROR' and 'WARNING' messages to be displayed.

  3. 'DEBUG' - displays information that is diagnostically helpful. For example, a debug message could be 'stopping Strategy Service'.

    • Selecting this level will cause 'ERROR','WARNING' and 'DEBUG' messages to all be displayed..

  4. 'INFO' - displays all useful information such as configuration assumptions, success messages, etc.

    • This level displays all log_level messages.

Post initialization configuration#

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

True

Determines whether to provide values for missing data points. If True, copies previous value.

IGNORE_T_COSTS

True

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

['LONDON_1600', 'EOD']

Sets data point defaults according to Trading Manager Calendar.

TM_INTRADAY_OUT_OF_HOURS

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 a 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.

Re-initializing your environment#

Note: to destroy your configured environment and clear the cache in preparation for initializing a new environment, use sig.de_init().

Sometimes, you may want to re-initialize an environment with new parameters. Attempts to re-initialize an already initialized environment will produce different behaviour based on the value of the repeat_mode parameter. This parameter controls how the environment behaves if init() is called more than once (i.e. you reinitialize an environment). The three repeat_mode options are as follows:

  • 'reinit' - runs the de_init() command (destroying the environment) and then runs init() again (creating a new environment).

  • 'error' - if a second init() command is called, this command is terminated and an error is displayed explaining why.

  • 'warning' - the second init() command is allowed to finish and a warning is displayed that another environment has been created.

Note: Entering sig.de_init followed by sig.init() performs the same function as sig.init(repeat_mode='reinit').

These behaviors are described in the code block below:

sig.init()
# The environment is now initialized

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