---
title: "Composite Factor Bundle"
description: "Composite Factor Bundle dataset from Kavout."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/kavout/composite-factor-bundle
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/kavout/composite-factor-bundle.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/21%20Kavout/01%20Composite%20Factor%20Bundle
modified: 2026-10-29
index: https://www.quantconnect.com/llms.txt
---

# Composite Factor Bundle

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Kavout](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/kavout.md) > Composite Factor Bundle

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

The Composite Factor Bundle dataset by Kavout provides ensemble scores for popular market factors. Kavout signals are machine-learning enhanced scores that capture the returns of systematic factors such as quality, value, momentum, growth, and low volatility. There are many different anomalies discovered by researchers and practitioners across these factor categories and there is no good common definition of each style across the literature. Kavout creates an ensemble score for each style that gauges the different factors considered in the literature and industry practice.

In this data set, you will find Kavout's proprietary signals for quality, value, momentum, growth, and low volatility, which have been adopted by some of the multi-billion dollar quant funds in New York and London. Each signal is generated by an ensemble model consisting of inputs from hundreds of anomalies. The data is generated on a daily basis and covers all the stocks traded in US major markets such as NYSE and Nasdaq since 2003. You could leverage this abundant set of signals to construct and backtest your strategies.

This dataset depends on the [US Equity Security Master](https://www.quantconnect.com/datasets/quantconnect-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 Composite Factor Bundle dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/kavout-composite-factor-bundle).

## About the Provider

Kavout was created by ex-Googlers and the founding team used to work at Google, Microsoft, Baidu, and financial firms with a proven track record of building many mission-critical machine learning systems where billions of data points were processed in real-time to predict the best outcome for core search ranking, ads monetization, recommendations, and trading platforms.

Their mission is to build machine investing solutions to find alpha with adaptive learning algorithms and to create an edge by assimilating vast quantities of complex data through the latest AI and Machine Learning methods to generate signals to uncover hidden, dynamic, and nonlinear patterns in the financial markets.

## Getting Started

The following snippet demonstrates how to request data from the Composite Factor Bundle dataset:

```python
self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
self.dataset_symbol = self.add_data(KavoutCompositeFactorBundle, self.aapl).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 2003 |
| Asset Coverage | 8,000 US Equities |
| Data Density | Regular |
| Resolution | Daily |
| Timezone | UTC |

## Requesting Data

To add Composite Factor Bundle data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

```python
class KavoutCompositeFactorBundleAlgorithm(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(KavoutCompositeFactorBundle, self.aapl).symbol
```

```
public class KavoutCompositeFactorBundleAlgorithm : 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 & lt; KavoutCompositeFactorBundle & gt; (_symbol).Symbol;
    }
}
```

## Accessing Data

To get the current Composite Factor Bundle data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) 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.

```python
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} momentum at {slice.time}: {data_point.momentum}")
```

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

```python
def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.get(KavoutCompositeFactorBundle).items():
        self.log(f"{dataset_symbol} momentum at {slice.time}: {data_point.momentum}")
```

## Historical Data

To get historical Composite Factor Bundle data, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

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

# Dataset objects
history_bars = self.history[KavoutCompositeFactorBundle](self.dataset_symbol, 100, Resolution.DAILY)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Remove Subscriptions

To remove a subscription, call the `remove_security` method.

```python
self.remove_security(self.dataset_symbol)
```

If you subscribe to Composite Factor Bundle 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](https://www.quantconnect.com/docs/v2/writing-algorithms/algorithm-framework/alpha/key-concepts.md#05-Track-Security-Changes).

## Example Applications

The Composite Factor Bundle dataset enables you to access the performance of 5 different factors in order to engineer strategies. Examples include the following strategies:

- Performing return-risk optimization based on performance and volatility scoring.
- Weighing stocks based on regression analysis in factor-vector space.

### Classic Algorithm Example

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

```python
from AlgorithmImports import *

class KavoutCompositeFactorBundleAlgorithm(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(self._select_assets)

    def _select_assets(self, fundamentals: List[Fundamental]) -> List[Symbol]:
        # Filter for the highly traded stocks for more informed data from frequent market activities, which may translate to more accurate prediction
        # Factors scores are only available for the ones with fundamentals
        sorted_by_dollar_volume = sorted(
            [x for x in fundamentals if x.has_fundamental_data],
            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 Kavout dataset.
        points = slice.get(KavoutCompositeFactorBundle)
        ## Demonstrate how to iterate through the data and access its members:
        #for dataset_symbol, factors in points.items():
        #    self.quit(
        #        f"{self.time} -- "
        #        f"Asset Symbol: {dataset_symbol.underlying}; "
        #        f"Growth factor: {factors.growth} "
        #    )

        # Drop factors for assets that have no price.
        points = [x for x in points.items() if self.securities[x[0].underlying].price]
        # Only rebalance when there are new Kavout factors.
        if not points:
            return

        # Long the stocks with highest factor scores, which indicate higher return from various factors
        # Short the ones with lowest factor scores for lower return estimates
        sorted_by_score = sorted(points, key=self._total_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]]

        # Invest in equal-size and dollar-neutral to evenly dissipate individual capital risk, avoid non-systematic risk, and better margin
        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 factor bundle data for trade signal generation
            security.kavout_symbol = self.add_data(KavoutCompositeFactorBundle, security.symbol).symbol
            # Historical Data
            history = self.history(security.kavout_symbol, 2, Resolution.DAILY)
        for security in changes.removed_securities:
            # Remove the factor bundle data for this asset when it leaves the universe.
            self.remove_security(security.kavout_symbol)

    def _total_score(self, value) -> float:
        # Return the total score to integrate overall likelihood to outcompete, take equal weighting for each factor
        value = value[1]
        return value.growth + value.low_volatility + value.momentum + value.quality + value.value_factor
```

### Framework Algorithm Example

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

```python
from AlgorithmImports import *

class KavoutCompositeFactorBundleAlgorithm(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 to emit insights based on factor bundle data
        self.add_alpha(KavoutCompositeFactorBundleAlphaModel())
        # Invest in equal-size and dollar-neutral to evenly dissipate individual capital risk, avoid non-systematic risk, and better margin
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
        self.set_execution(ImmediateExecutionModel())

class LiquidEquitiesUniverseSelectionModel(FundamentalUniverseSelectionModel):

    def select(self, algorithm: QCAlgorithm, fundamentals: List[Fundamental]) -> List[Symbol]:
        # Filter for the highly traded stocks for more informed data from frequent market activities, which may translate to more accurate prediction
        # Factors scores are only available for the ones with fundamentals
        sorted_by_dollar_volume = sorted(
            [x for x in fundamentals if x.has_fundamental_data],
            key=lambda x: x.dollar_volume
        )
        return [x.symbol for x in sorted_by_dollar_volume[-100:]]

class KavoutCompositeFactorBundleAlphaModel(AlphaModel):

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        # Get the current data from the Kavout dataset.
        points = slice.get(KavoutCompositeFactorBundle)
        ## Demonstrate how to iterate through the data and access its members:
        #for dataset_symbol, factors in points.items():
        #    algorithm.quit(
        #        f"{algorithm.time} -- "
        #        f"Asset Symbol: {dataset_symbol.underlying}; "
        #        f"Growth factor: {factors.growth} "
        #    )

        # Drop factors for assets that have no price.
        points = [x for x in points.items() if algorithm.securities[x[0].underlying].price]
        # Only rebalance when there are new Kavout factors.
        if not points:
            return []

        # Long the stocks with highest factor scores, which indicate higher return from various factors
        # Short the ones with lowest factor scores for lower return estimates
        sorted_by_score = sorted(points, key=self._total_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]]

        insights = []
        for symbol in long_symbols:
            insights.append(Insight.price(symbol, Expiry.END_OF_DAY, InsightDirection.UP))
        for symbol in short_symbols:
            insights.append(Insight.price(symbol, Expiry.END_OF_DAY, InsightDirection.DOWN))
        return insights

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Requesting factor bundle data for trade signal generation
            security.kavout_symbol = algorithm.add_data(KavoutCompositeFactorBundle, security.symbol).symbol
            # Historical Data
            history = algorithm.history(security.kavout_symbol, 10, Resolution.DAILY)
        for security in changes.removed_securities:
            # Remove the factor bundle data for this asset when it leaves the universe.
            algorithm.remove_security(security.kavout_symbol)

    def _total_score(self, value) -> float:
        # Return the total score to integrate overall likelihood to outcompete, take equal weighting for each factor
        value = value[1]
        return value.growth + value.low_volatility + value.momentum + value.quality + value.value_factor
```

## Data Point Attributes

The Composite Factor Bundle dataset provides `KavoutCompositeFactorBundle` objects, which have the following attributes:

*Members of `QuantConnect.DataSource.KavoutCompositeFactorBundle` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.KavoutCompositeFactorBundle&language=python*
