lse-data
The Python client for LSE Data 3.0. One key streams live prices and downloads history.
LSE Data 3.0
LSE Data 3.0 is the new version of our market data archive and API, with data integrity as its first priority.
- Level 3 order data: Nasdaq TotalView, CME Globex
- Level 2 book: Nasdaq TotalView
- 24,000 additional pairs
- Over 76,000 instruments across 11 markets
- 67 million US options contracts
- CSV and Parquet exports
- Free plan: 50 GB a month
- Coming soon: London Stock Exchange, Toronto Stock Exchange, Eurex
pip install lse-data
from lse import LSE
client = LSE(api_key="your_key")
for tick in client.stream(["BTC/USD", "AAPL"]):
print(tick.symbol, tick.price)
path = client.export("us_stocks", "AAPL", "5m", "2026-10-08", "2026-10-14", format="csv")
Markets: US, UK and Canadian stocks, forex, crypto, futures, indices, commodities, US options, CME Globex and Nasdaq TotalView, plus macro series, bond yields and 18 reference collections. docs/api.md lists every call.
One key for streaming and downloads. client.usage() shows the plan and its limits.
Download history
Rows for a quick look, files for everything else.
from lse import LSE
client = LSE(api_key="your_key")
# OHLCV candles as rows. timeframe: 1s, 5s, 15s, 30s, 1m, 3m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1mo
candles = client.candles("AAPL", "1h", start="2026-10-01", end="2026-10-14")
latest = client.candles("BTCUSDT", "1d", limit=30, order="desc")
# The last ten rows of anything, and what an export would weigh, before you ask for it
peek = client.preview("us_stocks", "AAPL", "5m")
size = client.estimate("us_stocks", "AAPL", "1m", "2016-01-04", "2026-10-21", format="parquet")
# Macro series and yields: (date, value) rows, any series in one call
cpi = client.series("US.core_inflation_rate", start="2020-01-01")
us10y = client.series("US10Y")
# Reference collections, as rows
events = client.economic_calendar(region="US", start="2026-10-01")
insiders = client.insider_trades("WRB", type="P-Purchase")
divs = client.dividends("AAPL")
splits = client.splits("NVDA")
cot = client.cot("GC")
reports = client.financial_reports("AAPL", report_type="income", period="FY")
profile = client.company_profiles("NVDA")
Each call returns a list of dicts. Errors raise LSEError:
from lse import LSEError
try:
client.export("cme", "ESZ6", "tick", "2026-10-13", "2026-10-13", data="trades")
except LSEError as e:
print(e.status, e.code, e.message) # 403 plan-required This feed requires a subscription
print(e.required_plan) # {"market": "cme", "tier": "lite", "name": "CME Group Lite", ...}
Rows are held in memory, so keep them to days or weeks. Years of candles, ticks and order books are files.
Files: CSV and Parquet
export() saves a selection as a file and returns its path. Large exports are prepared on the server; downloads resume if the connection drops and are verified when they finish. The free plan includes 50 GB a month.
path = client.export("us_stocks", "AAPL", "1m", "2016-01-04", "2026-10-21", format="parquet")
path = client.export("us_stocks", "AAPL", "tick", "2026-10-21", "2026-10-21", format="csv") # the trade slice
path = client.export("nasdaq", "NVDA", "tick", "2026-10-14", "2026-10-14", data="book") # the Level 2 book
path = client.export("cme", "ESZ6", "tick", "2026-10-13", "2026-10-13", data="orders") # Level 3 orders
path = client.macro_export("observation", "US.core_inflation_rate", "1957-02-01", "2026-07-01", format="csv")
path = client.reference_export("company_profiles", "AAPL", format="csv")
df = client.history("AAPL", timeframe="1d", start="2020-01-01", end="2026-10-01") # a DataFrame with the frames extra
pip install 'lse-data[frames]' adds DataFrames to history(), dataset() and load(path).
CME Globex and Nasdaq TotalView are paid feeds. Their rows need the feed's plan, and a free key gets an error naming the plan. Tick counts, dates, table sizes and estimates are open to every key.
Options
The whole US options tape, every contract, with implied volatility and the Greeks computed twice a day.
chain = client.options("apple", type="call", max_dte=30)
prints = client.options_flow("NVDA", min_premium=100_000)
sweep = client.options_flow(min_premium=250_000, limit=200)
bars = client.option_candles("AAPL", strike=100, expiry="2026-11-20", type="call")
names = client.options_underlyings()
options() returns the chain, one row per contract with the last trade, volume, premium, implied volatility and Greeks. options_flow() returns prints with their premium and venue; leave out the underlying to scan every name. Its window is today by default, up to seven days with start and end. option_candles() returns candles for one contract. subscribe_options(["AAPL"]) streams every AAPL contract live as OptionTick objects, which add underlying, right, strike, expiry, dte, premium and notional to a tick. With from lse import tape, client.on("tick", tape()) prints them as a readable table.
Find instruments
client.markets() # every market, with what your key may open
client.catalog("stocks") # one dict per symbol: {"symbol": "AAPL", "name": "Apple Inc. - Common Stock", "ticks": 1627759459, ...}
client.pairs("us_stocks", q="apple") # a market's instruments, searched
client.pairs("cme", underlying="SP500", expiry="2026-12-18") # the contracts of one underlying
client.factors("uk_stocks", "ULVR") # an instrument's splits and, for a stock, its dividends
client.macro_catalogue("observation", country="US", q="inflation")
client.reference_catalogue() # the eighteen reference collections
Symbols are spelt as the catalogue lists them, in any case: AAPL, EUR_USD, BTCUSDT, ESZ6, AAPL 261120C00100000. An option contract works with or without the spaces, so AAPL261120C00100000 is the same contract. Pair names work too, so EUR/USD and BTC/USD resolve. A symbol in several markets, such as AAPL, resolves to US stocks unless you pass market=.
Stream live data
from lse import LSE
client = LSE(api_key="your_key")
for tick in client.stream(["BTC/USD", "ETH/USD", "AAPL"]):
print(tick.symbol, tick.price)
Use callbacks instead of a loop:
client = LSE(api_key="your_key")
client.on("tick", lambda t: print(t.symbol, t.price))
client.connect(["BTC/USD"])
Events are tick, connected, authenticated, disconnected, error, replay_started and replay_complete.
Change subscriptions while connected:
client.subscribe(["SOL/USD"])
client.unsubscribe(["BTC/USD"])
client.subscribe_options(["AAPL"]) # every AAPL contract at once
Replay then live
Pass start to replay up to 24 hours of history before the live ticks, on the same connection.
from datetime import datetime, timedelta, timezone
start = (datetime.now(timezone.utc) - timedelta(hours=1)).strftime("%Y-%m-%dT%H:%M:%S") # UTC
for tick in client.stream(["BTC/USD"], start=start):
print("replay" if tick.replay else "live", tick.symbol, tick.price)
Async
import asyncio
from lse import LSE
async def main():
client = LSE(api_key="your_key")
async for tick in client.stream_async(["BTC/USD"]):
print(tick)
asyncio.run(main())
The key
Pass it directly, or set it in the environment:
client = LSE(api_key="your_key")
import os
os.environ["LSE_API_KEY"] = "your_key"
client = LSE()
The key never goes in a URL: downloads send it in the X-API-Key header, the stream in its first message. LSE also works as a context manager:
with LSE() as client:
for tick in client.stream(["BTC/USD"]):
...
A tick has symbol, price, bid, ask, volume, timestamp (ISO 8601), name and replay; tick.datetime is the parsed timestamp.
Settings
Every setting of LSE() is optional:
| Setting | Default | What it does |
|---|---|---|
timeout |
60 |
seconds to wait for each HTTP call |
retries |
3 |
retries of a call that got no answer, or a 429, 500, 502, 503 or 504 |
poll_seconds |
0.5 |
how often a prepared export is polled |
wait_for_limit |
True |
past your plan's calls a minute, wait the server's Retry-After once (at most two minutes) and try again; False raises at once |
data_url |
https://download.londonstrategicedge.com |
the LSE Data 3.0 server |
url |
wss://data-ws.londonstrategicedge.com |
the live WebSocket |
client = LSE(api_key="your_key", timeout=120, wait_for_limit=False)
Command line
lse auth lse_live_xxxxxxxxxxxx
lse stream BTC/USD AAPL
lse datasets
lse browse
Upgrading from 0.x
Scripts written for 0.14 keep working: the method names and row shapes are the same, except get(). What changed:
candles()holds rows in memory and takes a date window. It still returns at mostlimitbars (5,000 by default), fromstartonwards or the most recent. To page, pass the last bar'stimestampas the nextstart; that bar comes back as the first row. For years of bars, usehistory()orexport().- Symbols follow the catalogue. The 0.x spellings still resolve:
EUR/USDtoEUR_USD,BTC/USDtoBTCUSDT(crypto is quoted in Tether). series()takes catalogue codes (US10Y,US.core_inflation_rate).cpi_yoyandfdtrstill work, asUS.inflation_rateandUS.interest_rate. A name matching several series raisesLSEErrorwith codeseries-ambiguousand lists them.get()read the retired tables. It now raisesLSEError(410,removed) naming the methods to use.
CHANGELOG.md lists every change and docs/api.md every call.
Licence
This client is MIT licensed. See LICENSE.
That licence extends to the library alone and confers no rights in the data obtained through it. Data retrieved with an LSE key may be used for your own research, trading and model training, including for commercial purposes. It may not be redistributed, resold, or otherwise made available to third parties, whether in bulk or by way of any competing feed, download service or interface sourced from LSE. Full terms: https://londonstrategicedge.com/terms
Metadata
Release files for lse-data 3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lse_data-3.0.tar.gz | 67.5 kB | Without provenance | Details for lse_data-3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lse_data-3.0-py3-none-any.whl | Python 3 | none | any | Details for lse_data-3.0-py3-none-any.whl |
Total release size: 111.6 kB
Release files / lse_data-3.0.tar.gz
| Download URL | lse_data-3.0.tar.gz |
|---|---|
| Size | 67.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
805dea2b4f8edd00c8b53af87c5aff5eb6dd4b040839b0190713ed3e914d6aad
|
|
BLAKE2b-256 checksum How to use checksums |
426824d0c34c5e48c7a92be0c35cd2839ca0c91f772707a10f9ac94e0c85d2f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / lse_data-3.0-py3-none-any.whl
| Download URL | lse_data-3.0-py3-none-any.whl |
|---|---|
| Size | 44.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39fe9b375c3e57b499aa38a1167e61a8c2af5879db3358dc1b854b546712f6b7
|
|
BLAKE2b-256 checksum How to use checksums |
c7a20d680133a94c4918a4101eecf63cf776c275b92f04fd2c64354bad7943b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for lse-data 3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.