---
title: "Brain Wikipedia Page Views"
description: "Brain Wikipedia Page Views dataset from Brain."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-wikipedia-page-views
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-wikipedia-page-views.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/08%20Brain/04%20Brain%20Wikipedia%20Page%20Views
modified: 2026-11-23
index: https://www.quantconnect.com/llms.txt
---

# Brain Wikipedia Page Views

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Brain](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain.md) > Brain Wikipedia Page Views

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

## Introduction

The Brain Wikipedia Page Views dataset by Brain tracks investor attention toward large U.S. equities by monitoring traffic on company Wikipedia pages. The dataset covers approximately 1,000 of the largest U.S. companies, broadly corresponding to the Russell 1000, and is available starting from February 2023. Data is delivered at a daily frequency.

The dataset is constructed by analyzing the number of views on each company’s Wikipedia page, including both the main page and any secondary pages that redirect to it. Only English-language Wikipedia pages are considered. The data is published daily, typically by 12:00 PM UTC, and reflects attention metrics calculated relative to the reporting date.

In addition to raw page-view counts, the dataset includes buzz metrics, which normalize current attention levels relative to historical behavior. Buzz scores are computed as the distance between current page views and the company’s own historical average over the previous six months, expressed in units of standard deviations. As a result, positive buzz values indicate unusually high attention, while negative values indicate lower-than-normal attention.

Metrics are provided across multiple time horizons, including 1-day, 7-day, and 30-day rolling windows, enabling users to study short-term spikes in attention as well as more persistent trends. These features make the dataset well-suited for research into investor attention, behavioral finance signals, event-driven strategies, and alpha models that incorporate information demand.

This dataset depends on the US Equity Security Master dataset, which provides essential information such as symbol mappings, corporate actions, and identifier consistency required for accurate historical analysis and backtesting.

For more information about the Brain Wikipedia Page Views dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/brain-wikipedia-page-views).

## About the Provider

[Brain](https://braincompany.co/bsr.html) is a Research Company that creates proprietary datasets and algorithms for investment strategies, combining experience in financial markets with strong competencies in Statistics, Machine Learning, and Natural Language Processing. The founders share a common academic background of research in Physics as well as extensive experience in Financial markets.

## Getting Started

The following snippet demonstrates how to request data from the Brain Wikipedia Page Views dataset:

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

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | February 2023 |
| Asset Coverage* | ~1,000 US Equities (approximately Russell 1000) |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | UTC |

* The coverage includes the largest U.S. equities since the start date and may evolve over time.

## Requesting Data

To add Brain Wikipedia Page Views Indicator 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 BrainWikipediaPageViewsAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2021, 1, 1)
        self.set_end_date(2021, 7, 8)
        self.set_cash(100000)
        self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(BrainWikipediaPageViews, self.aapl).symbol
```

## Accessing Data

To get the current Brain Wikipedia Page Views Indicator 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} sentiments at {slice.time}: {data_point.number_views_1}, {data_point.buzz_1}")
```

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(BrainWikipediaPageViews).items():
         self.log(f"{dataset_symbol} metric at {slice.time}: {data_point.number_views_1} , {data_point.buzz_1}")
```

## Historical Data

To get historical Brain Wikipedia Page Views 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
history_df = self.history(self.dataset_symbol, 252, Resolution.DAILY)
```

## Remove Subscriptions

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

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

## Example Applications

The Brain Wikipedia Page Views dataset enables you to incorporate investor attention signals derived from Wikipedia traffic into your strategies. Examples include the following strategies:

- Buying securities that experience unusually high spikes in Wikipedia page views, indicating elevated public interest.
- Avoiding or reducing exposure to securities with declining or abnormally low attention relative to their historical baseline.
- Scaling position sizes based on short-term or long-term attention intensity using page view and buzz metrics.
- Building cross-sectional ranking strategies that favor stocks with sustained increases in public visibility.

### Classic Algorithm Example

The following example algorithm ranks large-cap U.S. stocks daily using Brain Wikipedia Page Views attention and buzz metrics, then allocates portfolio weights proportionally to each stock’s relative attention score.

```python
from AlgorithmImports import *

class BrainWikipediaPageViewsRankingAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2025, 1, 1)
        self.set_end_date(2025, 11, 23)
        self.set_cash(100000)

        # Seed prices so we don't get "no price" trading errors
        self.settings.seed_initial_prices = True

        # We cherry-picked 5 largest stocks, high trading volume provides better information and credibility for ML ranking
        tickers = ["AAPL", "TSLA", "MSFT", "F", "KO"]

        for ticker in tickers:
            # Requesting data to get 2 days estimated relative ranking
            equity = self.add_equity(ticker, Resolution.DAILY)
            equity.dataset_symbol = self.add_data(BrainWikipediaPageViews, equity.symbol).symbol

            # Historical data
            history = self.history(equity.dataset_symbol, 252, Resolution.DAILY)
            self.debug(f"We got {len(history)} items from our history request for {equity.symbol}")

    def on_data(self, slice: Slice) -> None:
        points = slice.get(BrainWikipediaPageViews)

        if not points:
            return

        scores = {}

        for point in points.values():
            # Example composite signal:
            number_of_views = point.number_views_1 if point.number_views_1 else 0
            buzz1day = point.buzz_1 if point.buzz_1 else 0

            symbol = point.symbol.underlying
            scores[symbol] = buzz1day * math.sqrt(number_of_views)

        if len(scores) == 0:
            return

        # Rank by score (higher score = better)
        ranked = sorted(scores.items(), key=lambda x: x[1], reverse=True)

        # Convert ranks to weights (same style as your example)
        ranks = list(range(len(ranked), 0, -1))  # best gets highest rank number
        denom = sum(ranks)
        top = ", ".join([f"{sym.value}:{sc:.4f}" for sym, sc in ranked[:3]])
        self.debug(f"{self.time.date()} top: {top}")

        # Place orders according to the ML ranking, the better the rank, the higher the estimated return and hence weight
        for i, (sym, sc) in enumerate(ranked):
            w = ranks[i] / denom
            self.set_holdings(sym, w)
```

### Framework Algorithm Example

The following example algorithm creates a dynamic universe of liquid U.S. equities, ranks them daily using Brain Wikipedia Page Views attention and buzz metrics, and emits weighted bullish insights for the most attention-driven stocks using the Alpha Framework.

```python
from AlgorithmImports import *
import math

class BrainWikipediaPageViewsFrameworkRankingAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        self.settings.seed_initial_prices = True
        self.universe_settings.resolution = Resolution.DAILY

        # Universe: pick liquid names
        self.add_universe(self._select)
        alpha = BrainWikipediaPageViewsRankingAlpha()
        self.add_alpha(alpha)

        self.schedule.on(
            self.date_rules.every_day(),
            self.time_rules.at(9, 0),
            lambda: alpha.emit_insights(self)
        )

        self.set_portfolio_construction(InsightWeightingPortfolioConstructionModel())
        self.add_risk_management(NullRiskManagementModel())
        self.set_execution(ImmediateExecutionModel())

        self.set_warmup(30, Resolution.DAILY)

    def _select(self, fundamental: List[Fundamental]) -> List[Symbol]:
        # Liquid universe
        filtered = [c for c in fundamental if c.has_fundamental_data and c.price > 10]
        filtered.sort(key=lambda c: c.dollar_volume, reverse=True)

        # Keep it manageable
        return [c.symbol for c in filtered[:50]]

class BrainWikipediaPageViewsRankingAlpha(AlphaModel):
    def __init__(self):
        self._securities = []

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        points = slice.get(BrainWikipediaPageViews)
        if not points:
            return []

        for brain_symbol, point in points.items():
            security = algorithm.securities[brain_symbol.underlying]

            number_of_views = point.number_views_1 if point.number_views_1 else 0
            buzz_1_day = point.buzz_1 if point.buzz_1 else 0

            score = buzz_1_day + math.sqrt(number_of_views)
            security.score = score

        return []

    def emit_insights(self, algorithm: QCAlgorithm) -> None:
        # Collect securities with a non-zero score
        securities = [security for security in self._securities if security.score]
        if not securities:
            return

        # Rank by score and emit weighted bullish insights
        securities.sort(key=lambda security: security.score, reverse=True)

        n = len(securities)
        denom = n * (n + 1) / 2.0

        insights = []
        for i, security in enumerate(securities):
            rank = n - i
            insights.append(Insight.price(security, timedelta(7), InsightDirection.UP, weight=rank / denom))

        algorithm.emit_insights(insights)

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Subscribe to custom data and store dataset symbol via duck typing
            dataset = algorithm.add_data(BrainWikipediaPageViews, security, Resolution.DAILY)
            security.wiki_data = dataset
            security.score = 0.0

            # Fetch historical data
            history = algorithm.history(dataset, 365, Resolution.DAILY)
            algorithm.debug(f"We got {len(history)} items from our history request")

            # Track this security
            self._securities.append(security)

        for security in changes.removed_securities:
            # Unsubscribe from custom data
            algorithm.remove_security(security.wiki_data)

            # Remove from tracking
            if security in self._securities:
                self._securities.remove(security)
```

### Research Example

The following example retrieves historical Brain Wikipedia Page Views data for Apple and prints the daily number of Wikipedia page views over the past six months.

```python
qb = QuantBook()
# Requesting Data
aapl = qb.add_equity("AAPL", Resolution.DAILY).symbol
symbol = qb.add_data(BrainWikipediaPageViews, aapl).symbol

# Historical data
history = qb.history(BrainWikipediaPageViews, symbol, 180, Resolution.DAILY)
for (symbol, time), row in history.iterrows():
    print(f"{symbol} views at {time}: {row['numberviews1']}")
```

## Data Point Attributes

The Brain Wikipedia Page Views dataset provides `BrainWikipediaPageViews` objects.

`BrainWikipediaPageViews` objects have the following attributes:

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