Skip to main content

Python client for London Strategic Edge market data: live streaming and historical download

Project description

lse-data

A Python client for London Strategic Edge market data. Stream live prices and download history with the same key.

PyPI Python Licence Downloads

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)

It covers stocks, forex, crypto, commodities, indices and ETFs, a little over 4,000 instruments. Live ticks come over a websocket and history comes over plain HTTP, both on one key. Get a key at londonstrategicedge.com/websockets.

How it compares

lse-data yfinance Alpha Vantage Finnhub
Live websocket yes no no yes
Historical candles yes yes yes yes
Asset classes stocks, FX, crypto, commodities, indices, ETFs equities focus stocks, FX, crypto stocks, FX, crypto
Official API yes no, scrapes Yahoo yes yes
Free key yes none needed yes yes

The free key allows 100 calls a minute and 50 GB of data a month, shared between streaming and download.

Download history

The same key pulls history over REST. Candles for any instrument, plus the economic calendar, insider trades, dividends and splits.

from lse import LSE

client = LSE(api_key="your_key")

# OHLCV candles. timeframe: 1m, 5m, 15m, 1h, 4h, 1d
candles  = client.candles("BTC/USD", "1d", start="2026-01-01")
intraday = client.candles("AAPL", "1h", limit=200, order="desc")

# Reference and event feeds
events   = client.economic_calendar(region="US", start="2026-04-01")
insiders = client.insider_trades("AAPL", type="P-Purchase")
divs     = client.dividends("AAPL")
splits   = client.splits("NVDA")

# Anything else, with raw filters
rows = client.get("z_insider_trades", symbol="eq.NVDA", limit="50")

Each call returns a list of dicts. A call that fails raises LSEError:

from lse import LSEError

try:
    client.candles("BTC/USD", "1m")
except LSEError as e:
    print(e.status, e.message)

A call returns at most 5,000 rows. Page through more with start and end.

Find instruments

catalog() lists everything you can stream or download. It needs no key and no connection.

client.catalog()              # every instrument
client.catalog("crypto")      # [{"symbol": "BTC/USD", "name": "Bitcoin", "category": "Crypto"}, ...]
[x["symbol"] for x in client.catalog("forex")]

Categories are stock, forex, crypto, etf, commodity and index. Use a symbol straight in stream or candles.

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 and error.

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 and the server sends history from that point, then carries on with live ticks on the same connection. History goes back up to 24 hours.

for tick in client.stream(["BTC/USD"], start="2026-06-01T09:00:00"):
    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()

LSE also works as a context manager, which disconnects on exit:

with LSE() as client:
    for tick in client.stream(["BTC/USD"]):
        ...

A tick carries symbol, price, bid, ask, volume, timestamp (an ISO 8601 string), name and replay. Use tick.datetime for the timestamp as a parsed datetime.

Command line

lse auth lse_live_xxxxxxxxxxxx
lse stream BTC/USD AAPL

Licence

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lse_data-0.10.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lse_data-0.10.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file lse_data-0.10.0.tar.gz.

File metadata

  • Download URL: lse_data-0.10.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lse_data-0.10.0.tar.gz
Algorithm Hash digest
SHA256 f6b5acdcf5f39b04badbb515c0ef06b05c296aae276f6c9334fa65cb34a6c4a0
MD5 d0c86bd74a297ed8a8281c21c11ad08f
BLAKE2b-256 8d8ce5bc0b6e26f0f1827e0d6ec0c85b19e6a080106b9f323eecf73278d4fc38

See more details on using hashes here.

File details

Details for the file lse_data-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: lse_data-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lse_data-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aeb0645664dfb662aa96c4b751104b5d5dddb4d5a4bdebf5126a92809da37593
MD5 47a5a030475aab079a6d5edf16f6119a
BLAKE2b-256 7591148131733985fd16cf8546fcd29cf865aef42dfd27618f0449d563dcbcae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page