# LongPort OpenAPI Documentation LongPort OpenAPI provides programmatic quote trading interfaces for investors with research and development capabilities and assists them to build trading or quote strategy analysis tools based on their own investment strategies. The functions fall into the following categories: - **Trading** - Create, amend, cancel orders, query today's/past orders and transaction details, etc. - **Quotes** - Real-time quotes, acquisition of historical quotes, etc. - **Portfolio** - Real-time query of the account assets, positions, funds - **Real-time subscription** - Provides real-time quotes and push notifications for order status changes ## Interface Type LongPort provides diversified access methods such as HTTP / WebSockets interfaces for accessing the underlying services and SDK (Python / C++, etc.) encapsulated in the upper layer, allowing flexible choices. ## How to Enable OpenAPI 1. Log in to the [LongPort App](https://longportapp.com/download) to complete the account opening process; 2. Log in to the [longportapp.com](https://longportapp.com) and enter the developer platform, complete the developer verification (OpenAPI permission application), and obtain a token. ## Quote Coverage
Market Symbol
HK Market Securities (including equities, ETFs, Warrants, CBBCs)
Hang Seng Index
US Market Securities (including stocks, ETFs)
Nasdsaq Index
OPRA Options
CN Market Securities (including stocks, ETFs)
Index
## Trading Supported trading functions include: | Market | Stock and ETF | Warrant & CBBC | Options | | --------- | ------------- | -------------- | ------- | | HK Market | ✓ | ✓ | | | US Market | ✓ | ✓ | ✓ | ## Rate Limit {#rate-limit} | Category | Limitation | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Quote API | | | Trade API | | :::success The [OpenAPI SDK](https://open.longportapp.com/sdk) has done effective frequency control internally: - Quote: The methods under `QuoteContext` will be actively controlled by the SDK according to the server's rate limit. When the request is too fast, the SDK will automatically delay the request. Therefore, you do not need to implement the frequency control details separately. - Trade: The methods under `TradeContext` are not limited by the SDK. Due to the special nature of the trading order placement scenario, this is left to the user to handle. ::: ## Pricing {#pricing} LongPort does not charge any additional fees for activating or using interface services. You only need to open a LongPort Integrated A/C and get OpenAPI service permissions to use it for free. For actual transaction fees, please contact the brokerage firm where you have opened your securities account. ## Other The OpenAPI services are provided by LongPort and the applicable affiliates (subject to the agreement). openapi-trade.longportapp.com ## SDK - [Getting Started](https://open.longportapp.com/en/docs/getting-started.md) - [Introduction](https://open.longportapp.com/en/docs/index.md) - [llm](https://open.longportapp.com/en/docs/llm.md) ## Api-reference - [Error Codes](https://open.longportapp.com/en/docs/error-codes.md) - [Overview](https://open.longportapp.com/en/docs/how-to-access-api.md) - [Refresh Token](https://open.longportapp.com/en/docs/refresh-token-api.md) ## Socket - [Get Socket OTP (One time password)](https://open.longportapp.com/en/docs/socket-token-api.md) ## Socket - [Data Commands](https://open.longportapp.com/en/docs/socket/biz-command.md) - [Control commands](https://open.longportapp.com/en/docs/socket/control-command.md) - [Access differences between WebSocket and TCP](https://open.longportapp.com/en/docs/socket/diff_ws_tcp.md) - [Endpoints](https://open.longportapp.com/en/docs/socket/hosts.md) - [Subscribe Real-Time Market Data](https://open.longportapp.com/en/docs/socket/subscribe_quote.md) - [Subscribe Real-Time Trading Data](https://open.longportapp.com/en/docs/socket/subscribe_trade.md) ## Qa - [Quote Releated](https://open.longportapp.com/en/docs/qa/broker.md) - [General](https://open.longportapp.com/en/docs/qa/general.md) - [Trade](https://open.longportapp.com/en/docs/qa/trade.md) ## Quote - [Permissions](https://open.longportapp.com/en/docs/quote/level.md) - [Definition](https://open.longportapp.com/en/docs/quote/objects.md) - [Overview](https://open.longportapp.com/en/docs/quote/overview.md) ## Individual - [Create Watchlist Group](https://open.longportapp.com/en/docs/quote/individual/watchlist_create_group.md) - [Delete Watchlist Group](https://open.longportapp.com/en/docs/quote/individual/watchlist_delete_group.md) - [Watchlist Group](https://open.longportapp.com/en/docs/quote/individual/watchlist_groups.md) - [Update Watchlist Group](https://open.longportapp.com/en/docs/quote/individual/watchlist_update_group.md) ## Pull - [Broker IDs](https://open.longportapp.com/en/docs/quote/pull/broker-ids.md) - [Security Brokers](https://open.longportapp.com/en/docs/quote/pull/brokers.md) - [Calculate Indexes Of Securities](https://open.longportapp.com/en/docs/quote/pull/calc-index.md) - [Security Candlesticks](https://open.longportapp.com/en/docs/quote/pull/candlestick.md) - [Security Capital Distribution](https://open.longportapp.com/en/docs/quote/pull/capital-distribution.md) - [Security Capital Flow Intraday](https://open.longportapp.com/en/docs/quote/pull/capital-flow-intraday.md) - [Security Depth](https://open.longportapp.com/en/docs/quote/pull/depth.md) - [Security History Candlesticks](https://open.longportapp.com/en/docs/quote/pull/history-candlestick.md) - [Historical Market Temperature](https://open.longportapp.com/en/docs/quote/pull/history_market_temperature.md) - [Security Intraday](https://open.longportapp.com/en/docs/quote/pull/intraday.md) - [Warrant Issuer IDs](https://open.longportapp.com/en/docs/quote/pull/issuer.md) - [Current Market Temperature](https://open.longportapp.com/en/docs/quote/pull/market_temperature.md) - [Real-time Quotes of Option](https://open.longportapp.com/en/docs/quote/pull/option-quote.md) - [Option Chain By Date](https://open.longportapp.com/en/docs/quote/pull/optionchain-date-strike.md) - [Option Chain Expiry Date List](https://open.longportapp.com/en/docs/quote/pull/optionchain-date.md) - [Real-time Quotes Of Securities](https://open.longportapp.com/en/docs/quote/pull/quote.md) - [Basic Information of Securities](https://open.longportapp.com/en/docs/quote/pull/static.md) - [Market Trading Days](https://open.longportapp.com/en/docs/quote/pull/trade-day.md) - [Trading Session of The Day](https://open.longportapp.com/en/docs/quote/pull/trade-session.md) - [Security Trades](https://open.longportapp.com/en/docs/quote/pull/trade.md) - [Warrant Filter](https://open.longportapp.com/en/docs/quote/pull/warrant-filter.md) - [Real-time Quotes of Warrant](https://open.longportapp.com/en/docs/quote/pull/warrant-quote.md) ## Push - [Push Real-time Brokers](https://open.longportapp.com/en/docs/quote/push/broker.md) - [Push Real-time Depth](https://open.longportapp.com/en/docs/quote/push/depth.md) - [Push Real-time Quote](https://open.longportapp.com/en/docs/quote/push/quote.md) - [Push Real-time Trades](https://open.longportapp.com/en/docs/quote/push/trade.md) ## Security - [Retrieve the List of Securities](https://open.longportapp.com/en/docs/quote/security/security_list.md) ## Subscribe - [Subscribe Quote](https://open.longportapp.com/en/docs/quote/subscribe/subscribe.md) - [Subscription Information](https://open.longportapp.com/en/docs/quote/subscribe/subscription.md) - [Unsubscribe Quote](https://open.longportapp.com/en/docs/quote/subscribe/unsubscribe.md) ## Trade - [Definition](https://open.longportapp.com/en/docs/trade/trade-definition.md) - [Overview](https://open.longportapp.com/en/docs/trade/trade-overview.md) - [Trade Push](https://open.longportapp.com/en/docs/trade/trade-push.md) ## Asset - [Get Account Balance](https://open.longportapp.com/en/docs/trade/asset/account.md) - [Get Cash Flow](https://open.longportapp.com/en/docs/trade/asset/cashflow.md) - [Get Fund Positions](https://open.longportapp.com/en/docs/trade/asset/fund.md) - [Get margin ratio](https://open.longportapp.com/en/docs/trade/asset/margin_ratio.md) - [Get Stock Positions](https://open.longportapp.com/en/docs/trade/asset/stock.md) ## Execution - [Get History Executions](https://open.longportapp.com/en/docs/trade/execution/history_executions.md) - [Get Today Executions](https://open.longportapp.com/en/docs/trade/execution/today_executions.md) ## Order - [Estimate Maximum Purchase Quantity](https://open.longportapp.com/en/docs/trade/order/estimate_available_buy_limit.md) - [Get History Order](https://open.longportapp.com/en/docs/trade/order/history_orders.md) - [Order Details](https://open.longportapp.com/en/docs/trade/order/order_detail.md) - [Replace Order](https://open.longportapp.com/en/docs/trade/order/replace.md) - [Submit Order](https://open.longportapp.com/en/docs/trade/order/submit.md) - [Get Today Order](https://open.longportapp.com/en/docs/trade/order/today_orders.md) - [Withdraw Order](https://open.longportapp.com/en/docs/trade/order/withdraw.md)