Skip to main content

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 4,000+ instruments including stocks, crypto, forex, indices, commodities, ETFs, and 81,000+ options contracts.

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
  • 4,000+ symbols: US/UK/EU/Asia stocks, crypto, forex, indices, commodities, ETFs, 81K+ options
  • Symbol catalog API for discovery before subscribing
  • Server-side symbol validation (invalid symbols rejected immediately)
  • 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

Symbol catalog

Query available instruments before subscribing. No WebSocket connection needed.

from lse import LSE

client = LSE(api_key="your_key")

# Get all available symbols
all_symbols = client.catalog()
print(f"{len(all_symbols)} instruments available")

# Filter by category: stock, crypto, forex, etf, commodity, index
stocks = client.catalog(category="stock")
crypto = client.catalog(category="crypto")

# Each entry has symbol, display_name, and category
for s in crypto[:5]:
    print(f"{s['symbol']:12s} {s['display_name']:20s} {s['category']}")

The catalog returns every subscribable instrument. Use it to build symbol pickers, validate user input, or discover what is available.

Available categories

Category Count Examples
stock ~3,987 AAPL, NVDA, TSLA, 0005.HK, 7203.T
forex ~62 EUR/USD, GBP/JPY, USD/CHF
crypto ~58 BTC/USD, ETH/USD, SOL/USD
etf ~25 SPY, QQQ, IWM, GLD
commodity ~23 XAU/USD, WTICO/USD, NATGAS/USD
index ~13 US30, NAS100, UK100

Options (81,000+ contracts) are available separately via the WebSocket subscribe_options action.

Requirements

  • Python 3.8+
  • websockets (installed automatically)

License

MIT

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.2.0.tar.gz (8.0 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.2.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lse_data-0.2.0.tar.gz
  • Upload date:
  • Size: 8.0 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.2.0.tar.gz
Algorithm Hash digest
SHA256 ad22d58c7c5f1a566813c756c148e578c90a1cb000ea15923f4253744bf29613
MD5 3268173ac7a8400144be04d70a877860
BLAKE2b-256 7d90462221ff2d3cb4736423ceb39bb38dd88dfd3968c0ccc1765cdad4b2179c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lse_data-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e7612ccd83e61da6e4bdd0125cc10812b32e2138d40cd906cb4aee7afc36ab8
MD5 e43cd92bd6b21c5f7ce0fa7756539c49
BLAKE2b-256 e58fe323e21ccf71c6195f07defeb58b6887ccb1c79915cbcafb9198bf5d780a

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