Futures

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

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()

Futures instrument

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

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

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.

future.activity_fields, future.history_fields

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.

future.history().tail()

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:

future_group = future.group()
future_group

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

future_group.query_instrument_names()[:5]

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.

Last updated

© 2023 SIG Technologies Limited