# LongPort OpenAPI Documentation ## Introduction 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 watched group](https://open.longportapp.com/en/docs/quote/individual/watchlist_create_group.md) - [Delete watched group](https://open.longportapp.com/en/docs/quote/individual/watchlist_delete_group.md) - [Get watched groups](https://open.longportapp.com/en/docs/quote/individual/watchlist_groups.md) - [Update watched group](https://open.longportapp.com/en/docs/quote/individual/watchlist_update_group.md) ## Pull - [Get Broker IDs](https://open.longportapp.com/en/docs/quote/pull/broker-ids.md) - [Get Security Brokers](https://open.longportapp.com/en/docs/quote/pull/brokers.md) - [Get Calculate Indexes Of Securities](https://open.longportapp.com/en/docs/quote/pull/calc-index.md) - [Get Security Candlesticks](https://open.longportapp.com/en/docs/quote/pull/candlestick.md) - [Get Security Capital Distribution](https://open.longportapp.com/en/docs/quote/pull/capital-distribution.md) - [Get Security Capital Flow Intraday](https://open.longportapp.com/en/docs/quote/pull/capital-flow-intraday.md) - [Get Security Depth](https://open.longportapp.com/en/docs/quote/pull/depth.md) - [Get Security History Candlesticks](https://open.longportapp.com/en/docs/quote/pull/history-candlestick.md) - [Get Security Intraday](https://open.longportapp.com/en/docs/quote/pull/intraday.md) - [Get Warrant Issuer IDs](https://open.longportapp.com/en/docs/quote/pull/issuer.md) - [Get Real-time Quotes Of Option Securities](https://open.longportapp.com/en/docs/quote/pull/option-quote.md) - [Get Option Chain Info By Date](https://open.longportapp.com/en/docs/quote/pull/optionchain-date-strike.md) - [Get Option Chain Expiry Date List](https://open.longportapp.com/en/docs/quote/pull/optionchain-date.md) - [Get Real-time Quotes Of Securities](https://open.longportapp.com/en/docs/quote/pull/quote.md) - [Get Basic Information Of Securities](https://open.longportapp.com/en/docs/quote/pull/static.md) - [Get Market Trading Days](https://open.longportapp.com/en/docs/quote/pull/trade-day.md) - [Get Trading Session Of The Day](https://open.longportapp.com/en/docs/quote/pull/trade-session.md) - [Get Security Trades](https://open.longportapp.com/en/docs/quote/pull/trade.md) - [Get Filtered Warrant](https://open.longportapp.com/en/docs/quote/pull/warrant-filter.md) - [Get Real-time Quotes Of Warrant Securities](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) - [Get 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)