2. Simple equity basket strategy

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

A multi-instrument equity strategy in seven steps

In this example, you will create a simple basket strategy to hedge investment in Apple stock against market risk. The basket strategy will long Apple and short S&P 500 ETF.

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

1. Set up environment

Note that for this tutorial we will need the pandas library:

# Import necessary libraries
import sigtech.framework as sig
import datetime as dtm
import pandas as pd
from uuid import uuid4

# Initalise the environment

2. Define historical period

As you'll need to use the start and end dates multiple times, store them as variables:

start_date = dtm.date(2016, 1, 1)
end_date = dtm.date(2020, 12, 31)

3. Define strategies and instruments

This time, you will define two ReinvestmentStrategy instances—one for the Apple stock and one for the S&P 500 ETF.

apple_rs = sig.ReinvestmentStrategy(
    ticker=f'APPLE {str(uuid4())[:5]}'

spy_rs = sig.ReinvestmentStrategy(
    underlyer='SPY UP EQUITY',
    ticker=f'SPY {str(uuid4())[:5]}'

4. 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 two ReinvestmentStrategy instances created above:

my_bs = sig.BasketStrategy(     

    # Long apple, short SPX, equal weighting
    constituent_names=[apple_rs.name, spy_rs.name],
    weights=[1, -1],

    # Rebalance the basket every month

    ticker=f'BASKET {str(uuid4())[:5]}',

    # Set the initial cash to be invested

5. Analyse performance in different ways

Plot the strategy's return

From a simple plot it looks like this strategy has performed well.


Compare the strategy's return against a benchmark

As you will see from running this code, the return of your basket strategy is much worse than just investing in the Apple stock alone:

# Compare the basket strategy's perfomance with that of the Apple stock alone
}, axis=1).dropna().plot()

Compare the strategy's risk against a benchmark

Running the following two blocks of code will reveal deeper insights about the performance of both your basket strategy and the Apple stock. If you look at market risk instead of return, you can see that your basket strategy has partially hedged against market risk.


👷Your turn: customise the strategy

Add an additional instrument and indicate whether to long or short it.

Last updated

© 2023 SIG Technologies Limited