---
title: "Tactical"
description: "Tactical dataset from ExtractAlpha."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/extractalpha/tactical
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/extractalpha/tactical.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/16%20ExtractAlpha/03%20Tactical
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Tactical

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [ExtractAlpha](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/extractalpha.md) > Tactical

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

## Introduction

The Tactical dataset by ExtractAlpha is a stock scoring algorithm that captures the technical dynamics of individual US Equities over one to ten trading day horizons. It can assist a longer-horizon investor in timing their entry or exit points or be used in combination with existing systematic or qualitative strategies with similar holding periods.

The data covers a dynamic universe of around 4,700 US Equities per day on average, starts in January 2000, and is delivered on a daily frequency. The Tactical dataset expands upon simple reversal, liquidity, and seasonality factors to identify stocks that are likely to trend or reverse.

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 Tactical dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/extractalpha-tactical).

## About the Provider

[ExtractAlpha](https://extractalpha.com/) 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 Tactical dataset:

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

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 2000 |
| Asset Coverage | 5,000 US Equities |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | New York |
| Timestamp | 9 AM |

## Requesting Data

To add Tactical 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 ExtractAlphaTacticalModelDataAlgorithm(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(ExtractAlphaTacticalModel, self.aapl).symbol
```

## Accessing Data

To get the current Tactical 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} score at {slice.time}: {data_point.score}")
```

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(ExtractAlphaTacticalModel).items():
        self.log(f"{dataset_symbol} score at {slice.time}: {data_point.score}")
```

## Historical Data

To get historical Tactical 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_df = self.history[ExtractAlphaTacticalModel](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 Tactical 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 Tactical dataset enables you to gain insight into short-term stock dynamics for trading. Examples include the following strategies:

- Optimizing entry and exit times in a portfolio construction model.
- Using the raw factor values as technical indicators.
- Inputting the data into machine learning classifier models as trend/reversal labels.

### Classic Algorithm Example

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

```python
from AlgorithmImports import *

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

    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 tactical 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 tactical dataset.
        points = slice.get(ExtractAlphaTacticalModel)
        ## 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} "
        #    )

        # Remove 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 tactical factors.
        if not points:
            return

        # Long the ones with the highest return estimates riding from tactical strategies
        # Short the lowest that predicted stock price goes down
        sorted_by_score = sorted(points, 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]]
        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 tactical data for trading signal generation
            security.tactical_model = self.add_data(
                ExtractAlphaTacticalModel, security.symbol
            ).symbol
            # Historical Data
            history = self.history(security.tactical_model, 2, Resolution.DAILY)
        for security in changes.removed_securities:
            # Remove the tactical model data for this asset when it leaves the universe.
            self.remove_security(security.tactical_model)
```

### Framework Algorithm Example

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

```python
from AlgorithmImports import *

class ExtractAlphaTacticalModelFrameworkAlgorithm(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.add_universe_selection(LiquidEquitiesUniverseSelectionModel())
        # Custom alpha model to generate trading signal based on tactical data
        self.add_alpha(ExtractAlphaTacticalModelAlphaModel())
        # 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 tactical 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 ExtractAlphaTacticalModelAlphaModel(AlphaModel):

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        # Get the current data from the tactical dataset.
        points = slice.get(ExtractAlphaTacticalModel)
        ## 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} "
        #    )

        # Remove assets that have no price or score.
        points = [x for x in points.items() if algorithm.securities[x[0].underlying].price]

        # Long the ones with the highest return estimates riding from tactical strategies
        # Short the lowest that predicted stock price goes down
        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 tactical data for trading signal generation
            security.tactical_model = algorithm.add_data(
                ExtractAlphaTacticalModel, security.symbol
            ).symbol
            # Historical Data
            history = algorithm.history(security.tactical_model, 2, Resolution.DAILY)
        for security in changes.removed_securities:
            # Remove the tactical model data for this asset when it leaves the universe.
            algorithm.remove_security(security.tactical_model)
```

## Data Point Attributes

The Tactical dataset provides `ExtractAlphaTacticalModel` objects, which have the following attributes:

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