ExtractAlpha

Cross Asset Model

Introduction

The Cross Asset Model by ExtractAlpha provides stock scoring values based on the trading activity in the Options market. Since the Options market has a higher proportion of institutional traders than the Equities market, the Options market is composed of investors who are more informed and information-driven on average. The data covers a dynamic universe of over 3,000 US Equities, starts in July 2005, and is delivered on a daily frequency. This dataset is created by feature engineering on the Options market put-call spread, volatility skewness, and volume.

This dataset depends on the US Equity Security Master dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.

For more information about the Cross Asset Model dataset, including CLI commands and pricing, see the dataset listing.

About the Provider

ExtractAlpha was founded by Vinesh Jha in 2013 with the goal of providing alternative data for investors. ExtractAlpha's rigorously researched data sets and quantitative stock selection models leverage unique sources and analytical techniques, allowing users to gain an investment edge.

Getting Started

The following snippet demonstrates how to request data from the Cross Asset Model dataset:

self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
self.dataset_symbol = self.add_data(ExtractAlphaCrossAssetModel, self.aapl).symbol
_symbol = AddEquity("AAPL", Resolution.Daily).Symbol;
_datasetSymbol = AddData<ExtractAlphaCrossAssetModel>(_symbol).Symbol;

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJuly 2005
Asset CoverageOver 3,000 US Equities
Data DensitySparse
ResolutionDaily
TimezoneUTC

Requesting Data

To add Cross Asset Model data to your algorithm, call the AddDataadd_data method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.

class ExtractAlphaCrossAssetModelDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2020, 6, 1)
        self.set_cash(100000)

        self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(ExtractAlphaCrossAssetModel, self.aapl).symbol
public class ExtractAlphaCrossAssetModelDataAlgorithm : QCAlgorithm
{
    private Symbol _symbol, _datasetSymbol;

    public override void Initialize()
    {
        SetStartDate(2019, 1, 1);
        SetEndDate(2020, 6, 1);
        SetCash(100000);

        _symbol = AddEquity("AAPL", Resolution.Daily).Symbol;
        _datasetSymbol = AddData<ExtractAlphaCrossAssetModel>(_symbol).Symbol;
    }
}

Accessing Data

To get the current Cross Asset Model data, index the current Slice with the dataset Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your dataset at every time step. To avoid issues, check if the Slice contains the data you want before you index it.

def on_data(self, slice: Slice) -> None:
    if slice.contains_key(self.dataset_symbol):
        data_point = slice[self.dataset_symbol]
        self.log(f"{self.dataset_symbol} score at {slice.time}: {data_point.score}")
public override void OnData(Slice slice)
{
    if (slice.ContainsKey(_datasetSymbol))
    {
        var dataPoint = slice[_datasetSymbol];
        Log($"{_datasetSymbol} score at {slice.Time}: {dataPoint.Score}");
    }
}

To iterate through all of the dataset objects in the current Slice, call the Getget method.

def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.get(ExtractAlphaCrossAssetModel).items():
        self.log(f"{dataset_symbol} score at {slice.time}: {data_point.score}")
public override void OnData(Slice slice)
{
    foreach (var kvp in slice.Get<ExtractAlphaCrossAssetModel>())
    {
        var datasetSymbol = kvp.Key;
        var dataPoint = kvp.Value;
        Log($"{datasetSymbol} score at {slice.Time}: {dataPoint.Score}");
    }
}

Historical Data

To get historical Cross Asset Model data, call the Historyhistory method with the dataset Symbol. If there is no data in the period you request, the history result is empty.

# DataFrame
history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[ExtractAlphaCrossAssetModel](self.dataset_symbol, 100, Resolution.DAILY)
var history = History<ExtractAlphaCrossAssetModel>(_datasetSymbol, 100, Resolution.Daily);

For more information about historical data, see History Requests.

Remove Subscriptions

To remove a subscription, call the RemoveSecurityremove_security method.

self.remove_security(self.dataset_symbol)
RemoveSecurity(_datasetSymbol);

If you subscribe to Cross Asset Model data for assets in a dynamic universe, remove the dataset subscription when the asset leaves your universe. To view a common design pattern, see Track Security Changes.

Example Applications

The Cross Asset Model dataset by ExtractAlpha enables you to utilize Options market information to extract alpha. Examples include the following strategies:

  • Predicting price and volatility changes in Equities.
  • Signaling arbitrage opportunities between Options and underlying assets.
  • Using it as a stock selection indicator.

Classic Algorithm Example

The following example algorithm creates a dynamic universe of the 100 most liquid US Equities. Each day, the algorithm forms an equal-weighted dollar-neutral portfolio of the 10 companies most likely to outperform and the 10 companies most likely to underperform.

from AlgorithmImports import *

class ExtractAlphaCrossAssetModelAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100_000)
        self._points = {}
        self.add_universe(self._select_assets)
        # Add a Scheduled Event to rebalance the portfolio each day.
        spy = Symbol.create('SPY', SecurityType.EQUITY, Market.USA)
        self.schedule.on(
            self.date_rules.every_day(spy),
            self.time_rules.after_market_open(spy, 30),
            self._rebalance
        )
        
    def _select_assets(self, coarse: List[Fundamental]) -> List[Symbol]:
        # Select non-penny stocks with highest dollar volume due to better informed information from more market activities
        # Only the ones with fundamental data are supported by cross asset model data
        sorted_by_dollar_volume = sorted(
            [x for x in coarse if x.has_fundamental_data and x.price > 4], 
            key=lambda x: x.dollar_volume
        )
        return [x.symbol for x in sorted_by_dollar_volume[-100:]]

    def on_data(self, slice: Slice) -> None:    
        # Get the current data from the cross asset model.
        points = slice.get(ExtractAlphaCrossAssetModel)
        if points:
            self._points = points
            ## Demonstrate how to iterate through the data and access its members:
            #for dataset_symbol, model in points.items():
            #    self.quit(
            #        f"{self.time} -- "
            #        f"Asset Symbol: {dataset_symbol.underlying}; " 
            #        f"Score: {model.score} "
            #    )
    
    def _rebalance(self):
        # Long the ones with the highest return estimates based on option trade data
        # Short the lowest return ones
        sorted_by_score = sorted(
            [
                x for x in self._points.items() 
                # Remove assets that have no price or score.
                if self.securities[x[0].underlying].price and x[1].score
            ], 
            key=lambda x: x[1].score
        )
        long_symbols = [x[0].underlying for x in sorted_by_score[-10:]]
        short_symbols = [x[0].underlying for x in sorted_by_score[:10]]

        # Liquidate the ones without a strong trading signal
        # Invest equally and dollar-neutral to evenly dissipate capital risk and hedge systematic risk
        long_targets = [PortfolioTarget(symbol, 0.05) for symbol in long_symbols]
        short_targets = [PortfolioTarget(symbol, -0.05) for symbol in short_symbols]
        self.set_holdings(long_targets + short_targets, True)
        
    def on_securities_changed(self, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Requesting cross asset model data for trading signal generation
            security.cross_asset_model = self.add_data(
                ExtractAlphaCrossAssetModel, security.symbol
            ).symbol
            # Historical Data
            history = self.history(security.cross_asset_model, 2, Resolution.DAILY)
        for security in changes.removed_securities:
            # Remove the cross asset model data for this asset when it leaves the universe.
            self.remove_security(security.cross_asset_model)
public class ExtractAlphaCrossAssetModelAlgorithm : QCAlgorithm
{
    private DataDictionary<ExtractAlphaCrossAssetModel> _points = new DataDictionary<ExtractAlphaCrossAssetModel>();
    
    public override void Initialize()
    {
        SetStartDate(2024, 9, 1);
        SetEndDate(2024, 12, 31);
        SetCash(100000);
        AddUniverse(SelectAssets);
        // Add a Scheduled Event to rebalance the portfolio each day.
        var spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
        Schedule.On(DateRules.EveryDay(spy), TimeRules.AfterMarketOpen(spy, 30), Rebalance);
    }
    
    private IEnumerable<Symbol> SelectAssets(IEnumerable<Fundamental> coarse)
    {
        // Select non-penny stocks with highest dollar volume due to better informed information from more market activities
        // Only the ones with fundamental data are supported by cross asset model data
        return (from c in coarse
                where c.HasFundamentalData && c.Price > 4
                orderby c.DollarVolume descending
                select c.Symbol).Take(100);
    }
    
    public override void OnData(Slice slice)
    {        
        // Get the current data from the cross asset model.
        var points = slice.Get<ExtractAlphaCrossAssetModel>();
        if (points.Count > 0)
        {
            _points = points;
            //// Demonstrate how to iterate through the data and access its members:
            //foreach(var kvp in points)
            //{
            //    var datasetSymbol = kvp.Key;
            //    var model = kvp.Value;
            //    Quit(
            //        $"{Time} -- " +
            //        $"Asset Symbol: {datasetSymbol.Underlying}; " +
            //        $"Score: {model.Score}"
            //    );
            //}
        }
    }

    public void Rebalance()
    {
        // Long the ones with the highest return estimates based on option trade data
        // Short the lowest return ones
        var sortedByScore = from s in _points.Values
                        where (s.Score != null && Securities[s.Symbol.Underlying].Price != 0)
                        orderby s.Score
                        select s.Symbol.Underlying;
        var longSymbols = sortedByScore.TakeLast(10);
        var shortSymbols = sortedByScore.Take(10);

        // Liquidate the ones without a strong trading signal
        // Invest equally and dollar-neutral to evenly dissipate capital risk and hedge systematic risk
        var targets = new List<PortfolioTarget>();
        targets.AddRange(longSymbols.Select(symbol => new PortfolioTarget(symbol, 0.05m)));
        targets.AddRange(shortSymbols.Select(symbol => new PortfolioTarget(symbol, -0.05m)));
        SetHoldings(targets, true);
    }
    
    public override void OnSecuritiesChanged(SecurityChanges changes)
    {
        foreach(dynamic security in changes.AddedSecurities)
        {
            // Requesting cross asset model data for trading signal generation
            security.CrossAssetModel = AddData<ExtractAlphaCrossAssetModel>(security.Symbol).Symbol;
            // Historical Data
            var history = History(security.CrossAssetModel, 2, Resolution.Daily);
        }
        foreach (dynamic security in changes.RemovedSecurities)
        { 
            // Remove the cross asset model data for this asset when it leaves the universe.
            RemoveSecurity(security.CrossAssetModel);
        }
    }
}

Framework Algorithm Example

The following example algorithm creates a dynamic universe of the 100 most liquid US Equities. Each day, the algorithm forms an equal-weighted dollar-neutral portfolio of the 10 companies most likely to outperform and the 10 companies most likely to underperform.

from AlgorithmImports import *

class ExtractAlphaCrossAssetModelFrameworkAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        self.add_universe_selection(LiquidEquitiesUniverseSelectionModel())
        # Custom alpha model emits insights based on cross asset model data
        self.add_alpha(ExtractAlphaCrossAssetModelAlphaModel())
        # Invest equally and dollar-neutral to evenly dissipate capital risk and hedge systematic risk
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
        self.set_execution(ImmediateExecutionModel())


class LiquidEquitiesUniverseSelectionModel(FundamentalUniverseSelectionModel):

    def select(self, algorithm: QCAlgorithm, fundamentals: List[Fundamental]) -> List[Symbol]:
        # Select non-penny stocks with highest dollar volume due to better informed information from more market activities
        # Only the ones with fundamental data are supported by cross asset model data
        sorted_by_dollar_volume = sorted(
            [x for x in fundamentals if x.has_fundamental_data and x.price > 4], 
            key=lambda x: x.dollar_volume
        )
        return [x.symbol for x in sorted_by_dollar_volume[-100:]]


class ExtractAlphaCrossAssetModelAlphaModel(AlphaModel):

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        # Get the current data from the cross asset model.
        points = slice.get(ExtractAlphaCrossAssetModel)
        ## Demonstrate how to iterate through the data and access its members:
        #for dataset_symbol, model in points.items():
        #    algorithm.quit(
        #        f"{algorithm.time} -- "
        #        f"Asset Symbol: {dataset_symbol.underlying}; " 
        #        f"Score: {model.score} "
        #    )

        # Drop factors for assets that have no price or score.
        points = [
            x for x in points.items() 
            if algorithm.securities[x[0].underlying].price and x[1].score
        ]
        # Only rebalance when there are new data points from the cross asset models.
        if not points:
            return []

        # Long the ones with the highest return estimates based on option trade data
        # Short the lowest return ones
        sorted_by_score = sorted(points, key=lambda x: x[1].score)
        insight_directions = (
            [(x, InsightDirection.DOWN) for x in sorted_by_score[:10]] +
            [(x, InsightDirection.UP) for x in sorted_by_score[-10:]]
        )
        return [
            Insight.price(x[0].underlying, Expiry.END_OF_DAY, direction)
            for x, direction in insight_directions
        ]

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Requesting cross asset model data for trading signal generation
            security.cross_asset_model = algorithm.add_data(
                ExtractAlphaCrossAssetModel, security.symbol
            ).symbol
            # Historical Data
            history = algorithm.history(security.cross_asset_model, 2, Resolution.DAILY)
        for security in changes.removed_securities:
            # Remove the cross asset model data for this asset when it leaves the universe.
            algorithm.remove_security(security.cross_asset_model)
public class ExtractAlphaCrossAssetModelFrameworkAlgorithm : QCAlgorithm
{
    public override void Initialize()
    {
        SetStartDate(2024, 9, 1);
        SetEndDate(2024, 12, 31);
        SetCash(100000);
        AddUniverseSelection(new LiquidEquitiesUniverseSelectionModel());
        // Custom alpha model emits insights based on cross asset model data
        AddAlpha(new ExtractAlphaCrossAssetModelAlphaModel());
        // Invest equally and dollar-neutral to evenly dissipate capital risk and hedge systematic risk
        SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
        SetExecution(new ImmediateExecutionModel());
    }

    private IEnumerable<Symbol> MyCoarseFilterFunction(IEnumerable<CoarseFundamental> coarse)
    {

        return (from c in coarse
                where c.HasFundamentalData && c.Price > 4
                orderby c.DollarVolume descending
                select c.Symbol).Take(100);
    }
}

public class LiquidEquitiesUniverseSelectionModel : FundamentalUniverseSelectionModel
{
    public override IEnumerable<Symbol> Select(QCAlgorithm algorithm, IEnumerable<Fundamental> fundamentals)
    {
        // Select non-penny stocks with highest dollar volume due to better informed information from more market activities
        // Only the ones with fundamental data are supported by cross asset model data
        return (from f in fundamentals
                where f.HasFundamentalData && f.Price > 4
                orderby f.DollarVolume descending
                select f.Symbol).Take(100);
    }
}

public class ExtractAlphaCrossAssetModelAlphaModel: AlphaModel
{
    public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice slice)
    {        
        // Get the current data from the cross asset model.
        var points = slice.Get<ExtractAlphaCrossAssetModel>()
            // Drop factors for assets that have no price or score.
            .Where(kvp => algorithm.Securities[kvp.Key.Underlying].Price != 0 && kvp.Value.Score != null);
        // Demonstrate how to iterate through the data and access its members:
        //foreach(var kvp in points)
        //{
        //    var datasetSymbol = kvp.Key;
        //    var model = kvp.Value;
        //    algorithm.Quit(
        //        $"{algorithm.Time} -- " +
        //        $"Asset Symbol: {datasetSymbol.Underlying}; " +
        //        $"Score: {model.Score}"
        //    );
        //}

        // Long the ones with the highest return estimates based on option trade data
        // Short the lowest return ones
        var sortedByScore = points.OrderBy(kvp => kvp.Value.Score).Select(kvp => kvp.Key.Underlying);
        var longSymbols = sortedByScore.TakeLast(10);
        var shortSymbols = sortedByScore.Take(10);

        var insights = new List<Insight>();
        insights.AddRange(longSymbols.Select(symbol => new Insight(symbol, Expiry.EndOfDay, InsightType.Price, InsightDirection.Up)));
        insights.AddRange(shortSymbols.Select(symbol => new Insight(symbol, Expiry.EndOfDay, InsightType.Price, InsightDirection.Down)));
        return insights;
    }

    public override void OnSecuritiesChanged(QCAlgorithm algorithm, SecurityChanges changes)
    {
        foreach(dynamic security in changes.AddedSecurities)
        {
            // Requesting cross asset model data for trading signal generation
            security.CrossAssetModel = algorithm.AddData<ExtractAlphaCrossAssetModel>(security.Symbol).Symbol;
            // Historical Data
            var history = algorithm.History(security.CrossAssetModel, 2, Resolution.Daily);
        }
        foreach (dynamic security in changes.RemovedSecurities)
        { 
            // Remove the cross asset model data for this asset when it leaves the universe.
            algorithm.RemoveSecurity(security.CrossAssetModel);
        }
    }
}

Data Point Attributes

The Cross Asset Model dataset provides ExtractAlphaCrossAssetModel objects, which have the following attributes:

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: