longbridge
A Python library for Longbridge Open API
What it is and what it does
Longbridge is a Python SDK that wraps the Longbridge OpenAPI, a financial data and trading platform. It provides synchronous and asynchronous interfaces to multiple specialized contexts: QuoteContext for real-time quotes and candlesticks, TradeContext for order and position management, FundamentalContext for financial reports and analyst ratings, MarketContext for market status and holdings, and several others for calendar data, alerts, and portfolio analysis. The package is built with Rust bindings for performance and supports OAuth 2.0 authentication as the recommended method, with legacy API key support available.
The SDK is designed for developers building trading applications, market analysis tools, and portfolio management systems. It handles WebSocket subscriptions for push data, supports both synchronous and asynchronous workflows, and includes configuration management for multiple environments and language settings. Zero runtime dependencies keep the install footprint minimal.
Use it for:
- Build a real-time stock quote dashboard that subscribes to price updates and displays candlestick data for multiple securities.
- Automate order submission and monitor execution status, positions, and account balance across trading sessions.
- Retrieve financial reports, analyst ratings, and dividend information for fundamental analysis and valuation workflows.
- Implement price alerts and manage watchlists programmatically for custom trading workflows.
- Analyze portfolio P&L using exchange rates and portfolio context APIs for multi-currency portfolios.
- Fetch financial calendar events (earnings, splits, IPOs) to schedule market analysis or trading strategies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Longbridge provides a Python SDK for accessing Longbridge's OpenAPI, enabling programmatic access to real-time quotes, trading, account management, and financial data across multiple market contexts.
Yes, with conditions. Longbridge is actively maintained, has no known vulnerabilities, and offers a comprehensive API surface for trading and market data. However, the unclear license status is a blocker for commercial use—verify licensing terms in the repository before deploying in proprietary projects. Install friction is moderate due to compiled wheels, but this is typical for performance-critical financial libraries. Suitable for retail traders, fintech developers, and market data consumers with Longbridge account access.
Install
longbridge on PyPI
pip
pip install longbridgeuv
uv add longbridgepoetry
poetry add longbridgeInstalling longbridge
Before you install
Medium install friction due to compiled wheels across multiple Python versions and platforms (cp310–cp312, macOS, Linux, Windows). Package is actively maintained with recent releases and no known vulnerabilities.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license terms in the repository before use in proprietary or commercial projects.
Quickstart
pip install longbridge
from longbridge.openapi import Config, QuoteContext, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(
lambda url: print(f"Open this URL to authorize: {url}")
)
config = Config.from_oauth(oauth)
ctx = QuoteContext(config)
resp = ctx.quote(["700.HK", "AAPL.US"])
print(resp)
Requires OAuth client registration or legacy API key credentials (LONGBRIDGE_APP_KEY, LONGBRIDGE_APP_SECRET, LONGBRIDGE_ACCESS_TOKEN environment variables). Python >= 3.8 required.
Verify before relying
- Whether the unclear license permits commercial or proprietary use without restriction
- Real-world latency and throughput characteristics for high-frequency trading scenarios
- Completeness of async API coverage across all context types
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 363,757/month — #7,217 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: longbridge-4.5.0-cp310-cp310-macosx_10_12_x86_64.whl; longbridge-4.5.0-cp310-cp310-macosx_11_0_arm64.whl; longbridge-4.5.0-cp310-cp310-manylinux_2_39_aarch64.whl; longbridge-4.5.0-cp310-cp310-manylinux_2_39_x86_64.whl; longbridge-4.5.0-cp310-cp310-musllinux_1_2_aarch64.whl; longbridge-4.5.0-cp310-cp310-musllinux_1_2_x86_64.whl; longbridge-4.5.0-cp310-cp310-win_amd64.whl; longbridge-4.5.0-cp311-cp311-macosx_10_12_x86_64.whl; longbridge-4.5.0-cp311-cp311-macosx_11_0_arm64.whl; longbridge-4.5.0-cp311-cp311-manylinux_2_39_aarch64.whl; longbridge-4.5.0-cp311-cp311-manylinux_2_39_x86_64.whl; longbridge-4.5.0-cp311-cp311-musllinux_1_2_aarch64.whl; longbridge-4.5.0-cp311-cp311-musllinux_1_2_x86_64.whl; longbridge-4.5.0-cp311-cp311-win_amd64.whl; longbridge-4.5.0-cp312-cp312-macosx_10_12_x86_64.whl; longbridge-4.5.0-cp312-cp312-macosx_11_0_arm64.whl; longbridge-4.5.0-cp312-cp312-manylinux_2_39_aarch64.whl; longbridge-4.5.0-cp312-cp312-manylinux_2_39_x86_64.whl; longbridge-4.5.0-cp312-cp312-musllinux_1_2_aarch64.whl; longbridge-4.5.0-cp312-cp312-musllinux_1_2_x86_64.whl
Tags
More Financial packages
statsmodels provides statistical models,…
permissive · top 1,000 on PyPI
yfinanceFetches financial and market data from Yahoo…
permissive · top 1,000 on PyPI
bokehBokeh is an interactive visualization library…
permissive · top 5,000 on PyPI
python-stdnumParses, validates, and reformats standard…
copyleft · top 5,000 on PyPI
panelPanel is a Python framework for building…
permissive · top 5,000 on PyPI
databentoOfficial Python client for accessing live and…
permissive · top 5,000 on PyPI
schwab-pyUnofficial wrapper for the Charles Schwab API…
permissive · top 15,000 on PyPI
tastytradeAn asynchronous Python SDK for Tastytrade's…
permissive · top 15,000 on PyPI
kiteconnectOfficial Python client for the Kite Connect…
permissive · top 15,000 on PyPI
polygon-api-clientProvides REST and WebSocket client libraries…
permissive · top 15,000 on PyPI
massiveOfficial Python client for Massive's REST and…
permissive · top 15,000 on PyPI
openbb-tradingeconomicsIntegrates Trading Economics data into the…
agpl · top 15,000 on PyPI
tradingeconomicsProvides Python access to over 300,000 economic…
permissive · top 15,000 on PyPI
growwapiSDK for connecting to Groww's trading platform…
permissive · top 15,000 on PyPI
metatrader5Connects Python to MetaTrader 5 Terminal to…
permissive · top 15,000 on PyPI
xero-pythonProvides Python bindings to Xero's accounting,…
permissive · top 15,000 on PyPI