Python SDK for London Strategic Edge real-time market data
Project description
lse-data
Python SDK for London Strategic Edge real-time market data.
Stream live prices for 2,000+ instruments including stocks, crypto, forex, indices, commodities, ETFs, and options.
Install
pip install lse-data
Quick start
from lse import LSE
client = LSE(api_key="your_api_key")
for tick in client.stream(["BTC/USD", "AAPL", "EUR/USD"]):
print(f"{tick.symbol}: ${tick.price}")
Get your API key at londonstrategicedge.com/data.
Features
- Real-time WebSocket streaming with auto-reconnect
- 2,000+ symbols: US/UK/EU/Asia stocks, crypto, forex, indices, commodities, options
- Sync and async interfaces
- Callback and iterator patterns
- Zero config, just an API key
Usage
Stream ticks (simplest)
from lse import LSE
client = LSE(api_key="your_key")
for tick in client.stream(["BTC/USD", "ETH/USD", "AAPL"]):
print(f"{tick.symbol:12s} ${tick.price:>12,.2f}")
Callback style
from lse import LSE
def on_tick(tick):
print(f"{tick.symbol}: {tick.price}")
client = LSE(api_key="your_key")
client.on("tick", on_tick)
client.connect(symbols=["BTC/USD", "ETH/USD"])
Async streaming
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())
Save to CSV
import csv, datetime
from lse import LSE
client = LSE(api_key="your_key")
with open("ticks.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["time", "symbol", "price", "bid", "ask"])
for tick in client.stream(["BTC/USD", "ETH/USD"]):
writer.writerow([
datetime.datetime.now().isoformat(),
tick.symbol, tick.price, tick.bid, tick.ask,
])
Tick object
Each tick has these fields:
| Field | Type | Description |
|---|---|---|
symbol |
str |
Instrument symbol (e.g. BTC/USD, AAPL) |
price |
float |
Latest price |
bid |
float |
Bid price (if available) |
ask |
float |
Ask price (if available) |
volume |
float |
Volume (if available) |
timestamp |
float |
Unix timestamp |
name |
str |
Human-readable name (e.g. Apple Inc.) |
Events
When using the callback style with .on():
| Event | Callback args | Description |
|---|---|---|
tick |
Tick |
New price tick |
connected |
(none) | WebSocket connected |
authenticated |
(none) | API key accepted |
disconnected |
(none) | Connection lost (will auto-reconnect) |
error |
str |
Error message |
Available symbols
After connecting, client.symbols contains the full list of available instruments:
client = LSE(api_key="your_key")
# stream() handles connection internally, but you can also connect manually:
import asyncio, json, websockets
async def list_symbols():
async with websockets.connect("wss://data-ws.londonstrategicedge.com") as ws:
await ws.recv() # welcome
await ws.send(json.dumps({"action": "auth", "api_key": "your_key"}))
data = json.loads(await ws.recv())
for s in data["symbols"]:
print(s["symbol"], s.get("name", ""))
asyncio.run(list_symbols())
Requirements
- Python 3.8+
websockets(installed automatically)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lse_data-0.1.0.tar.gz.
File metadata
- Download URL: lse_data-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b15ad0b58a2e484fd556b0f65b6ea012f65fba8988ccc58b9c53082335efc1d
|
|
| MD5 |
99cad92708f9f5922de6096f0cde4e59
|
|
| BLAKE2b-256 |
5734bec117d300d380969b96b736a4791a02a5e98b23b9f2d1c88039d10f7b79
|
File details
Details for the file lse_data-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lse_data-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6083e525715e450f244781c07fa5dab06a678c501b4423766688455904d2f981
|
|
| MD5 |
38460eaa11ecf8e36639b851c0281c41
|
|
| BLAKE2b-256 |
64059a0c58e7d89da24b45ad15f9b72ff422871cf7c8e80c3ea806f9d12f3918
|