---
title: "US Regulatory Alerts - Financial Sector"
description: "US Regulatory Alerts - Financial Sector dataset from RegAlytics."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/regalytics/us-regulatory-alerts---financial-sector
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/regalytics/us-regulatory-alerts---financial-sector.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/24%20RegAlytics/01%20US%20Regulatory%20Alerts%20-%20Financial%20Sector
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# US Regulatory Alerts - Financial Sector

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [RegAlytics](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/regalytics.md) > US Regulatory Alerts - Financial Sector

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

## Introduction

The US Regulatory Alerts dataset by RegAlytics tracks changes from over 8,000 globally governing bodies. The data covers over 2.5 million alerts, starts from January 2020, and is delivered on a daily basis. This dataset is created by sourcing information from over 8,000 regulators and using proprietary technology to gather and structure the regulatory data. Once prepared, the data is thoroughly reviewed by RegAlytics' team of regulatory experts and delivered each morning by 8AM for industry use.

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 US Regulatory Alerts - Financial Sector dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/regalytics-us-regulatory-alerts).

## About the Provider

[RegAlytics](https://regalytics.ai/) was founded by Mary Kopczynski, Aaron Heisler, Alexander Appugliese, and Werner Pauliks in 2019 with the goal of significantly reducing the time and cost required to mitigate regulatory risk. RegAlytics provides access to accurate and clean regulatory data from all global regulators in all sectors that is enriched by regulatory experts for risk and compliance teams everywhere. Please come to RegAlytics directly if you would like data on other sectors or countries!

## Getting Started

The following snippet demonstrates how to request data from the US Regulatory Alerts - Financial Sector dataset:

```python
self.dataset_symbol = self.add_data(RegalyticsRegulatoryArticles, "REG").symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 2020 |
| Coverage | 2,500,000 Alerts |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | New York |

## Requesting Data

To add US Regulatory Alerts 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 RegalyticsDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2021, 1, 1)
        self.set_end_date(2021, 6, 1)
        self.set_cash(100000)

        self.dataset_symbol = self.add_data(RegalyticsRegulatoryArticles, "REG").symbol
```

## Accessing Data

To get the current US Regulatory Alerts 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_points = slice[self.dataset_symbol]
        for data_point in data_points:
            self.log(f"{self.dataset_symbol} title at {slice.time}: {data_point.title}")
```

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

```python
def on_data(self, slice: Slice) -> None:
    data = slice.get(RegalyticsRegulatoryArticles)
    if data:
        for articles in data.values():
            self.log(f"{self.time} {articles.to_string()}")

            for article in articles:
                self.log(f"{self.dataset_symbol} article title at {slice.time}: {article.title}")
```

## Historical Data

To get historical US Regulatory Alerts 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 where the columns are the RegalyticsRegulatoryArticle attributes:
history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY, flatten=True)

# Series where the values are lists of RegalyticsRegulatoryArticle objects:
history_series = self.history(self.dataset_symbol, 100, Resolution.DAILY)

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

## Remove Subscriptions

To remove your subscription to US Regulatory Alerts data, call the `remove_security` method.

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

## Example Applications

This regulatory dataset enables you to accurately design strategies while mitigating regulatory risk. Examples include the following strategies:

- Temporarily increasing/decreasing exposure to securities when new regulations are announced
- Parsing the content of regulatory announcements to determine market or sector impact
- [Country rotation based on regulatory alert sentiment](https://www.quantconnect.com/research/14843/country-rotation-based-on-regulatory-alerts-sentiment/p1)

### Classic Algorithm Example

The following example algorithm sells short 100% SPY if any predetermined negative sentimental phrase was present in any of the previous day's regulatory articles. Otherwise, it buys and hold 100% SPY.

```python
from AlgorithmImports import *

class RegalyticsDataAlgorithm(QCAlgorithm):
    # Pre-defined list of negative sentiment phrases as indicator for short selling, since these words will decrease confident in equity performance
    _negative_sentiment_phrases = [
        "emergency rule", "proposed rule change", "development of rulemaking"
    ]

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        # Seed the price of each asset with its last known price to avoid trading errors.
        self.settings.seed_initial_prices = True
        self.spy = self.add_equity("SPY", extended_market_hours=True).symbol
        # Requesting data to receive updated regulatory news for timely short selling
        self.regalytics_symbol = self.add_data(RegalyticsRegulatoryArticles, "REG").symbol

        # Historical data for past articles
        history = self.history(self.regalytics_symbol, 7, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request")

    def on_data(self, slice: Slice) -> None:
        # Only trade on regulatory news data
        data = slice.get(RegalyticsRegulatoryArticles)
        if not data:
            return
        # If any of the negative phrases appeared in regulatory news, we expect a market drop for the day
        detected_negativity = False
        for articles in data.values():
            if detected_negativity:
                break
            detected_negativity = any(
                [p in article.title.lower() for p in self._negative_sentiment_phrases for article in articles]
            )
        self.transactions.cancel_open_orders()
        quantity = self.calculate_order_quantity(self.spy, -1 if detected_negativity else 1)
        if quantity:
            self.market_order(self.spy, quantity)
```

### Framework Algorithm Example

The following example algorithm buys and holds the S&P 500 ETF, SPY. To reduce regulatory risk, it liquidates your holdings for 2 days following regulatory announcements regarding new rules.

```python
from AlgorithmImports import *

class RegalyticsDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)

        self.universe_settings.resolution = Resolution.DAILY
        # Trade SPY as the proxy of the whole equity market movement on the regulatory news
        symbols = [ Symbol.create("SPY", SecurityType.EQUITY, Market.USA) ]
        self.add_universe_selection(ManualUniverseSelectionModel(symbols))

        self.add_alpha(RegAnalyticsAlphaModel(self))

        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(lambda time: None))

        self.add_risk_management(NullRiskManagementModel())

        self.set_execution(ImmediateExecutionModel())

class RegAnalyticsAlphaModel(AlphaModel):

    symbols = []
    last_news_date = datetime.min
    target_direction = InsightDirection.UP
    # Pre-defined list of negative sentiment phrases as indicator for short selling, since these words will decrease confident in equity performance
    negative_sentiment_phrases = ["emergency rule", "proposed rule change", "development of rulemaking"]
    # Assuming the negative impact of the regulatory news will last for 2 days
    news_affect_duration = timedelta(days = 2)

    def __init__(self, algorithm: QCAlgorithm) -> None:
        # Requesting data to receive updated regulatory news for timely short selling
        self.regalytics_symbol = algorithm.add_data(RegalyticsRegulatoryArticles, "REG").symbol

        # Historical data for past articles
        history = algorithm.history(self.regalytics_symbol, 14, Resolution.DAILY)
        algorithm.debug(f"We got {len(history)} from our history request")

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        insights = []

        # Only trade on regulatory news data
        if slice.contains_key(self.regalytics_symbol) and slice[self.regalytics_symbol] is not None:
            for article in slice[self.regalytics_symbol]:
                title = article.title.lower()
                # If any of the negative phrases appeared in regulatory news, we expect a market drop for the day
                # Signal an exit from the market when regulatory articles with negative sentiment are released
                if any(phrase in title for phrase in self.negative_sentiment_phrases):
                    self.target_direction = InsightDirection.FLAT
                    self.last_news_date = slice.time

        # Signal an entry if we've waited long enough for the market to digest the negative news
        if self.last_news_date + self.news_affect_duration < slice.time:
            self.target_direction = InsightDirection.UP

        for symbol in self.symbols:
            # Ensure we have security data in the current Slice to avoid stale fill
            if not (slice.contains_key(symbol) and slice[symbol] is not None):
                continue

            if self.target_direction == InsightDirection.UP and not algorithm.portfolio[symbol].invested:
                insights += [Insight.price(symbol, timedelta(days=90), InsightDirection.UP)]
            elif self.target_direction == InsightDirection.FLAT and algorithm.portfolio[symbol].invested:
                insights += [Insight.price(symbol, self.news_affect_duration, InsightDirection.FLAT)]

        return insights

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            self.symbols.append(security.symbol)

        for security in changes.removed_securities:
            symbol = security.symbol
            if symbol in self.symbols:
                self.symbols.remove(symbol)
```

## Data Point Attributes

The US Regulatory Alerts dataset provides `RegalyticsRegulatoryArticle` and `RegalyticsRegulatoryArticles` objects.

### RegalyticsRegulatoryArticle

`RegalyticsRegulatoryArticle` objects have the following attributes:

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

### RegalyticsRegulatoryArticles

`RegalyticsRegulatoryArticles` objects have the following attributes:

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