US Equities
AvailableDaily bars for major US stocks and ETFs, plus minute bars for a few sample days.
Split- and dividend-adjusted daily bars for SPY, QQQ, IWM, AAPL, GOOG, IBM, BAC, AIG, EEM, USO, BNO, WM and FB from 1998 to March 2021.
Minute bars exist for a few days only: SPY and IBM from 7 to 11 October 2013, and AAPL from 5 to 9 June 2014.
How the data works
- Tickers outside this list have no price data, so an algorithm subscribing to them trades nothing.
- Daily bars end on 31 March 2021, so end a backtest before then. Prefer Resolution.DAILY: a minute subscription only has data on the sample days.
- Prices are stored raw and LEAN adjusts them for splits and dividends as a backtest runs. Choose how with self.add_equity("SPY", Resolution.DAILY, data_normalization_mode=DataNormalizationMode.RAW).
- The list is today's survivors, not the market of the time, so results are flattered by survivorship bias.
Fields
4 columns| Field | Description |
|---|---|
| time | When the bar began, in the market's time zone |
| end_time | When the bar closed: the moment it reaches your algorithm |
| open, high, low, close | Prices in the bar |
| volume | Shares traded in the bar |
Example algorithm
# region imports
from AlgorithmImports import *
# endregion
class TrendAlgorithm(QCAlgorithm):
def initialize(self):
self.set_start_date(2010, 1, 1)
self.set_end_date(2021, 1, 1)
self.set_cash(100000)
self.spy = self.add_equity("SPY", Resolution.DAILY).symbol
self.fast = self.sma(self.spy, 50, Resolution.DAILY)
self.slow = self.sma(self.spy, 200, Resolution.DAILY)
self.set_warm_up(200, Resolution.DAILY)
def on_data(self, slice):
if self.is_warming_up:
return
# Hold SPY while its 50-day average is above its 200-day average.
if self.fast.current.value > self.slow.current.value:
self.set_holdings(self.spy, 1)
else:
self.liquidate(self.spy)
Sample data distributed with the open-source LEAN engine.