lse-data 0.12.0__tar.gz → 3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lse_data-3.0/.gitignore +12 -0
- lse_data-3.0/CHANGELOG.md +182 -0
- lse_data-3.0/PKG-INFO +287 -0
- lse_data-3.0/README.md +255 -0
- lse_data-3.0/docs/api.md +737 -0
- {lse_data-0.12.0 → lse_data-3.0}/examples/async_stream.py +2 -2
- {lse_data-0.12.0 → lse_data-3.0}/examples/basic_stream.py +2 -2
- {lse_data-0.12.0 → lse_data-3.0}/examples/callback_style.py +2 -2
- lse_data-3.0/examples/catalogue.py +24 -0
- {lse_data-0.12.0 → lse_data-3.0}/examples/disconnect_example.py +2 -2
- lse_data-3.0/examples/history_file.py +34 -0
- lse_data-3.0/examples/macro_series.py +26 -0
- lse_data-3.0/examples/options_data.py +52 -0
- {lse_data-0.12.0 → lse_data-3.0}/examples/options_stream.py +12 -11
- lse_data-3.0/examples/reference_rows.py +23 -0
- {lse_data-0.12.0 → lse_data-3.0}/examples/save_to_csv.py +5 -7
- {lse_data-0.12.0 → lse_data-3.0}/examples/unsubscribe_example.py +3 -3
- lse_data-3.0/lse/__init__.py +8 -0
- lse_data-3.0/lse/cli.py +141 -0
- lse_data-3.0/lse/client.py +1373 -0
- lse_data-3.0/lse/data3.py +879 -0
- lse_data-3.0/lse/tui.py +297 -0
- {lse_data-0.12.0 → lse_data-3.0}/pyproject.toml +14 -6
- lse_data-0.12.0/.gitignore +0 -4
- lse_data-0.12.0/CHANGELOG.md +0 -70
- lse_data-0.12.0/PKG-INFO +0 -210
- lse_data-0.12.0/README.md +0 -181
- lse_data-0.12.0/examples/feed_health.py +0 -198
- lse_data-0.12.0/examples/options_data.py +0 -44
- lse_data-0.12.0/examples/test_limits.py +0 -358
- lse_data-0.12.0/lse/__init__.py +0 -6
- lse_data-0.12.0/lse/cli.py +0 -88
- lse_data-0.12.0/lse/client.py +0 -1137
- {lse_data-0.12.0 → lse_data-3.0}/LICENSE +0 -0
- {lse_data-0.12.0 → lse_data-3.0}/lse/py.typed +0 -0
lse_data-3.0/.gitignore
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## LSE Data 3.0
|
|
4
|
+
|
|
5
|
+
Every read of history now comes from `https://download.londonstrategicedge.com/v3`: eleven markets, over 76,000 instruments and 67 million US options contracts, resumable CSV and Parquet exports checked by SHA-256, macro and reference data, options chains and flow. The websocket, the key and the package are the same. [docs/api.md](https://github.com/londonstrategicedge/lse-data/blob/main/docs/api.md) describes every call.
|
|
6
|
+
|
|
7
|
+
Kept, with the same names and row shapes
|
|
8
|
+
|
|
9
|
+
- Streaming: `stream()`, `connect()`, `subscribe()`, `unsubscribe()`, `subscribe_options()`, `unsubscribe_options()`, `on()`, `disconnect()`, `stream_async()`, the `Tick` and `OptionTick` objects.
|
|
10
|
+
- `candles()`, `series()`, `economics()`, `bond_yields()`, `economic_calendar()`, `insider_trades()`, `dividends()`, `splits()`, `cot()`, `financial_reports()`, `company_profiles()`, `fundamentals()`, `catalog()`, `datasets()`, `reference()`, `history()`, `dataset()`, `options()`, `options_flow()`, `option_candles()`, `options_underlyings()`, answered by LSE Data 3.0 underneath.
|
|
11
|
+
- The command line: `lse auth`, `lse stream`, `lse browse`, `lse datasets`.
|
|
12
|
+
|
|
13
|
+
Added
|
|
14
|
+
|
|
15
|
+
- `markets()`, `health()`, `usage()`, `tables()`, `overview()`, `catalogue()`, `pair_page()`, `iter_pairs()`, `pairs()`, `factors()`: the catalogue of every market, with what the key may open and each instrument's stored rows.
|
|
16
|
+
- `preview()`, `estimate()`, `rows()`, `export()`, `job()`: the last ten rows of any selection, what an export would weigh, a selection as rows, and the file itself: CSV or Parquet, streamed at once or prepared as a job, resumed with `Range` after a cut, placed only after its size and SHA-256 match. `data=` selects candles, the trade slice (`timeframe="tick"`), trades, quotes, the Level 2 book, Level 3 orders or the Greeks.
|
|
17
|
+
- `dataset_export()`: candles with indicators, a companion instrument and local-time filters, computed on the server.
|
|
18
|
+
- `options_chain()`, `options_flow_page()`: the chain and the flow as pages with their totals and window.
|
|
19
|
+
- `macro_catalogue()`, `iter_macro_series()`, `macro_preview()`, `macro_series()`, `macro_estimate()`, `macro_export()`, `macro_chart_export()`: economic observations, releases and bond yields by country, as rows or files.
|
|
20
|
+
- `reference_catalogue()`, `iter_reference_series()`, `reference_preview()`, `reference_estimate()`, `reference_export()`, `reference_rows()`: eighteen reference collections with every native column.
|
|
21
|
+
- `load(path)`: a saved CSV or Parquet as a pandas DataFrame (the `frames` extra).
|
|
22
|
+
- `LSEError.code` and `LSEError.required_plan`: the server's refusal code (`plan-required`, `history-limit`, `level-required`, ...) and the plan that opens a paid feed.
|
|
23
|
+
- `LSE(..., data_url=, retries=, poll_seconds=, wait_for_limit=)`: the data server, how often a failed call is retried, how often a prepared export is polled, and whether a call past the plan's calls a minute waits once and tries again.
|
|
24
|
+
|
|
25
|
+
Changed
|
|
26
|
+
|
|
27
|
+
- Symbols are spelt as the catalogue lists them: `EUR_USD` for forex (the name `EUR/USD` is accepted too), `BTCUSDT` for crypto (`BTC/USD` is accepted too), `ESZ6` for a CME contract. A symbol listed in several markets resolves to US stocks unless `market=` says otherwise.
|
|
28
|
+
- `candles()` holds its rows in memory and reads a window of dates: pass `start` and `end`, or `limit` for the most recent bars. As in 0.x it returns at most `limit` bars, the first ones from `start` (the newest with `order="desc"`), and reads a long window a span of days at a time until it has them. `start` may be a timestamp when `end` is a date. The row's time key is still `timestamp`; rows also carry `trades`. For years of candles use `history()` or `export()`.
|
|
29
|
+
- `series()` takes the catalogue's codes: yields keep their names (`US10Y`); observations use the country-prefixed codes (`US.core_inflation_rate`). The 0.x names `cpi_yoy` and `fdtr` answer as `US.inflation_rate` and `US.interest_rate`. A name that is not a code is searched; a search that matches different series raises `series-ambiguous` with the codes, and `macro_catalogue()` lists them all.
|
|
30
|
+
- The reference readers read a collection and filter it: `insider_trades(type=)`, `financial_reports(report_type=, period=)`, `economic_calendar(region=, event=, released_only=)` apply their filters on the rows.
|
|
31
|
+
- `catalog()` lists every instrument of the nine listed markets, Nasdaq TotalView included; the two contract markets, US options and CME Globex, are listed by underlying, and `pairs(market, underlying=...)` pages through their contracts. Rows gain `pair_id`; `ticks` is the instrument's stored rows.
|
|
32
|
+
- `history()` takes `market=` beside the old `dataset=`, defaults to one-minute candles, needs `start` and `end` for a bounded pull (without them the whole stored history is asked for), and returns the file's path with `dataframe=False`.
|
|
33
|
+
- `options_flow()` carries each print's `venue`; `option_candles()` takes `timeframe=`.
|
|
34
|
+
- An option contract is accepted with or without the spaces of its OCC symbol: `AAPL 261120C00100000` or `AAPL261120C00100000`.
|
|
35
|
+
- `LSEError(status, message)` keeps its two positional arguments; `str(e)` is unchanged.
|
|
36
|
+
- The package needs no extra dependency for files; `frames` stays optional.
|
|
37
|
+
|
|
38
|
+
Removed
|
|
39
|
+
|
|
40
|
+
- `get()` over the retired `/iso` tables raises `LSEError` (410, `removed`) naming the methods to use.
|
|
41
|
+
- `vault_meta()`: `markets()`, `catalogue()` and `reference_catalogue()` answer what it answered.
|
|
42
|
+
- Arrow exports: files are CSV or Parquet.
|
|
43
|
+
|
|
44
|
+
## 0.14.0
|
|
45
|
+
|
|
46
|
+
Changed
|
|
47
|
+
|
|
48
|
+
- Every REST read is now served from the LSE vault
|
|
49
|
+
(`api.londonstrategicedge.com/vault/...`) instead of the legacy `/iso`
|
|
50
|
+
endpoints. Method signatures and row shapes are unchanged; what changed is
|
|
51
|
+
what is behind them:
|
|
52
|
+
- `candles()` accepts every vault resolution ("1s", "5s", "15s", "30s",
|
|
53
|
+
"1m", "3m", "5m", "15m", "30m", "1h", "4h", "1d", "1w", "1mo") and reaches
|
|
54
|
+
the vault's full depth (US stocks back to 2003, FX to 2009, crypto to
|
|
55
|
+
2017). Stock and ETF candles come back split adjusted.
|
|
56
|
+
- `catalog()` reads the live vault catalog (one row per dataset and symbol,
|
|
57
|
+
22,000+ instruments including economics series, bond yield tenors and
|
|
58
|
+
option underlyings) instead of a static file, so it now needs the API key.
|
|
59
|
+
Rows keep `symbol`/`name`/`category` and gain `dataset`, `ticks`, `first`,
|
|
60
|
+
`last` and `country`.
|
|
61
|
+
- `options_underlyings()` also reads the catalog and needs the key.
|
|
62
|
+
- `option_candles()` merges archive bars and live folded prints on the
|
|
63
|
+
server in one call.
|
|
64
|
+
- `get()` still accepts the previously documented `/iso` table names and
|
|
65
|
+
their filters, translating them onto the vault; anything else
|
|
66
|
+
raises an error naming the method to use instead.
|
|
67
|
+
- `economic_calendar()` no longer sends a staleness filter; the vault
|
|
68
|
+
holds only current events.
|
|
69
|
+
|
|
70
|
+
Added
|
|
71
|
+
|
|
72
|
+
- `series()`: any (date, value) observation stream in one synchronous call,
|
|
73
|
+
with the class resolved from the catalog: `series("cpi_yoy")` for a macro
|
|
74
|
+
series, `series("US10Y")` for a bond yield tenor. `economics(symbol)` now
|
|
75
|
+
returns those rows instantly instead of running an export job (use
|
|
76
|
+
`history(symbol, dataset="economics")` when you want Parquet).
|
|
77
|
+
- New reference readers, same row-dict shape as the rest: `cot()`,
|
|
78
|
+
`financial_reports()` (statements parsed from JSON), `company_profiles()`,
|
|
79
|
+
`fundamentals()` and `bond_yields()`.
|
|
80
|
+
- `candles(..., dataset=...)` to pin the asset class when a symbol exists in
|
|
81
|
+
more than one.
|
|
82
|
+
- Options history keeps accumulating in the vault: prints older than the old
|
|
83
|
+
one-week window stay queryable through `options_flow()` with `start`/`end`.
|
|
84
|
+
- `LSE(..., timeout=)` sets the REST timeout per client. The default rose from
|
|
85
|
+
30s to 60s because the longest queries (1s candles over long spans) can
|
|
86
|
+
take tens of seconds.
|
|
87
|
+
|
|
88
|
+
Fixed
|
|
89
|
+
|
|
90
|
+
- Timeouts and connection failures on REST calls and downloads now raise
|
|
91
|
+
`LSEError` like HTTP errors always did, instead of leaking a raw
|
|
92
|
+
`TimeoutError`/`URLError` traceback. One `except LSEError` covers every
|
|
93
|
+
failed call.
|
|
94
|
+
- Bare `lse` (and `lse browse`) without an interactive terminal exits with a
|
|
95
|
+
plain one-line message pointing at `lse datasets`, instead of a curses
|
|
96
|
+
traceback. Ctrl+C inside the browser exits quietly.
|
|
97
|
+
|
|
98
|
+
## 0.13.0
|
|
99
|
+
|
|
100
|
+
Added
|
|
101
|
+
|
|
102
|
+
- The vault: `history()` pulls deep history (raw ticks or any of 14 candle
|
|
103
|
+
resolutions) as Parquet through resumable async export jobs; `dataset()`
|
|
104
|
+
downloads whole reference datasets; `economics()` lists and pulls macro
|
|
105
|
+
series; `datasets()` and `reference()` list what the vault holds;
|
|
106
|
+
`vault_meta()` describes its shape. DataFrames come back directly with
|
|
107
|
+
`pip install 'lse-data[frames]'`.
|
|
108
|
+
- `lse browse`: a curses TUI over the vault catalog (also the bare `lse`
|
|
109
|
+
default), plus `lse datasets` for a plain listing.
|
|
110
|
+
|
|
111
|
+
Changed
|
|
112
|
+
|
|
113
|
+
- `vault_usage` was dropped in favour of the server's usage endpoint.
|
|
114
|
+
|
|
115
|
+
## 0.12.0
|
|
116
|
+
|
|
117
|
+
Added
|
|
118
|
+
|
|
119
|
+
- Options over REST. `options("apple")` returns the live chain (one row per
|
|
120
|
+
contract: last price, IV, greeks, today's volume and premium), filterable
|
|
121
|
+
by `type`, `expiry`, `strike` window and DTE window. Underlyings resolve
|
|
122
|
+
from tickers or company names in any case.
|
|
123
|
+
- `options_flow()`: recent option prints (time and sales) with premium, IV
|
|
124
|
+
and greeks, across one underlying or the whole tape (`min_premium=250_000`).
|
|
125
|
+
- `option_candles()`: 1-minute premium OHLC + greeks history for a single
|
|
126
|
+
contract, addressed by OSI ticker or by parts
|
|
127
|
+
(`option_candles("AAPL", strike=205, expiry="2026-06-12", type="call")`).
|
|
128
|
+
Archive bars and a live trailing week merge into one continuous series.
|
|
129
|
+
- `options_underlyings()`: every underlying with listed options, no key
|
|
130
|
+
required.
|
|
131
|
+
|
|
132
|
+
## 0.11.0
|
|
133
|
+
|
|
134
|
+
Added
|
|
135
|
+
|
|
136
|
+
- `OptionTick`: option contract ticks now arrive as a `Tick` subclass with the
|
|
137
|
+
contract parsed into named fields: `underlying`, `right` ("call"/"put"),
|
|
138
|
+
`strike`, `expiry` (a `date`), plus `dte`, `premium` (alias of `price`) and
|
|
139
|
+
`notional` (price x volume x 100) properties. `print(tick)` is now readable.
|
|
140
|
+
Non-option symbols still produce plain `Tick` objects, and `OptionTick` is a
|
|
141
|
+
`Tick`, so existing callbacks keep working unchanged.
|
|
142
|
+
- `tape()`: a ready-made tick callback that prints an aligned column table
|
|
143
|
+
(time, underlying, type, strike, expiry, DTE, premium, volume, notional)
|
|
144
|
+
with a one-time header. Usage: `client.on("tick", tape())`.
|
|
145
|
+
|
|
146
|
+
Fixed
|
|
147
|
+
|
|
148
|
+
- `subscribe()` called before `connect()` (or `stream()`) now actually takes
|
|
149
|
+
effect. Previously it added the symbol to the local set but only sent the
|
|
150
|
+
subscribe message if the socket was already open, so the common
|
|
151
|
+
`subscribe(); connect()` pattern silently received nothing for those symbols,
|
|
152
|
+
and symbols added with `subscribe()` were also not restored after a reconnect.
|
|
153
|
+
Authentication now replays the full subscription set, matching how option
|
|
154
|
+
subscriptions were already handled. Passing symbols straight to
|
|
155
|
+
`connect()`/`stream()` was unaffected.
|
|
156
|
+
|
|
157
|
+
## 0.10.0
|
|
158
|
+
|
|
159
|
+
Added
|
|
160
|
+
|
|
161
|
+
- Historical download over REST with the same key used for streaming:
|
|
162
|
+
`candles()`, `economic_calendar()`, `insider_trades()`, `dividends()`,
|
|
163
|
+
`splits()`, and a generic `get()`. Each returns a list of row dicts.
|
|
164
|
+
- `catalog()` lists every available instrument (`symbol`, `name`, `category`)
|
|
165
|
+
with optional category filtering. No key or connection required.
|
|
166
|
+
- `LSEError` raised on REST API errors (bad filter, rate limit, quota, forbidden
|
|
167
|
+
table).
|
|
168
|
+
- `LSE()` reads the `LSE_API_KEY` environment variable when no key is passed.
|
|
169
|
+
- `LSE` supports the context manager protocol (`with LSE(...) as client:`),
|
|
170
|
+
which disconnects on exit.
|
|
171
|
+
- `py.typed` marker so type checkers use the package's annotations.
|
|
172
|
+
|
|
173
|
+
Changed
|
|
174
|
+
|
|
175
|
+
- `Tick.timestamp` is typed as a string (ISO 8601), which is what the server
|
|
176
|
+
sends. Use the new `Tick.datetime` property for a parsed `datetime`.
|
|
177
|
+
|
|
178
|
+
Fixed
|
|
179
|
+
|
|
180
|
+
- Streaming no longer hangs or reconnects forever on a bad or over-quota key,
|
|
181
|
+
and `disconnect()` now ends a `stream()`/replay loop cleanly.
|
|
182
|
+
- REST calls send a User-Agent header.
|
lse_data-3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lse-data
|
|
3
|
+
Version: 3.0
|
|
4
|
+
Summary: Python client for London Strategic Edge market data: live streaming, LSE Data 3.0 history as CSV and Parquet with resumable checked downloads, macro and reference data, options chains and flow
|
|
5
|
+
Project-URL: Homepage, https://londonstrategicedge.com
|
|
6
|
+
Project-URL: Documentation, https://github.com/londonstrategicedge/lse-data/blob/main/docs/api.md
|
|
7
|
+
Project-URL: Repository, https://github.com/londonstrategicedge/lse-data
|
|
8
|
+
Project-URL: Issues, https://github.com/londonstrategicedge/lse-data/issues
|
|
9
|
+
Author-email: London Strategic Edge <support@londonstrategicedge.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: crypto,csv,forex,futures,level 2,level 3,market data,options,parquet,realtime,stocks,trading,websocket
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Requires-Dist: websockets>=11.0
|
|
28
|
+
Provides-Extra: frames
|
|
29
|
+
Requires-Dist: pandas>=1.5; extra == 'frames'
|
|
30
|
+
Requires-Dist: pyarrow>=14; extra == 'frames'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# lse-data
|
|
34
|
+
|
|
35
|
+
The Python client for LSE Data 3.0. One key streams live prices and downloads history.
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/lse-data/)
|
|
38
|
+
[](https://pypi.org/project/lse-data/)
|
|
39
|
+
[](https://github.com/londonstrategicedge/lse-data/blob/main/LICENSE)
|
|
40
|
+
[](https://pypi.org/project/lse-data/)
|
|
41
|
+
|
|
42
|
+
## LSE Data 3.0
|
|
43
|
+
|
|
44
|
+
LSE Data 3.0 is the new version of our market data archive and API, with data integrity as its first priority.
|
|
45
|
+
|
|
46
|
+
- Level 3 order data: Nasdaq TotalView, CME Globex
|
|
47
|
+
- Level 2 book: Nasdaq TotalView
|
|
48
|
+
- 24,000 additional pairs
|
|
49
|
+
- Over 76,000 instruments across 11 markets
|
|
50
|
+
- 67 million US options contracts
|
|
51
|
+
- CSV and Parquet exports
|
|
52
|
+
- Free plan: 50 GB a month
|
|
53
|
+
- Coming soon: London Stock Exchange, Toronto Stock Exchange, Eurex
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install lse-data
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from lse import LSE
|
|
61
|
+
|
|
62
|
+
client = LSE(api_key="your_key")
|
|
63
|
+
for tick in client.stream(["BTC/USD", "AAPL"]):
|
|
64
|
+
print(tick.symbol, tick.price)
|
|
65
|
+
|
|
66
|
+
path = client.export("us_stocks", "AAPL", "5m", "2026-10-08", "2026-10-14", format="csv")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
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](https://github.com/londonstrategicedge/lse-data/blob/main/docs/api.md) lists every call.
|
|
70
|
+
|
|
71
|
+
One key for streaming and downloads. `client.usage()` shows the plan and its limits.
|
|
72
|
+
|
|
73
|
+
## Download history
|
|
74
|
+
|
|
75
|
+
Rows for a quick look, files for everything else.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from lse import LSE
|
|
79
|
+
|
|
80
|
+
client = LSE(api_key="your_key")
|
|
81
|
+
|
|
82
|
+
# OHLCV candles as rows. timeframe: 1s, 5s, 15s, 30s, 1m, 3m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1mo
|
|
83
|
+
candles = client.candles("AAPL", "1h", start="2026-10-01", end="2026-10-14")
|
|
84
|
+
latest = client.candles("BTCUSDT", "1d", limit=30, order="desc")
|
|
85
|
+
|
|
86
|
+
# The last ten rows of anything, and what an export would weigh, before you ask for it
|
|
87
|
+
peek = client.preview("us_stocks", "AAPL", "5m")
|
|
88
|
+
size = client.estimate("us_stocks", "AAPL", "1m", "2016-01-04", "2026-10-21", format="parquet")
|
|
89
|
+
|
|
90
|
+
# Macro series and yields: (date, value) rows, any series in one call
|
|
91
|
+
cpi = client.series("US.core_inflation_rate", start="2020-01-01")
|
|
92
|
+
us10y = client.series("US10Y")
|
|
93
|
+
|
|
94
|
+
# Reference collections, as rows
|
|
95
|
+
events = client.economic_calendar(region="US", start="2026-10-01")
|
|
96
|
+
insiders = client.insider_trades("WRB", type="P-Purchase")
|
|
97
|
+
divs = client.dividends("AAPL")
|
|
98
|
+
splits = client.splits("NVDA")
|
|
99
|
+
cot = client.cot("GC")
|
|
100
|
+
reports = client.financial_reports("AAPL", report_type="income", period="FY")
|
|
101
|
+
profile = client.company_profiles("NVDA")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Each call returns a list of dicts. Errors raise `LSEError`:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from lse import LSEError
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
client.export("cme", "ESZ6", "tick", "2026-10-13", "2026-10-13", data="trades")
|
|
111
|
+
except LSEError as e:
|
|
112
|
+
print(e.status, e.code, e.message) # 403 plan-required This feed requires a subscription
|
|
113
|
+
print(e.required_plan) # {"market": "cme", "tier": "lite", "name": "CME Group Lite", ...}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Rows are held in memory, so keep them to days or weeks. Years of candles, ticks and order books are files.
|
|
117
|
+
|
|
118
|
+
## Files: CSV and Parquet
|
|
119
|
+
|
|
120
|
+
`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.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
path = client.export("us_stocks", "AAPL", "1m", "2016-01-04", "2026-10-21", format="parquet")
|
|
124
|
+
path = client.export("us_stocks", "AAPL", "tick", "2026-10-21", "2026-10-21", format="csv") # the trade slice
|
|
125
|
+
path = client.export("nasdaq", "NVDA", "tick", "2026-10-14", "2026-10-14", data="book") # the Level 2 book
|
|
126
|
+
path = client.export("cme", "ESZ6", "tick", "2026-10-13", "2026-10-13", data="orders") # Level 3 orders
|
|
127
|
+
path = client.macro_export("observation", "US.core_inflation_rate", "1957-02-01", "2026-07-01", format="csv")
|
|
128
|
+
path = client.reference_export("company_profiles", "AAPL", format="csv")
|
|
129
|
+
|
|
130
|
+
df = client.history("AAPL", timeframe="1d", start="2020-01-01", end="2026-10-01") # a DataFrame with the frames extra
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`pip install 'lse-data[frames]'` adds DataFrames to `history()`, `dataset()` and `load(path)`.
|
|
134
|
+
|
|
135
|
+
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.
|
|
136
|
+
|
|
137
|
+
## Options
|
|
138
|
+
|
|
139
|
+
The whole US options tape, every contract, with implied volatility and the Greeks computed twice a day.
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
chain = client.options("apple", type="call", max_dte=30)
|
|
143
|
+
prints = client.options_flow("NVDA", min_premium=100_000)
|
|
144
|
+
sweep = client.options_flow(min_premium=250_000, limit=200)
|
|
145
|
+
bars = client.option_candles("AAPL", strike=100, expiry="2026-11-20", type="call")
|
|
146
|
+
names = client.options_underlyings()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`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.
|
|
150
|
+
|
|
151
|
+
## Find instruments
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
client.markets() # every market, with what your key may open
|
|
155
|
+
client.catalog("stocks") # one dict per symbol: {"symbol": "AAPL", "name": "Apple Inc. - Common Stock", "ticks": 1627759459, ...}
|
|
156
|
+
client.pairs("us_stocks", q="apple") # a market's instruments, searched
|
|
157
|
+
client.pairs("cme", underlying="SP500", expiry="2026-12-18") # the contracts of one underlying
|
|
158
|
+
client.factors("uk_stocks", "ULVR") # an instrument's splits and, for a stock, its dividends
|
|
159
|
+
client.macro_catalogue("observation", country="US", q="inflation")
|
|
160
|
+
client.reference_catalogue() # the eighteen reference collections
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
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=`.
|
|
164
|
+
|
|
165
|
+
## Stream live data
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from lse import LSE
|
|
169
|
+
|
|
170
|
+
client = LSE(api_key="your_key")
|
|
171
|
+
for tick in client.stream(["BTC/USD", "ETH/USD", "AAPL"]):
|
|
172
|
+
print(tick.symbol, tick.price)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Use callbacks instead of a loop:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
client = LSE(api_key="your_key")
|
|
179
|
+
client.on("tick", lambda t: print(t.symbol, t.price))
|
|
180
|
+
client.connect(["BTC/USD"])
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Events are `tick`, `connected`, `authenticated`, `disconnected`, `error`, `replay_started` and `replay_complete`.
|
|
184
|
+
|
|
185
|
+
Change subscriptions while connected:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
client.subscribe(["SOL/USD"])
|
|
189
|
+
client.unsubscribe(["BTC/USD"])
|
|
190
|
+
client.subscribe_options(["AAPL"]) # every AAPL contract at once
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Replay then live
|
|
194
|
+
|
|
195
|
+
Pass `start` to replay up to 24 hours of history before the live ticks, on the same connection.
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from datetime import datetime, timedelta, timezone
|
|
199
|
+
|
|
200
|
+
start = (datetime.now(timezone.utc) - timedelta(hours=1)).strftime("%Y-%m-%dT%H:%M:%S") # UTC
|
|
201
|
+
for tick in client.stream(["BTC/USD"], start=start):
|
|
202
|
+
print("replay" if tick.replay else "live", tick.symbol, tick.price)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Async
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
import asyncio
|
|
209
|
+
from lse import LSE
|
|
210
|
+
|
|
211
|
+
async def main():
|
|
212
|
+
client = LSE(api_key="your_key")
|
|
213
|
+
async for tick in client.stream_async(["BTC/USD"]):
|
|
214
|
+
print(tick)
|
|
215
|
+
|
|
216
|
+
asyncio.run(main())
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## The key
|
|
220
|
+
|
|
221
|
+
Pass it directly, or set it in the environment:
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
client = LSE(api_key="your_key")
|
|
225
|
+
|
|
226
|
+
import os
|
|
227
|
+
os.environ["LSE_API_KEY"] = "your_key"
|
|
228
|
+
client = LSE()
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
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:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
with LSE() as client:
|
|
235
|
+
for tick in client.stream(["BTC/USD"]):
|
|
236
|
+
...
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
A tick has `symbol`, `price`, `bid`, `ask`, `volume`, `timestamp` (ISO 8601), `name` and `replay`; `tick.datetime` is the parsed timestamp.
|
|
240
|
+
|
|
241
|
+
## Settings
|
|
242
|
+
|
|
243
|
+
Every setting of `LSE()` is optional:
|
|
244
|
+
|
|
245
|
+
| Setting | Default | What it does |
|
|
246
|
+
|---|---|---|
|
|
247
|
+
| `timeout` | `60` | seconds to wait for each HTTP call |
|
|
248
|
+
| `retries` | `3` | retries of a call that got no answer, or a 429, 500, 502, 503 or 504 |
|
|
249
|
+
| `poll_seconds` | `0.5` | how often a prepared export is polled |
|
|
250
|
+
| `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 |
|
|
251
|
+
| `data_url` | `https://download.londonstrategicedge.com` | the LSE Data 3.0 server |
|
|
252
|
+
| `url` | `wss://data-ws.londonstrategicedge.com` | the live WebSocket |
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
client = LSE(api_key="your_key", timeout=120, wait_for_limit=False)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Command line
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
lse auth lse_live_xxxxxxxxxxxx
|
|
262
|
+
lse stream BTC/USD AAPL
|
|
263
|
+
lse datasets
|
|
264
|
+
lse browse
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Upgrading from 0.x
|
|
268
|
+
|
|
269
|
+
Scripts written for 0.14 keep working: the method names and row shapes are the same, except `get()`. What changed:
|
|
270
|
+
|
|
271
|
+
- `candles()` holds rows in memory and takes a date window. It still returns at most `limit` bars (5,000 by default), from `start` onwards or the most recent. To page, pass the last bar's `timestamp` as the next `start`; that bar comes back as the first row. For years of bars, use `history()` or `export()`.
|
|
272
|
+
- Symbols follow the catalogue. The 0.x spellings still resolve: `EUR/USD` to `EUR_USD`, `BTC/USD` to `BTCUSDT` (crypto is quoted in Tether).
|
|
273
|
+
- `series()` takes catalogue codes (`US10Y`, `US.core_inflation_rate`). `cpi_yoy` and `fdtr` still work, as `US.inflation_rate` and `US.interest_rate`. A name matching several series raises `LSEError` with code `series-ambiguous` and lists them.
|
|
274
|
+
- `get()` read the retired tables. It now raises `LSEError` (410, `removed`) naming the methods to use.
|
|
275
|
+
|
|
276
|
+
[CHANGELOG.md](https://github.com/londonstrategicedge/lse-data/blob/main/CHANGELOG.md) lists every change and [docs/api.md](https://github.com/londonstrategicedge/lse-data/blob/main/docs/api.md) every call.
|
|
277
|
+
|
|
278
|
+
## Licence
|
|
279
|
+
|
|
280
|
+
This client is MIT licensed. See [LICENSE](https://github.com/londonstrategicedge/lse-data/blob/main/LICENSE).
|
|
281
|
+
|
|
282
|
+
That licence extends to the library alone and confers no rights in the data
|
|
283
|
+
obtained through it. Data retrieved with an LSE key may be used for your own
|
|
284
|
+
research, trading and model training, including for commercial purposes. It may
|
|
285
|
+
not be redistributed, resold, or otherwise made available to third parties,
|
|
286
|
+
whether in bulk or by way of any competing feed, download service or interface
|
|
287
|
+
sourced from LSE. Full terms: https://londonstrategicedge.com/terms
|