---
title: "Data Link"
description: "Data Link dataset from Nasdaq."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/nasdaq/data-link
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/nasdaq/data-link.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/22%20Nasdaq/01%20Data%20Link
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Data Link

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Nasdaq](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/nasdaq.md) > Data Link

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

## Introduction

The Data Link dataset by Nasdaq, previously known as Quandl, is a collection of alternative data sets. It has indexed millions of time-series datasets from over 400 sources, which start in different years. This dataset is delivered on several frequencies, but the free data sets have often a daily frequency.

For more information about the Data Link dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/nasdaq-data-link).

## About the Provider

"[Nasdaq](https://www.nasdaq.com/)" was initially an acronym for the National Association of Securities Dealers Automated Quotations. It was founded in 1971 by the National Association of Securities Dealers (NASD), now known as the Financial Industry Regulatory Authority ([FINRA](https://www.finra.org/)), with the goal to provide financial services and operate stock exchanges.

On Dec. 4th, 2018, Nasdaq announced it had acquired [Quandl, Inc.](https://www.quandl.com), a leading provider of alternative and core financial data. Quandl was founded by Tammer Kamel in 2012, with goal of making it easy for anyone to find and use high-quality data effectively in their professional decision-making. In 2021, Quandl was replaced by [Nasdaq Data Link](https://data.nasdaq.com/).

## Getting Started

The following snippet demonstrates how to request data from the Data Link dataset:

```python
# For premium datasets, provide your API Key
# NasdaqDataLink.set_auth_code(self.get_parameter("nasdaq-data-link-api-key"))

self.bitcoin_chain_symbol = self.add_data(NasdaqDataLink, "QDL/BCHAIN", Resolution.DAILY).symbol
# This dataset has one data column ("Value")

self.bitfinex_exchange_rate_symbol = self.add_data(NasdaqCustomColumns, "QDL/BITFINEX", Resolution.DAILY).symbol
# This dataset has multiple data columns. Create a subclass to set the default value column.

class NasdaqCustomColumns(NasdaqDataLink):
    def __init__(self) -> None:
        # Select the column "mid".
        self.value_column_name = "mid"
```

Our Nasdaq Data Link integration supports any dataset from Nasdaq that has a URL starting with `data.nasdaq.com/data/`. To import a dataset from Data Link, you need to get the dataset code. Follow these steps to get the dataset code:

1. Open the [Data Link catalog](https://data.nasdaq.com/search).
2. *(Optional)* Use the filters on the left side bar to narrow down the catalog results.
3. Click one of the data products.
4. On the data product page, click one of the table names.
5. In the top-right corner of the dataset page, copy the Nasdaq Data Link Code.

## Data Summary

The data summary depends on the specific Data Link dataset you use. Follow these steps to view the data summary of a dataset:

1. Open the [Data Link catalog](https://data.nasdaq.com/search).
2. Click one of the data products.
3. On the data product page, click one of the table names.
4. View the data frequency and description in the left sidebar.
5. Above the chart, click `Table` to view the start date, end date, and data point attributes.

## Backward Compatibility

QuantConnect/LEAN has supported Quandl since 2015. On January, 12, 2022, we moved the implementation from the [LEAN GitHub repository](https://github.com/QuantConnect/Lean) to the [Lean.DataSource.NasdaqDataLink GitHub repository](https://github.com/QuantConnect/Lean.DataSource.NasdaqDataLink). Through this transition, we maintained backward compatibility. All of the preceding code snippets work if you replace `NasdaqDataLink` with `Quandl`.

## Data Points Attributes

The Nasdaq Data Link dataset provides `NasdaqDataLink` objects with the following attributes:

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

## Requesting Data

To add Data Link 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. If there is more than one value column in the Data Link dataset, to set the `value` property of the data objects, create a sublcass of the `NasdaqDataLink` class and set its `value_column_name` property to the column name.

```python
class NasdaqDataLinkDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2022, 1, 1)
        self.set_end_date(2022, 7, 1)
        self.set_cash(100000)

        # For premium datasets, provide your API Key
        # NasdaqDataLink.set_auth_code(self.get_parameter("nasdaq-data-link-api-key"))

        self.bitcoin_chain_symbol = self.add_data(NasdaqDataLink, "QDL/BCHAIN", Resolution.DAILY).symbol
        # This dataset has one data column ("Value")
        # Source : https://data.nasdaq.com/databases/BCHAIN

        self.bitfinex_exchange_rate_symbol = self.add_data(NasdaqCustomColumns, "QDL/BITFINEX", Resolution.DAILY).symbol
        # This dataset has multiple data columns
        # Source: https://data.nasdaq.com/databases/BITFINEX

class NasdaqCustomColumns(NasdaqDataLink):
    def __init__(self) -> None:
        # Select the column "mid".
        self.value_column_name = "mid"
```

## Accessing Data

To get the current Data Link 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.

To get the default value of the dataset, use the `value` property. To get the value of a specific column in the dataset, call the `get_storage_dictionary` method and index the result with the column name.

```python
def on_data(self, slice: Slice) -> None:
    point = slice.get(self.bitcoin_chain_symbol)
    if point:
        value = point.value
        self.log(f"{self.bitcoin_chain_symbol} at {slice.time}: {value}")

    point = slice.get(self.bitfinex_exchange_rate_symbol)
    if point:
        value = point.value
        storage_dictionary = point.get_storage_dictionary()
        volume = storage_dictionary["volume"]
        self.log(f"{self.bitfinex_exchange_rate_symbol} Bitfinex exchange rate at {slice.time}: {value}")
```

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

    for dataset_symbol, data_point in slice.get(NasdaqCustomColumns).items():
        self.log(f"{dataset_symbol} value at {slice.time}: {data_point.value}")
```

## Historical Data

The process to get historical Data Link data depends on your environment.

### In Algorithms

To get historical Data Link data in an algorithm, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# DataFrames
bitcoin_chain_df = self.history(self.bitcoin_chain_symbol, 100, Resolution.DAILY)
bitfinex_exchange_rate_df = self.history(self.bitfinex_exchange_rate_symbol, 100, Resolution.DAILY)

# Dataset objects
bitcoin_chain_history = self.history[NasdaqDataLink](self.bitcoin_chain_symbol, 100, Resolution.DAILY)
bitfinex_exchange_rate_history = self.history[NasdaqCustomColumns](self.bitfinex_exchange_rate_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).

### In Research Notebooks

To get historical Data Link data in the Research Environment, call the `download` method with the data URL.

```python
from io import StringIO
data = qb.download("https://data.nasdaq.com/api/v3/datatables/QDL/BCHAIN.csv?")
df = pd.read_csv(StringIO(data), index_col=0)
```

To receive a notification when you can use the `history` method in the Research Environment to get data from Data Link, subscribe to [Lean.DataSource.NasdaqDataLink GitHub Issue #10](https://github.com/QuantConnect/Lean.DataSource.NasdaqDataLink/issues/10).

## Remove Subscriptions

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

```python
self.remove_security(self.bitcoin_chain_symbol)
self.remove_security(self.bitfinex_exchange_rate_symbol)
```

## Example Applications

The Nasdaq Data Link sources allow you to explore different kinds of data in their database to develop trading strategies. Examples include the following strategies:

- Using alternative data to regress market regime/asset price.
- Backtesting exotic derivatives or private Equity investments.

### Classic Algorithm Example

The following example algorithm subscribes to the Bitfinex Crypto Exchange Rate datasets. The algorithm takes a long position in Bitfinex BTCUSD.

```python
from AlgorithmImports import *

class NasdaqImporterAlgorithm(QCAlgorithm):

    def initialize(self):
        self.nasdaq_code = "QDL/BITFINEX"
        ## Optional argument - personal token necessary for restricted dataset
        # NasdaqDataLink.set_auth_code(self.get_parameter("nasdaq-data-link-api-key"))
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(25000)
        # Request nasdaq data link data to trade
        self.add_data(NasdaqCustomColumns, self.nasdaq_code, Resolution.DAILY, TimeZones.NEW_YORK)
        # Create SMA indicator that feed with nasdaq data link data, which can be used to determine trend for trend following trade
        self.sma = self.SMA(self.nasdaq_code, 14)

    def on_data(self, data):
        if not self.portfolio.hold_stock:
            self.set_holdings(self.nasdaq_code, 1)
            self.debug("Purchased {0} >> {1}".format(self.nasdaq_code, self.time))

        self.plot(self.nasdaq_code, "PriceSMA", self.sma.current.value)

# NasdaqDataLink often doesn't use close columns so need to tell LEAN which is the "value" column.
class NasdaqCustomColumns(NasdaqDataLink):
    def __init__(self):
        # Define ValueColumnName: cannot be None, Empty or non-existant column name
        super().__init__("mid")
        self.value_column_name = "mid"
```

### Framework Algorithm Example

The following example algorithm subscribes to the Bitcoin Chain dataset and Bitfinex Crypto Exchange Rate dataset. The algorithm takes a long position in Bitfinex BTCUSD.

```python
from AlgorithmImports import *

class NasdaqDataLinkFrameworkAlgorithm(QCAlgorithm):

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

        ### Requesting Data
        # For premium datasets, provide your API Key
        # NasdaqDataLink.set_auth_code(self.get_parameter("nasdaq-data-link-api-key"))

        # Add nasdaq data link data as trading vehicle
        bitfinex_exchange_rate_symbol = self.add_data(NasdaqDataLink, 'QDL/BCHAIN', Resolution.DAILY).symbol

        ### Historical Data
        history = self.history(bitfinex_exchange_rate_symbol, 1000, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request for {bitfinex_exchange_rate_symbol} Nasdaq Data Link")

        # Custom alpha model that emit insights based on updated nasdaq data link data
        self.add_alpha(NasdaqDataLinkAlphaModel(self))

        # Invest equally to evenly dissipate the capital concentration risk
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(lambda time: None))

class NasdaqDataLinkAlphaModel(AlphaModel):
    def __init__(self, algorithm: QCAlgorithm) -> None:
        ### Requesting NASDAQ data link custom data
        self.bitfinex_exchange_rate_symbol = algorithm.add_data(NasdaqCustomColumns, "QDL/BITFINEX", Resolution.DAILY).symbol
        # This dataset has multiple data columns, so create a custom class to set the value column name

        ### Historical Data
        history = algorithm.history(self.bitfinex_exchange_rate_symbol, 100, Resolution.DAILY)
        algorithm.debug(f"We got {len(history)} items from our history request for {self.bitfinex_exchange_rate_symbol} Nasdaq Data Link")

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

        # Trade only based on updated NASDAQ data link data
        for dataset_symbol, data_point in slice.get(NasdaqCustomColumns).items():
            if dataset_symbol != self.bitfinex_exchange_rate_symbol or algorithm.portfolio[dataset_symbol].invested:
                continue
            insights.append(Insight.price(dataset_symbol, timedelta(days=6*22), InsightDirection.UP))

        return insights

# NasdaqDataLink often doesn't use close columns so need to tell LEAN which is the "value" column.
class NasdaqCustomColumns(NasdaqDataLink):
    def __init__(self) -> None:
        # Select the column "mid".
        self.value_column_name = "mid"
```
