Futures#

This page shows how to create and work with individual future contracts on the platform.

Learn more: Rolling Future Strategy | Example notebooks

Environment#

Setting up your environment takes three steps:

  • Import the relevant internal and external libraries

  • Configure the environment parameters

  • Initialise the environment

import sigtech.framework as sig
import datetime as dtm
import seaborn as sns

sns.set(rc={'figure.figsize': (18, 6)})
sig.config.init()

Learn more: Setting up the environment

Futures instrument#

To pull a treasury future instrument object from our object factory:

Input:

future = sig.obj.get('TYZ18 COMDTY')
future

Output:

TYZ18 COMDTY <class 'sigtech.framework.instruments.futures.BondFuture'>[5457524864]

You can then retrieve time series and static data from this object. The available time series can be retrieved by the running the below commands. The available data will differ depending on the instrument type.

Input:

future.activity_fields, future.history_fields

Output:

(['Volume', 'OpenInterest'],
 ['LastPrice',
  'OPEN',
  'HIGH',
  'LOW',
  'Volume',
  'OPEN_INTEREST',
  'QuotedLastPrice'])

To query any of the above listed time series, the.history() method is used. The method uses the parameter fields to declare which of the time series are retrieved. If no field is defined, the default value is LastPrice.

Input:

future.history().tail()

Output:

2018-12-13    120.281250
2018-12-14    120.453125
2018-12-17    120.718750
2018-12-18    120.953125
2018-12-19    120.921875
Name: (LastPrice, EOD, TYZ18 COMDTY), dtype: float64

The time series can also be plotted as shown below:

future.history(field='Volume').plot()

Additional useful methods and properties of a futures contract object are the following:

Method/Property

Explanation

.exchange_code

Exchange code for contract

.contract_expiry_code()

Expiry code for contract

.underlying_str

Underlying instrument

.contract_code

Contract code of instrument

.next_available_contract()

Next contract in futures strip

Futures group#

All future contracts for a given asset are related using a futures group:

Input:

future_group = future.group()
future_group

Output:

TY COMDTY FUTURES GROUP <class 'sigtech.framework.instruments.futures.FuturesContractGroup'>[5457523280]

From a given futures group, all futures contracts related to the group can be queried using the following method:

Input:

future_group.query_instrument_names()[:5]

Output:

['TYH00 COMDTY',
 'TYH01 COMDTY',
 'TYH02 COMDTY',
 'TYH03 COMDTY',
 'TYH04 COMDTY']

Back-adjusted futures prices#

You have the ability to work with back-adjusted futures series to avoid triggering spurious trading signals during the roll.

The following code block demonstrates this functionality by setting the back_adjusted parameter to True:

back_adj_future = sig.RFPriceIndex(
    currency='USD',
    start_date=dtm.date(2019, 1, 1),
    end_date=dtm.date(2020, 6, 4),
    contract_code='C ',
    contract_sector='Comdty',
    front_offset='-4:-1',
    back_adjusted=True
)

Creating strategies#

To create strategies of futures contracts, use the building block RollingFutureStrategy object.

For further information on RollingFutureStrategy, see Rolling Future Strategy.