SigTech platform user guide
Search
⌃K

4. Multi-instrument futures strategy

Create a simple basket strategy that maintains specific weightings for different instruments.

A multi-instrument strategy in seven steps

In SigTech's Research environment, create a new notebook and run the following seven code blocks:

1. Set up environment

# Import necessary libraries
import sigtech.framework as sig
import datetime as dtm
# Initalise the environment
sig.init();

2. Define instruments

# Create a list of object names (found in Data)
my_instruments = [
'C COMDTY FUTURES GROUP', # corn
'S COMDTY FUTURES GROUP', # soybeans
'SB COMDTY FUTURES GROUP' # sugar
]
# Convert the list of object names into a list of objects
my_instruments = [sig.obj.get(i) for i in my_instruments]

3. Define historical period

As you'll need to use the start and end dates multiple times, store them as variables:
my_start = dtm.date(2019, 1, 4)
my_end = dtm.date(2020, 12, 31)

4. Define a function for creating similar RollingFutureStrategy instances

Create multiple RollingFutureStrategy instances—one for each instrument listed above. Create them using this function:
def create_rfs(instrument):
rfs = sig.RollingFutureStrategy(
start_date=my_start,
end_date=my_end,
currency=instrument.currency,
contract_code=instrument.contract_code,
contract_sector=instrument.contract_sector,
rolling_rule='F_0'
)
# Returning the strategy object's name is needed for a future step
return rfs.name

5. Build the RollingFutureStrategy instances inside a dictionary

Build the RollingFutureStrategy instances and store them inside a dictionary:
# Create an empty dictionary
basket = {}
# Populate the dictionary with the chosen instruments
# for each instrument in the dictionary
# the key is the asset description
# the value is the instrument object
for instrument in my_instruments:
basket[instrument.asset_description] = create_rfs(instrument)
# Let's see what it looks like
print(basket)

6. Build the BasketStrategy

The BasketStrategy building block is a strategy of strategies—it is a container for managing multiple sub-strategies.
With the following code build a BasketStrategy to manage the three RollingFutureStrategy instances created above:
my_bs = sig.BasketStrategy(
# Add the RollingFutureStrategy objects into this basket strategy
constituent_names=basket.values(),
# Define the relative weights of the instruments
# These correspond to RollingFutureStrategy objects, so:
# Corn: 10%
# Soybeans: 20%
# Sugar: 70%
# The basket strategy will strive to maintain these weightings
weights=[0.1, 0.2, 0.7],
# Every three months, the basket strategy will rebalance in order to
# maintain the weightings defined above
rebalance_frequency='3M',
currency='USD',
start_date=my_start,
end_date=my_end
)

7. Run the basket strategy and view its performance

my_bs.plot.performance()

👷
Your turn: customise the strategy

Add more instruments and define each instrument's weighting in the strategy.
© 2023 SIG Technologies Limited