Equal Weighted Equity Strategy#

Understand this code: Read our step-by-step explanation of this notebook: guided walkthrough.

Restricted data: You will only have access to the data used in this notebook if your organisation has specifically purchased it. To check your current data access, view Data. If you would like to access more data, please contact sales@sigtech.com.

Heavy computation: This notebook will perform heavy computations, requiring research environment instances running with at least 4 vCPU and 16 GiB. You can check your current configuration at the bottom of the leftmost sidebar. To change the configuration, you will first need to stop the current instance.

Changes will not be saved: Edits made to SigTech’s example notebooks like this will only persist for the duration of your session. When you restart the research environment, this notebook will have been restored to its original state, and any changes you have made will have been lost. To make permanent changes, copy and paste the content to a new notebook in one of your workspaces.

Environment#

[ ]:
import sigtech.framework as sig

from uuid import uuid4
import pandas as pd
import datetime as dtm

env = sig.init(env_date=dtm.date(2024, 2, 22))

Define the investment universe#

[ ]:
equity_filter = sig.EquityUniverseFilter('DAX INDEX', use_add_order=True)

Create the strategy#

[ ]:
factor_definition = sig.FactorExposures()

factor_definition.add_raw_factor_timeseries('SIZE', fundamental_field='Market Cap', fundamental_freq='Quarterly')
[ ]:
def include_highest_by_mcap(factors, proportion = 0.3, **kwargs):
    """
    :param factors: frame where index is each factor, columns are stocks
    :param proportion: proportion of stocks to include ranked by MCAP
    :returns: series where index is stocks, value is signal
    """

    factors = factors.sum(axis=0)

    n = int(len(factors) * proportion)

    long = pd.Series(1, index=factors.nlargest(n).index)

    return long
[ ]:
equal_weighted_strategy = sig.EquityFactorBasket(

    # Base currency of the strategy
    currency='USD',

    # Start date of the strategy
    start_date=dtm.date(2021, 1, 4),

    # End date of the strategy
    end_date=dtm.date(2021, 5, 31),

    # Equity universe filter object or universe time series
    universe_filter=equity_filter,

    # Rebalance frequency
    rebalance_frequency='EOM',

    # Factor exposure object
    factor_exposure_generator=factor_definition,

    # Function to convert factor values to signals
    factors_to_weight_function=include_highest_by_mcap,

    # Allocation function to convert signals to weights
    allocation_function=sig.EquityFactorBasket.AVAILABLE_ALLOCATION_FUNCTIONS.NORMALIZE_ZERO_FILLED,

    # Name of the strategy
    ticker=f'EQUAL WEIGHTED {str(uuid4())[:4]}'
)

equal_weighted_strategy.build()

Generate the performance report#

[ ]:
sig.PerformanceReport(equal_weighted_strategy.history()).report()