From 0928fe6a3dd09e2e5b72b91ecf7300dbf66c2e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E8=BD=A9=E4=BC=9F?= Date: Mon, 9 May 2022 16:30:19 +0800 Subject: [PATCH 1/3] fix catagory translation --- docs/quote/pull/broker-ids.md | 26 +++++++++++++++++++ docs/quote/pull/option-quote.md | 2 +- docs/quote/pull/quote.md | 6 ++--- docs/quote/pull/warrant-quote.md | 2 +- .../current.json | 16 ++++++------ .../current.json | 12 ++++----- .../current/quote/pull/option-quote.md | 2 +- .../current/quote/pull/quote.md | 6 ++--- .../current/quote/pull/warrant-quote.md | 2 +- 9 files changed, 50 insertions(+), 24 deletions(-) diff --git a/docs/quote/pull/broker-ids.md b/docs/quote/pull/broker-ids.md index 4d40c7cf5..cf0e8c040 100644 --- a/docs/quote/pull/broker-ids.md +++ b/docs/quote/pull/broker-ids.md @@ -11,6 +11,32 @@ sidebar_position: 7 [业务指令](../../socket/protocol/request):`16` ::: +## Request + +### Request Example +```python +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import WsCallback, WsClient +from quote_pb2 import ( + Command, + ParticipantBrokerIdsResponse, +) + +def example(): + auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) + config = Config(base_url="https://openapi.lbkrs.com") + http = HttpClient(auth, config) + ws = WsClient("wss://openapi-quote.longbridge.xyz", http, WsCallback) + result = ws.send_request(Command.QueryParticipantBrokerIds, "") + resp = ParticipantBrokerIdsResponse() + resp.ParseFromString(result) + print(f"{resp}") + + +if __name__ == "__main__": + example() +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/option-quote.md b/docs/quote/pull/option-quote.md index 7de55402f..0e31ecc86 100644 --- a/docs/quote/pull/option-quote.md +++ b/docs/quote/pull/option-quote.md @@ -40,7 +40,7 @@ message MultiSecurityRequest { | ∟ open | string | 开盘价 | | ∟ high | string | 最高价 | | ∟ low | string | 最低价 | -| ∟ timestamp | int64 | 最新成交的交时间戳 | +| ∟ timestamp | int64 | 最新成交的时间戳 | | ∟ volume | int64 | 成交量 | | ∟ turnover | string | 成交额 | | ∟ trade_status | int32 | 标的交易状态,详见 [TradeStatus](../objects#tradestatus---交易状态) | diff --git a/docs/quote/pull/quote.md b/docs/quote/pull/quote.md index f4894dc2a..498a6f4bc 100644 --- a/docs/quote/pull/quote.md +++ b/docs/quote/pull/quote.md @@ -40,13 +40,13 @@ message MultiSecurityRequest { | ∟ open | string | 开盘价 | | ∟ high | string | 最高价 | | ∟ low | string | 最低价 | -| ∟ timestamp | int64 | 最新成交的交时间戳 | +| ∟ timestamp | int64 | 最新成交的时间戳 | | ∟ volume | int64 | 成交量 | | ∟ turnover | string | 成交额 | | ∟ trade_status | int32 | 标的交易状态,详见 [TradeStatus](../objects#tradestatus---交易状态) | | ∟ pre_market_quote | object | 美股盘前交易行情 | | ∟∟ last_done | string | 最新价 | -| ∟∟ timestamp | int64 | 最新成交的交时间戳 | +| ∟∟ timestamp | int64 | 最新成交的时间戳 | | ∟∟ volume | int64 | 成交量 | | ∟∟ turnover | string | 成交额 | | ∟∟ high | string | 最高价 | @@ -54,7 +54,7 @@ message MultiSecurityRequest { | ∟∟ prev_close | string | 上一个交易阶段的收盘价 | | ∟ post_market_quote | object | 美股盘后交易行情 | | ∟∟ last_done | string | 最新价 | -| ∟∟ timestamp | int64 | 最新成交的交时间戳 | +| ∟∟ timestamp | int64 | 最新成交的时间戳 | | ∟∟ volume | int64 | 成交量 | | ∟∟ turnover | string | 成交额 | | ∟∟ high | string | 最高价 | diff --git a/docs/quote/pull/warrant-quote.md b/docs/quote/pull/warrant-quote.md index b8f6ee6ae..f22011b15 100644 --- a/docs/quote/pull/warrant-quote.md +++ b/docs/quote/pull/warrant-quote.md @@ -42,7 +42,7 @@ message MultiSecurityRequest { | ∟ open | string | 开盘价 | | ∟ high | string | 最高价 | | ∟ low | string | 最低价 | -| ∟ timestamp | int64 | 最新成交的交时间戳 | +| ∟ timestamp | int64 | 最新成交的时间戳 | | ∟ volume | int64 | 成交量 | | ∟ turnover | string | 成交额 | | ∟ trade_status | int32 | 标的交易状态,详见[TradeStatus](../objects#tradestatus---交易状态) | diff --git a/i18n/en/docusaurus-plugin-content-docs/current.json b/i18n/en/docusaurus-plugin-content-docs/current.json index b134776b5..01f9de0b5 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current.json +++ b/i18n/en/docusaurus-plugin-content-docs/current.json @@ -8,20 +8,20 @@ "description": "The label for category 准备开发 in sidebar docsSidebar" }, "sidebar.docsSidebar.category.行情": { - "message": "行情", - "description": "The label for category 行情 in sidebar docsSidebar" + "message": "Quote", + "description": "The label for category Quote in sidebar docsSidebar" }, "sidebar.docsSidebar.category.拉取": { - "message": "拉取", - "description": "The label for category 拉取 in sidebar docsSidebar" + "message": "Pull", + "description": "The label for category Pull in sidebar docsSidebar" }, "sidebar.docsSidebar.category.订阅": { - "message": "订阅", - "description": "The label for category 订阅 in sidebar docsSidebar" + "message": "Subscrption", + "description": "The label for category Subscrption in sidebar docsSidebar" }, "sidebar.docsSidebar.category.推送": { - "message": "推送", - "description": "The label for category 推送 in sidebar docsSidebar" + "message": "Push", + "description": "The label for category Push in sidebar docsSidebar" }, "sidebar.docsSidebar.category.交易": { "message": "交易", diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current.json b/i18n/zh-HK/docusaurus-plugin-content-docs/current.json index 82161e9a3..c50480672 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current.json +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current.json @@ -3,7 +3,7 @@ "message": "Next", "description": "The label for version current" }, - "sidebar.docsSidebar.category.準備開發": { + "sidebar.docsSidebar.category.准备开发": { "message": "準備開發", "description": "The label for category 準備開發 in sidebar docsSidebar" }, @@ -15,7 +15,7 @@ "message": "拉取", "description": "The label for category 拉取 in sidebar docsSidebar" }, - "sidebar.docsSidebar.category.訂閱": { + "sidebar.docsSidebar.category.订阅": { "message": "訂閱", "description": "The label for category 訂閱 in sidebar docsSidebar" }, @@ -27,19 +27,19 @@ "message": "交易", "description": "The label for category 交易 in sidebar docsSidebar" }, - "sidebar.docsSidebar.category.訂單": { + "sidebar.docsSidebar.category.订单": { "message": "訂單", "description": "The label for category 訂單 in sidebar docsSidebar" }, - "sidebar.docsSidebar.category.資產": { + "sidebar.docsSidebar.category.资产": { "message": "資產", "description": "The label for category 資產 in sidebar docsSidebar" }, - "sidebar.docsSidebar.category.長連接": { + "sidebar.docsSidebar.category.长连接": { "message": "長連接", "description": "The label for category 長連接 in sidebar docsSidebar" }, - "sidebar.docsSidebar.category.通信協議": { + "sidebar.docsSidebar.category.通信协议": { "message": "通信協議", "description": "The label for category 通信協議 in sidebar docsSidebar" } diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md index ae72577f2..53af3c9c6 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md @@ -40,7 +40,7 @@ message MultiSecurityRequest { | ∟ open | string | 開盤價 | | ∟ high | string | 最高價 | | ∟ low | string | 最低價 | -| ∟ timestamp | int64 | 最新成交的交時間戳 | +| ∟ timestamp | int64 | 最新成交的時間戳 | | ∟ volume | int64 | 成交量 | | ∟ turnover | string | 成交額 | | ∟ trade_status | int32 | 標的交易狀態,詳見 [TradeStatus](../objects#tradestatus---交易狀態) | diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md index 1b0ec3f24..77c77d35d 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md @@ -40,13 +40,13 @@ message MultiSecurityRequest { | ∟ open | string | 開盤價 | | ∟ high | string | 最高價 | | ∟ low | string | 最低價 | -| ∟ timestamp | int64 | 最新成交的交時間戳 | +| ∟ timestamp | int64 | 最新成交的時間戳 | | ∟ volume | int64 | 成交量 | | ∟ turnover | string | 成交額 | | ∟ trade_status | int32 | 標的交易狀態,詳見 [TradeStatus](../objects#tradestatus---交易狀態) | | ∟ pre_market_quote | object | 美股盤前交易行情 | | ∟∟ last_done | string | 最新價 | -| ∟∟ timestamp | int64 | 最新成交的交時間戳 | +| ∟∟ timestamp | int64 | 最新成交的時間戳 | | ∟∟ volume | int64 | 成交量 | | ∟∟ turnover | string | 成交額 | | ∟∟ high | string | 最高價 | @@ -54,7 +54,7 @@ message MultiSecurityRequest { | ∟∟ prev_close | string | 上一個交易階段的收盤價 | | ∟ post_market_quote | object | 美股盤後交易行情 | | ∟∟ last_done | string | 最新價 | -| ∟∟ timestamp | int64 | 最新成交的交時間戳 | +| ∟∟ timestamp | int64 | 最新成交的時間戳 | | ∟∟ volume | int64 | 成交量 | | ∟∟ turnover | string | 成交額 | | ∟∟ high | string | 最高價 | diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md index 0b6364cf0..37a6cf61f 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md @@ -42,7 +42,7 @@ message MultiSecurityRequest { | ∟ open | string | 開盤價 | | ∟ high | string | 最高價 | | ∟ low | string | 最低價 | -| ∟ timestamp | int64 | 最新成交的交時間戳 | +| ∟ timestamp | int64 | 最新成交的時間戳 | | ∟ volume | int64 | 成交量 | | ∟ turnover | string | 成交額 | | ∟ trade_status | int32 | 標的交易狀態,詳見[TradeStatus](../objects#tradestatus---交易狀態) | From 67d4e93c003bc87e6b07336d67aac77443bac269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E8=BD=A9=E4=BC=9F?= Date: Mon, 9 May 2022 18:20:11 +0800 Subject: [PATCH 2/3] add quote examples --- docs/quote/pull/broker-ids.md | 46 +++++++----- docs/quote/pull/brokers.md | 30 ++++++++ docs/quote/pull/candlestick.md | 30 ++++++++ docs/quote/pull/depth.md | 30 ++++++++ docs/quote/pull/intraday.md | 30 ++++++++ docs/quote/pull/issuer.md | 34 +++++++++ docs/quote/pull/option-quote.md | 30 ++++++++ docs/quote/pull/optionchain-date-strike.md | 30 ++++++++ docs/quote/pull/optionchain_date.md | 30 ++++++++ docs/quote/pull/quote.md | 30 ++++++++ docs/quote/pull/static.md | 30 ++++++++ docs/quote/pull/trade-day.md | 30 ++++++++ docs/quote/pull/trade-session.md | 31 ++++++++ docs/quote/pull/trade.md | 30 ++++++++ docs/quote/pull/warrant-filter.md | 31 ++++++++ docs/quote/pull/warrant-quote.md | 30 ++++++++ docs/quote/push/broker.md | 48 +++++++++++++ docs/quote/push/depth.md | 48 +++++++++++++ docs/quote/push/quote.md | 48 +++++++++++++ docs/quote/push/trade.md | 48 +++++++++++++ docs/quote/subscribe/subsciption.md | 72 +++++++++++++++++++ docs/quote/subscribe/subscribe.md | 48 +++++++++++++ docs/quote/subscribe/unsubscribe.md | 59 +++++++++++++++ .../current/quote/pull/broker-ids.md | 34 +++++++++ .../current/quote/pull/brokers.md | 30 ++++++++ .../current/quote/pull/candlestick.md | 30 ++++++++ .../current/quote/pull/depth.md | 30 ++++++++ .../current/quote/pull/intraday.md | 30 ++++++++ .../current/quote/pull/issuer.md | 34 +++++++++ .../current/quote/pull/option-quote.md | 30 ++++++++ .../quote/pull/optionchain-date-strike.md | 30 ++++++++ .../current/quote/pull/optionchain_date.md | 30 ++++++++ .../current/quote/pull/quote.md | 30 ++++++++ .../current/quote/pull/static.md | 30 ++++++++ .../current/quote/pull/trade-day.md | 30 ++++++++ .../current/quote/pull/trade-session.md | 31 ++++++++ .../current/quote/pull/trade.md | 30 ++++++++ .../current/quote/pull/warrant-filter.md | 31 ++++++++ .../current/quote/pull/warrant-quote.md | 30 ++++++++ .../current/quote/push/broker.md | 48 +++++++++++++ .../current/quote/push/depth.md | 48 +++++++++++++ .../current/quote/push/quote.md | 48 +++++++++++++ .../current/quote/push/trade.md | 48 +++++++++++++ .../current/quote/subscribe/subsciption.md | 72 +++++++++++++++++++ .../current/quote/subscribe/subscribe.md | 48 +++++++++++++ .../current/quote/subscribe/unsubscribe.md | 59 +++++++++++++++ .../current/quote/pull/broker-ids.md | 34 +++++++++ .../current/quote/pull/brokers.md | 30 ++++++++ .../current/quote/pull/candlestick.md | 30 ++++++++ .../current/quote/pull/depth.md | 30 ++++++++ .../current/quote/pull/intraday.md | 30 ++++++++ .../current/quote/pull/issuer.md | 34 +++++++++ .../current/quote/pull/option-quote.md | 30 ++++++++ .../quote/pull/optionchain-date-strike.md | 30 ++++++++ .../current/quote/pull/optionchain_date.md | 30 ++++++++ .../current/quote/pull/quote.md | 30 ++++++++ .../current/quote/pull/static.md | 30 ++++++++ .../current/quote/pull/trade-day.md | 30 ++++++++ .../current/quote/pull/trade-session.md | 31 ++++++++ .../current/quote/pull/trade.md | 30 ++++++++ .../current/quote/pull/warrant-filter.md | 31 ++++++++ .../current/quote/pull/warrant-quote.md | 30 ++++++++ .../current/quote/push/broker.md | 48 +++++++++++++ .../current/quote/push/depth.md | 48 +++++++++++++ .../current/quote/push/quote.md | 48 +++++++++++++ .../current/quote/push/trade.md | 48 +++++++++++++ .../current/quote/subscribe/subsciption.md | 72 +++++++++++++++++++ .../current/quote/subscribe/subscribe.md | 48 +++++++++++++ .../current/quote/subscribe/unsubscribe.md | 59 +++++++++++++++ 69 files changed, 2576 insertions(+), 19 deletions(-) diff --git a/docs/quote/pull/broker-ids.md b/docs/quote/pull/broker-ids.md index cf0e8c040..1b9f5d7d2 100644 --- a/docs/quote/pull/broker-ids.md +++ b/docs/quote/pull/broker-ids.md @@ -14,27 +14,35 @@ sidebar_position: 7 ## Request ### Request Example + ```python +# 获取券商席位 id +# https://open.longbridgeapp.com/docs/quote/pull/broker-ids +import os +import time +from google.protobuf import text_format from longbridge.http import Auth, Config, HttpClient -from longbridge.ws import WsCallback, WsClient -from quote_pb2 import ( - Command, - ParticipantBrokerIdsResponse, -) - -def example(): - auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) - config = Config(base_url="https://openapi.lbkrs.com") - http = HttpClient(auth, config) - ws = WsClient("wss://openapi-quote.longbridge.xyz", http, WsCallback) - result = ws.send_request(Command.QueryParticipantBrokerIds, "") - resp = ParticipantBrokerIdsResponse() - resp.ParseFromString(result) - print(f"{resp}") - - -if __name__ == "__main__": - example() +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, ParticipantBrokerIdsResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +result = ws.send_request(Command.QueryParticipantBrokerIds, "") +resp = ParticipantBrokerIdsResponse() +resp.ParseFromString(result) + +print(f"Broker ids:\n\n") +for broker_number in resp.participant_broker_numbers: + print(f"{text_format.MessageToString(broker_number, as_utf8=True)}") ``` ## Response diff --git a/docs/quote/pull/brokers.md b/docs/quote/pull/brokers.md index e98c3f3d2..a63222195 100644 --- a/docs/quote/pull/brokers.md +++ b/docs/quote/pull/brokers.md @@ -27,6 +27,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# Get Security Brokers +# https://open.longbridgeapp.com/docs/quote/pull/brokers +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, SecurityBrokersResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SecurityRequest(symbol="700.HK") +result = ws.send_request(Command.QueryBrokers, req.SerializeToString()) +resp = SecurityBrokersResponse() +resp.ParseFromString(result) + +print(f"Brokers:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/candlestick.md b/docs/quote/pull/candlestick.md index cf904b9c8..ea38346db 100644 --- a/docs/quote/pull/candlestick.md +++ b/docs/quote/pull/candlestick.md @@ -35,6 +35,36 @@ message SecurityCandlestickRequest { } ``` +### Request Example + +```python +# 获取标的 k 线 +# https://open.longbridgeapp.com/docs/quote/pull/candlestick +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityCandlestickRequest, SecurityCandlestickResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SecurityCandlestickRequest(symbol="700.HK", period=1000, count=10, adjust_type=0) +result = ws.send_request(Command.QueryCandlestick, req.SerializeToString()) +resp = SecurityCandlestickResponse() +resp.ParseFromString(result) + +print(f"Candlesticks:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/depth.md b/docs/quote/pull/depth.md index 553bdee66..4121c7294 100644 --- a/docs/quote/pull/depth.md +++ b/docs/quote/pull/depth.md @@ -29,6 +29,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# 获取标的盘口 +# https://open.longbridgeapp.com/docs/quote/pull/depth +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, SecurityDepthResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SecurityRequest(symbol="700.HK") +result = ws.send_request(Command.QueryDepth, req.SerializeToString()) +resp = SecurityDepthResponse() +resp.ParseFromString(result) + +print(f"Depth:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/intraday.md b/docs/quote/pull/intraday.md index b42481ab1..e6701ae3d 100644 --- a/docs/quote/pull/intraday.md +++ b/docs/quote/pull/intraday.md @@ -29,6 +29,36 @@ message SecurityIntradayRequest { } ``` +### Request Example + +```python +# 获取标的分时 +# https://open.longbridgeapp.com/docs/quote/pull/intraday +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityIntradayRequest, SecurityIntradayResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SecurityIntradayRequest(symbol="700.HK") +result = ws.send_request(Command.QueryIntraday, req.SerializeToString()) +resp = SecurityIntradayResponse() +resp.ParseFromString(result) + +print(f"Intraday:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/issuer.md b/docs/quote/pull/issuer.md index 4254af574..6ae3738ff 100644 --- a/docs/quote/pull/issuer.md +++ b/docs/quote/pull/issuer.md @@ -13,6 +13,40 @@ sidebar_position: 13 ::: +## Request + +### Request Example + +```python +# 获取轮证发行商 id +# https://open.longbridgeapp.com/docs/quote/pull/issuer +import os +import time +from google.protobuf import text_format +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, IssuerInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +result = ws.send_request(Command.QueryWarrantIssuerInfo, "") +resp = IssuerInfoResponse() +resp.ParseFromString(result) + +print(f"issuer info:\n\n") +for issuer in resp.issuer_info: + print(f"{text_format.MessageToString(issuer, as_utf8=True)}") +``` + ## Response ### Parameters diff --git a/docs/quote/pull/option-quote.md b/docs/quote/pull/option-quote.md index 0e31ecc86..1e5c1ed91 100644 --- a/docs/quote/pull/option-quote.md +++ b/docs/quote/pull/option-quote.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 获取期权实时行情 +# https://open.longbridgeapp.com/docs/quote/pull/option-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, OptionQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = MultiSecurityRequest(symbol=["AAPL230317P160000.US"]) +result = ws.send_request(Command.QueryOptionQuote, req.SerializeToString()) +resp = OptionQuoteResponse() +resp.ParseFromString(result) + +print(f"Option quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/optionchain-date-strike.md b/docs/quote/pull/optionchain-date-strike.md index 4022256f3..a3102464e 100644 --- a/docs/quote/pull/optionchain-date-strike.md +++ b/docs/quote/pull/optionchain-date-strike.md @@ -31,6 +31,36 @@ message OptionChainDateStrikeInfoRequest { } ``` +### Request Example + +```python +# 获取标的的期权链到期日期权标的列表 +# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date-strike +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, OptionChainDateStrikeInfoRequest, OptionChainDateStrikeInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = OptionChainDateStrikeInfoRequest(symbol="AAPL.US", expiry_date="20230120") +result = ws.send_request(Command.QueryOptionChainDateStrikeInfo, req.SerializeToString()) +resp = OptionChainDateStrikeInfoResponse() +resp.ParseFromString(result) + +print(f"Option chain info:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/optionchain_date.md b/docs/quote/pull/optionchain_date.md index a1f2c2a8f..0e8c10306 100644 --- a/docs/quote/pull/optionchain_date.md +++ b/docs/quote/pull/optionchain_date.md @@ -29,6 +29,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# 获取标的的期权链到期日列表 +# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, OptionChainDateListResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SecurityRequest(symbol="AAPL.US") +result = ws.send_request(Command.QueryOptionChainDate, req.SerializeToString()) +resp = OptionChainDateListResponse() +resp.ParseFromString(result) + +print(f"Option chain date:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/quote.md b/docs/quote/pull/quote.md index 498a6f4bc..84dd3b81d 100644 --- a/docs/quote/pull/quote.md +++ b/docs/quote/pull/quote.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 获取标的实时行情 +# https://open.longbridgeapp.com/docs/quote/pull/quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, SecurityQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = MultiSecurityRequest(symbol=["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]) +result = ws.send_request(Command.QuerySecurityQuote, req.SerializeToString()) +resp = SecurityQuoteResponse() +resp.ParseFromString(result) + +print(f"Security quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/static.md b/docs/quote/pull/static.md index 6fb614180..f89352060 100644 --- a/docs/quote/pull/static.md +++ b/docs/quote/pull/static.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 获取标的基础信息 +# https://open.longbridgeapp.com/docs/quote/pull/static +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, SecurityStaticInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = MultiSecurityRequest(symbol=["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]) +result = ws.send_request(Command.QuerySecurityStaticInfo, req.SerializeToString()) +resp = SecurityStaticInfoResponse() +resp.ParseFromString(result) + +print(f"Security static info:\n\n {resp.secu_static_info}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/trade-day.md b/docs/quote/pull/trade-day.md index 8cc0cc88e..84bfdb082 100644 --- a/docs/quote/pull/trade-day.md +++ b/docs/quote/pull/trade-day.md @@ -33,6 +33,36 @@ message MarketTradeDayRequest { } ``` +### Request Example + +```python +# 获取市场交易日 +# https://open.longbridgeapp.com/docs/quote/pull/trade-day +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MarketTradeDayRequest, MarketTradeDayResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = MarketTradeDayRequest(market="HK", beg_day="20220120", end_day="20220220") +result = ws.send_request(Command.QueryMarketTradeDay, req.SerializeToString()) +resp = MarketTradeDayResponse() +resp.ParseFromString(result) + +print(f"Trade days:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/trade-session.md b/docs/quote/pull/trade-session.md index 5882a39b4..10f05132c 100644 --- a/docs/quote/pull/trade-session.md +++ b/docs/quote/pull/trade-session.md @@ -13,6 +13,37 @@ sidebar_position: 15 ::: +## Request + +### Request Example + +```python +# 获取各市场当日交易时段 +# https://open.longbridgeapp.com/docs/quote/pull/trade-session +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MarketTradePeriodResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +result = ws.send_request(Command.QueryMarketTradePeriod, "") +resp = MarketTradePeriodResponse() +resp.ParseFromString(result) + +print(f"Market trade session:\n\n {resp.market_trade_session}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/trade.md b/docs/quote/pull/trade.md index b021d9c50..99f867ee8 100644 --- a/docs/quote/pull/trade.md +++ b/docs/quote/pull/trade.md @@ -31,6 +31,36 @@ message SecurityTradeRequest { } ``` +### Request Example + +```python +# 获取标的成交明细 +# https://open.longbridgeapp.com/docs/quote/pull/trade +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityTradeRequest, SecurityTradeResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SecurityTradeRequest(symbol="700.HK", count=10) +result = ws.send_request(Command.QueryTrade, req.SerializeToString()) +resp = SecurityTradeResponse() +resp.ParseFromString(result) + +print(f"Trade:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/warrant-filter.md b/docs/quote/pull/warrant-filter.md index 43bc1e9f8..1bcac5470 100644 --- a/docs/quote/pull/warrant-filter.md +++ b/docs/quote/pull/warrant-filter.md @@ -54,6 +54,37 @@ message FilterConfig { } ``` +### Request Example + +```python +# 获取轮证筛选列表 +# https://open.longbridgeapp.com/docs/quote/pull/warrant-filter +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, FilterConfig, WarrantFilterListRequest, WarrantFilterListResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +filterConfig = FilterConfig(sort_by=0, sort_order=1, sort_offset=0, sort_count=10) +req = WarrantFilterListRequest(symbol="700.HK", filter_config=filterConfig, language=1) +result = ws.send_request(Command.QueryWarrantFilterList, req.SerializeToString()) +resp = WarrantFilterListResponse() +resp.ParseFromString(result) + +print(f"Filtered warrant:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/docs/quote/pull/warrant-quote.md b/docs/quote/pull/warrant-quote.md index f22011b15..e264978de 100644 --- a/docs/quote/pull/warrant-quote.md +++ b/docs/quote/pull/warrant-quote.md @@ -29,6 +29,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 获取轮证实时行情 +# https://open.longbridgeapp.com/docs/quote/pull/warrant-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, WarrantQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = MultiSecurityRequest(symbol=["21125.HK"]) +result = ws.send_request(Command.QueryWarrantQuote, req.SerializeToString()) +resp = WarrantQuoteResponse() +resp.ParseFromString(result) + +print(f"Warrant quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/docs/quote/push/broker.md b/docs/quote/push/broker.md index fb7e5cf61..2e0fa1437 100644 --- a/docs/quote/push/broker.md +++ b/docs/quote/push/broker.md @@ -44,6 +44,54 @@ message Brokers { } ``` +### Example + +```python +# 实时经纪队列推送 +# https://open.longbridgeapp.com/docs/quote/push/push-brokers +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushBrokers, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushBrokersData: + quote = PushBrokers() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SubscribeRequest(symbol=["700.HK"], sub_type=[SubType.BROKERS], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/docs/quote/push/depth.md b/docs/quote/push/depth.md index 6aa13be08..8f6e396e7 100644 --- a/docs/quote/push/depth.md +++ b/docs/quote/push/depth.md @@ -50,6 +50,54 @@ message Depth { } ``` +### Example + +```python +# 实时盘口推送 +# https://open.longbridgeapp.com/docs/quote/push/push-depth +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushDepth, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushDepthData: + quote = PushDepth() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.DEPTH], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/docs/quote/push/quote.md b/docs/quote/push/quote.md index 82787f361..a21c1ab5a 100644 --- a/docs/quote/push/quote.md +++ b/docs/quote/push/quote.md @@ -49,6 +49,54 @@ message PushQuote { } ``` +### Example + +```python +# 实时价格推送 +# https://open.longbridgeapp.com/docs/quote/push/push-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/docs/quote/push/trade.md b/docs/quote/push/trade.md index d1017bee6..e8989dd6c 100644 --- a/docs/quote/push/trade.md +++ b/docs/quote/push/trade.md @@ -48,6 +48,54 @@ message Trade { } ``` +### Example + +```python +# 实时成交明细推送 +# https://open.longbridgeapp.com/docs/quote/push/push-trade +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushTrade, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushTradeData: + quote = PushTrade() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.TRADE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/docs/quote/subscribe/subsciption.md b/docs/quote/subscribe/subsciption.md index a71dde920..d81d6f43d 100644 --- a/docs/quote/subscribe/subsciption.md +++ b/docs/quote/subscribe/subsciption.md @@ -22,6 +22,78 @@ message SubscriptionRequest { } ``` +### Request Example + +```python +# 获取已订阅标的行情 +# https://open.longbridgeapp.com/docs/quote/subscribe/subscription +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType, SubscriptionRequest, UnsubscribeRequest, UnsubscribeResponse) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 + +#订阅标的 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=False) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#取消订阅 +req = UnsubscribeRequest(symbol=["700.HK"], unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#查询已订阅标的 +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#取消订阅 +req = UnsubscribeRequest(unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#查询已订阅标的 +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"Subscribed symbol:\n\n {resp.sub_list}") +``` + ## Response ### Response Properties diff --git a/docs/quote/subscribe/subscribe.md b/docs/quote/subscribe/subscribe.md index db5fbdc9b..5089f4611 100644 --- a/docs/quote/subscribe/subscribe.md +++ b/docs/quote/subscribe/subscribe.md @@ -33,6 +33,54 @@ message SubscribeRequest { } ``` +### Request Example + +```python +# 订阅行情数据 +# https://open.longbridgeapp.com/docs/quote/subscribe/subscribe +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ## Response ### Response Properties diff --git a/docs/quote/subscribe/unsubscribe.md b/docs/quote/subscribe/unsubscribe.md index 976120007..58700e9ad 100644 --- a/docs/quote/subscribe/unsubscribe.md +++ b/docs/quote/subscribe/unsubscribe.md @@ -33,6 +33,65 @@ message SubscribeRequest { } ``` +### Request Example + +```python +# 取消订阅行情数据 +# https://open.longbridgeapp.com/docs/quote/subscribe/unsubscribe +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType, SubscriptionRequest, UnsubscribeRequest, UnsubscribeResponse) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 订阅行情数据请检查 “开发者中心“ - “行情权限” 是否正确 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅 +# - 美股 - LV1 纳斯达克最优报价 (只限 Open API) +# +# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。 +# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。 + +#订阅标的 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=False) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#取消订阅 +req = UnsubscribeRequest(unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#查询已订阅标的 +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"After unsubscribing, subscribed symbol:\n\n {resp.sub_list}") +``` + ## Response ### Protobuf diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md index 15a5a1d29..10ecb16b0 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md @@ -11,6 +11,40 @@ This API is used to obtain participant IDs data (which can be synchronized once [Business Command](../../socket/protocol/request): `16` ::: +## Request + +### Request Example + +```python +# Get Broker IDs +# https://open.longbridgeapp.com/docs/quote/pull/broker-ids +import os +import time +from google.protobuf import text_format +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, ParticipantBrokerIdsResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +result = ws.send_request(Command.QueryParticipantBrokerIds, "") +resp = ParticipantBrokerIdsResponse() +resp.ParseFromString(result) + +print(f"Broker ids:\n\n") +for broker_number in resp.participant_broker_numbers: + print(f"{text_format.MessageToString(broker_number, as_utf8=True)}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/brokers.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/brokers.md index cf888e06d..80ff0a2b2 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/brokers.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/brokers.md @@ -27,6 +27,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# 获取标的经纪队列 +# https://open.longbridgeapp.com/docs/quote/pull/brokers +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, SecurityBrokersResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SecurityRequest(symbol="700.HK") +result = ws.send_request(Command.QueryBrokers, req.SerializeToString()) +resp = SecurityBrokersResponse() +resp.ParseFromString(result) + +print(f"Brokers:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md index 3b25c99a1..a1d6515a3 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md @@ -35,6 +35,36 @@ message SecurityCandlestickRequest { } ``` +### Request Example + +```python +# Get Security Candlesticks +# https://open.longbridgeapp.com/docs/quote/pull/candlestick +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityCandlestickRequest, SecurityCandlestickResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SecurityCandlestickRequest(symbol="700.HK", period=1000, count=10, adjust_type=0) +result = ws.send_request(Command.QueryCandlestick, req.SerializeToString()) +resp = SecurityCandlestickResponse() +resp.ParseFromString(result) + +print(f"Candlesticks:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/depth.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/depth.md index 6fe29ae85..ff68ac88d 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/depth.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/depth.md @@ -29,6 +29,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# Get Security Depth +# https://open.longbridgeapp.com/docs/quote/pull/depth +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, SecurityDepthResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SecurityRequest(symbol="700.HK") +result = ws.send_request(Command.QueryDepth, req.SerializeToString()) +resp = SecurityDepthResponse() +resp.ParseFromString(result) + +print(f"Depth:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/intraday.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/intraday.md index b5435e784..ff328c8fc 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/intraday.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/intraday.md @@ -29,6 +29,36 @@ message SecurityIntradayRequest { } ``` +### Request Example + +```python +# Get Security Intraday +# https://open.longbridgeapp.com/docs/quote/pull/intraday +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityIntradayRequest, SecurityIntradayResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SecurityIntradayRequest(symbol="700.HK") +result = ws.send_request(Command.QueryIntraday, req.SerializeToString()) +resp = SecurityIntradayResponse() +resp.ParseFromString(result) + +print(f"Intraday:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/issuer.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/issuer.md index a8295db69..0d45a2511 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/issuer.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/issuer.md @@ -13,6 +13,40 @@ This API is used to obtain the warrant issuer IDs data (which can be synchronize ::: +## Request + +### Request Example + +```python +# Get Warrant Issuer IDs +# https://open.longbridgeapp.com/docs/quote/pull/issuer +import os +import time +from google.protobuf import text_format +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, IssuerInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +result = ws.send_request(Command.QueryWarrantIssuerInfo, "") +resp = IssuerInfoResponse() +resp.ParseFromString(result) + +print(f"issuer info:\n\n") +for issuer in resp.issuer_info: + print(f"{text_format.MessageToString(issuer, as_utf8=True)}") +``` + ## Response ### Parameters diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md index dffe1a300..e07094d06 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# Get Real-time Quotes Of Option Securities +# https://open.longbridgeapp.com/docs/quote/pull/option-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, OptionQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = MultiSecurityRequest(symbol=["AAPL230317P160000.US"]) +result = ws.send_request(Command.QueryOptionQuote, req.SerializeToString()) +resp = OptionQuoteResponse() +resp.ParseFromString(result) + +print(f"Option quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md index 1222d558b..257a021fd 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md @@ -31,6 +31,36 @@ message OptionChainDateStrikeInfoRequest { } ``` +### Request Example + +```python +# Get Option Chain Info By Date +# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date-strike +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, OptionChainDateStrikeInfoRequest, OptionChainDateStrikeInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = OptionChainDateStrikeInfoRequest(symbol="AAPL.US", expiry_date="20230120") +result = ws.send_request(Command.QueryOptionChainDateStrikeInfo, req.SerializeToString()) +resp = OptionChainDateStrikeInfoResponse() +resp.ParseFromString(result) + +print(f"Option chain info:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md index a42361202..1b9521b81 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md @@ -29,6 +29,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# Get Option Chain Expiry Date List +# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, OptionChainDateListResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SecurityRequest(symbol="AAPL.US") +result = ws.send_request(Command.QueryOptionChainDate, req.SerializeToString()) +resp = OptionChainDateListResponse() +resp.ParseFromString(result) + +print(f"Option chain date:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/quote.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/quote.md index a7ce5cd04..7ee8debbd 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/quote.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/quote.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# Get Real-time Quotes Of Securities +# https://open.longbridgeapp.com/docs/quote/pull/quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, SecurityQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = MultiSecurityRequest(symbol=["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]) +result = ws.send_request(Command.QuerySecurityQuote, req.SerializeToString()) +resp = SecurityQuoteResponse() +resp.ParseFromString(result) + +print(f"Security quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/static.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/static.md index d5255bcc1..72d2c7f0c 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/static.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/static.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# Get Basic Information Of Securities +# https://open.longbridgeapp.com/docs/quote/pull/static +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, SecurityStaticInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = MultiSecurityRequest(symbol=["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]) +result = ws.send_request(Command.QuerySecurityStaticInfo, req.SerializeToString()) +resp = SecurityStaticInfoResponse() +resp.ParseFromString(result) + +print(f"Security static info:\n\n {resp.secu_static_info}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md index d9ed81137..e926bb003 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md @@ -33,6 +33,36 @@ message MarketTradeDayRequest { } ``` +### Request Example + +```python +# Get Market Trading Days +# https://open.longbridgeapp.com/docs/quote/pull/trade-day +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MarketTradeDayRequest, MarketTradeDayResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = MarketTradeDayRequest(market="HK", beg_day="20220120", end_day="20220220") +result = ws.send_request(Command.QueryMarketTradeDay, req.SerializeToString()) +resp = MarketTradeDayResponse() +resp.ParseFromString(result) + +print(f"Trade days:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md index 9f1473b94..19da04caa 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md @@ -13,6 +13,37 @@ This API is used to obtain the daily trading hours of each market. ::: +## Request + +### Request Example + +```python +# Get Trading Session Of The Day +# https://open.longbridgeapp.com/docs/quote/pull/trade-session +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MarketTradePeriodResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +result = ws.send_request(Command.QueryMarketTradePeriod, "") +resp = MarketTradePeriodResponse() +resp.ParseFromString(result) + +print(f"Market trade session:\n\n {resp.market_trade_session}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade.md index 22d0b3493..fdb539c53 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/trade.md @@ -31,6 +31,36 @@ message SecurityTradeRequest { } ``` +### Request Example + +```python +# Get Security Trades +# https://open.longbridgeapp.com/docs/quote/pull/trade +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityTradeRequest, SecurityTradeResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SecurityTradeRequest(symbol="700.HK", count=10) +result = ws.send_request(Command.QueryTrade, req.SerializeToString()) +resp = SecurityTradeResponse() +resp.ParseFromString(result) + +print(f"Trade:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md index 569ffd9c3..7315fcacf 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md @@ -54,6 +54,37 @@ message FilterConfig { } ``` +### Request Example + +```python +# Get Filtered Warrant +# https://open.longbridgeapp.com/docs/quote/pull/warrant-filter +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, FilterConfig, WarrantFilterListRequest, WarrantFilterListResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +filterConfig = FilterConfig(sort_by=0, sort_order=1, sort_offset=0, sort_count=10) +req = WarrantFilterListRequest(symbol="700.HK", filter_config=filterConfig, language=1) +result = ws.send_request(Command.QueryWarrantFilterList, req.SerializeToString()) +resp = WarrantFilterListResponse() +resp.ParseFromString(result) + +print(f"Filtered warrant:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md index 9a70d98b2..18956f937 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md @@ -29,6 +29,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# Get Real-time Quotes Of Warrant Securities +# https://open.longbridgeapp.com/docs/quote/pull/warrant-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, WarrantQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = MultiSecurityRequest(symbol=["21125.HK"]) +result = ws.send_request(Command.QueryWarrantQuote, req.SerializeToString()) +resp = WarrantQuoteResponse() +resp.ParseFromString(result) + +print(f"Warrant quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md index 6a79c7f67..4d3922a1e 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md @@ -44,6 +44,54 @@ message Brokers { } ``` +### Example + +```python +# Push Real-time Brokers +# https://open.longbridgeapp.com/docs/quote/push/push-brokers +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushBrokers, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushBrokersData: + quote = PushBrokers() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SubscribeRequest(symbol=["700.HK"], sub_type=[SubType.BROKERS], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md index 1eb95e85a..16979f692 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md @@ -50,6 +50,54 @@ message Depth { } ``` +### Example + +```python +# Push Real-time Depth +# https://open.longbridgeapp.com/docs/quote/push/push-depth +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushDepth, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushDepthData: + quote = PushDepth() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.DEPTH], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md index 1c744b727..985ac6d69 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md @@ -49,6 +49,54 @@ message PushQuote { } ``` +### Example + +```python +# Push Real-time Quote +# https://open.longbridgeapp.com/docs/quote/push/push-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers" to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md index b1205f064..eb48c4cb7 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md @@ -48,6 +48,54 @@ message Trade { } ``` +### Example + +```python +# Push Real-time Trades +# https://open.longbridgeapp.com/docs/quote/push/push-trade +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushTrade, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushTradeData: + quote = PushTrade() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.TRADE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md index 743f98639..822f03846 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md @@ -22,6 +22,78 @@ message SubscriptionRequest { } ``` +### Request Example + +```python +# Get Subscription Information +# https://open.longbridgeapp.com/docs/quote/subscribe/subscription +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType, SubscriptionRequest, UnsubscribeRequest, UnsubscribeResponse) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. + +#subscribe +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=False) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#unsubscribe +req = UnsubscribeRequest(symbol=["700.HK"], unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#query subscription +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#unsubscribe +req = UnsubscribeRequest(unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#query subscription +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"Subscribed symbol:\n\n {resp.sub_list}") +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md index 9e234925f..24239a43b 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md @@ -33,6 +33,54 @@ message SubscribeRequest { } ``` +### Request Example + +```python +# Subscribe Quote +# https://open.longbridgeapp.com/docs/quote/subscribe/subscribe +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ## Response ### Response Properties diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md index caec795ca..a6d0c7362 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md @@ -33,6 +33,65 @@ message SubscribeRequest { } ``` +### Request Example + +```python +# Unsubscribe Quote +# https://open.longbridgeapp.com/docs/quote/subscribe/unsubscribe +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf variables definition: https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType, SubscriptionRequest, UnsubscribeRequest, UnsubscribeResponse) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# To subscribe quotes data, please check whether "Developers - "Quote authority" is correct. +# https://open.longbridgeapp.com/account +# +# - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. +# - US Market - LV1 Nasdaq Basic (Only Open API). +# +# Before running, please visit the "Developers to ensure that the account has the correct quotes authority. +# If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. + +#subscribe +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=False) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#unsubscribe +req = UnsubscribeRequest(unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#query subscription +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"After unsubscribing, subscribed symbol:\n\n {resp.sub_list}") +``` + ## Response ### Protobuf diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md index 6bec15568..c7ded0908 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/broker-ids.md @@ -11,6 +11,40 @@ sidebar_position: 7 [業務指令](../../socket/protocol/request):`16` ::: +## Request + +### Request Example + +```python +# 獲取券商席位 id +# https://open.longbridgeapp.com/docs/quote/pull/broker-ids +import os +import time +from google.protobuf import text_format +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, ParticipantBrokerIdsResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +result = ws.send_request(Command.QueryParticipantBrokerIds, "") +resp = ParticipantBrokerIdsResponse() +resp.ParseFromString(result) + +print(f"Broker ids:\n\n") +for broker_number in resp.participant_broker_numbers: + print(f"{text_format.MessageToString(broker_number, as_utf8=True)}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/brokers.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/brokers.md index 753770aaf..2ed1ef0ba 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/brokers.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/brokers.md @@ -27,6 +27,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# 獲取標的經紀隊列 +# https://open.longbridgeapp.com/docs/quote/pull/brokers +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, SecurityBrokersResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SecurityRequest(symbol="700.HK") +result = ws.send_request(Command.QueryBrokers, req.SerializeToString()) +resp = SecurityBrokersResponse() +resp.ParseFromString(result) + +print(f"Brokers:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md index 78e5a4eee..b8cca683a 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/candlestick.md @@ -35,6 +35,36 @@ message SecurityCandlestickRequest { } ``` +### Request Example + +```python +# 獲取標的 K 線 +# https://open.longbridgeapp.com/docs/quote/pull/candlestick +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityCandlestickRequest, SecurityCandlestickResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SecurityCandlestickRequest(symbol="700.HK", period=1000, count=10, adjust_type=0) +result = ws.send_request(Command.QueryCandlestick, req.SerializeToString()) +resp = SecurityCandlestickResponse() +resp.ParseFromString(result) + +print(f"Candlesticks:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/depth.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/depth.md index b0a89049b..dc7ae409b 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/depth.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/depth.md @@ -29,6 +29,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# 獲取標的盤口 +# https://open.longbridgeapp.com/docs/quote/pull/depth +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, SecurityDepthResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SecurityRequest(symbol="700.HK") +result = ws.send_request(Command.QueryDepth, req.SerializeToString()) +resp = SecurityDepthResponse() +resp.ParseFromString(result) + +print(f"Depth:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/intraday.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/intraday.md index 2d46de046..4aab09b09 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/intraday.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/intraday.md @@ -29,6 +29,36 @@ message SecurityIntradayRequest { } ``` +### Request Example + +```python +# 獲取標的當日分時 +# https://open.longbridgeapp.com/docs/quote/pull/intraday +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityIntradayRequest, SecurityIntradayResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SecurityIntradayRequest(symbol="700.HK") +result = ws.send_request(Command.QueryIntraday, req.SerializeToString()) +resp = SecurityIntradayResponse() +resp.ParseFromString(result) + +print(f"Intraday:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/issuer.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/issuer.md index 3050fa26b..252cea1e1 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/issuer.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/issuer.md @@ -13,6 +13,40 @@ sidebar_position: 13 ::: +## Request + +### Request Example + +```python +# 獲取輪證發行商 ID +# https://open.longbridgeapp.com/docs/quote/pull/issuer +import os +import time +from google.protobuf import text_format +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, IssuerInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +result = ws.send_request(Command.QueryWarrantIssuerInfo, "") +resp = IssuerInfoResponse() +resp.ParseFromString(result) + +print(f"issuer info:\n\n") +for issuer in resp.issuer_info: + print(f"{text_format.MessageToString(issuer, as_utf8=True)}") +``` + ## Response ### Parameters diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md index 53af3c9c6..d10b80dc8 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/option-quote.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 獲取期權實時行情 +# https://open.longbridgeapp.com/docs/quote/pull/option-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, OptionQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = MultiSecurityRequest(symbol=["AAPL230317P160000.US"]) +result = ws.send_request(Command.QueryOptionQuote, req.SerializeToString()) +resp = OptionQuoteResponse() +resp.ParseFromString(result) + +print(f"Option quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md index b36d137c0..3dabb5d17 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain-date-strike.md @@ -58,6 +58,36 @@ message StrikePriceInfo { } ``` +### Request Example + +```python +# 獲取標的的期權鏈到期日期權標的列表 +# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date-strike +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, OptionChainDateStrikeInfoRequest, OptionChainDateStrikeInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = OptionChainDateStrikeInfoRequest(symbol="AAPL.US", expiry_date="20230120") +result = ws.send_request(Command.QueryOptionChainDateStrikeInfo, req.SerializeToString()) +resp = OptionChainDateStrikeInfoResponse() +resp.ParseFromString(result) + +print(f"Option chain info:\n\n {resp}") +``` + ### Response JSON Example ```json diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md index 970be0cbc..b619186d8 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/optionchain_date.md @@ -29,6 +29,36 @@ message SecurityRequest { } ``` +### Request Example + +```python +# 獲取標的的期權鏈到期日列表 +# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityRequest, OptionChainDateListResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SecurityRequest(symbol="AAPL.US") +result = ws.send_request(Command.QueryOptionChainDate, req.SerializeToString()) +resp = OptionChainDateListResponse() +resp.ParseFromString(result) + +print(f"Option chain date:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md index 77c77d35d..aebf6b76c 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/quote.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 獲取標的實時行情 +# https://open.longbridgeapp.com/docs/quote/pull/quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, SecurityQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = MultiSecurityRequest(symbol=["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]) +result = ws.send_request(Command.QuerySecurityQuote, req.SerializeToString()) +resp = SecurityQuoteResponse() +resp.ParseFromString(result) + +print(f"Security quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/static.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/static.md index 7338a1ff5..2090162d9 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/static.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/static.md @@ -27,6 +27,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 獲取標的基礎信息 +# https://open.longbridgeapp.com/docs/quote/pull/static +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, SecurityStaticInfoResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = MultiSecurityRequest(symbol=["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"]) +result = ws.send_request(Command.QuerySecurityStaticInfo, req.SerializeToString()) +resp = SecurityStaticInfoResponse() +resp.ParseFromString(result) + +print(f"Security static info:\n\n {resp.secu_static_info}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md index 49d20c694..7e2994a91 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-day.md @@ -33,6 +33,36 @@ message MarketTradeDayRequest { } ``` +### Request Example + +```python +# 獲取市場交易日 +# https://open.longbridgeapp.com/docs/quote/pull/trade-day +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MarketTradeDayRequest, MarketTradeDayResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = MarketTradeDayRequest(market="HK", beg_day="20220120", end_day="20220220") +result = ws.send_request(Command.QueryMarketTradeDay, req.SerializeToString()) +resp = MarketTradeDayResponse() +resp.ParseFromString(result) + +print(f"Trade days:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md index a5cf76cdc..f790efd52 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade-session.md @@ -13,6 +13,37 @@ sidebar_position: 15 ::: +## Request + +### Request Example + +```python +# 獲取各市場當日交易時段 +# https://open.longbridgeapp.com/docs/quote/pull/trade-session +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MarketTradePeriodResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +result = ws.send_request(Command.QueryMarketTradePeriod, "") +resp = MarketTradePeriodResponse() +resp.ParseFromString(result) + +print(f"Market trade session:\n\n {resp.market_trade_session}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade.md index b569620b8..cc7981b84 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/trade.md @@ -31,6 +31,36 @@ message SecurityTradeRequest { } ``` +### Request Example + +```python +# 獲取標的成交明細 +# https://open.longbridgeapp.com/docs/quote/pull/trade +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, SecurityTradeRequest, SecurityTradeResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SecurityTradeRequest(symbol="700.HK", count=10) +result = ws.send_request(Command.QueryTrade, req.SerializeToString()) +resp = SecurityTradeResponse() +resp.ParseFromString(result) + +print(f"Trade:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md index c9f879a6b..d2a54071a 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-filter.md @@ -54,6 +54,37 @@ message FilterConfig { } ``` +### Request Example + +```python +# 獲取輪證篩選列表 +# https://open.longbridgeapp.com/docs/quote/pull/warrant-filter +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, FilterConfig, WarrantFilterListRequest, WarrantFilterListResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +filterConfig = FilterConfig(sort_by=0, sort_order=1, sort_offset=0, sort_count=10) +req = WarrantFilterListRequest(symbol="700.HK", filter_config=filterConfig, language=1) +result = ws.send_request(Command.QueryWarrantFilterList, req.SerializeToString()) +resp = WarrantFilterListResponse() +resp.ParseFromString(result) + +print(f"Filtered warrant:\n\n {resp}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md index 37a6cf61f..938782f74 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/pull/warrant-quote.md @@ -29,6 +29,36 @@ message MultiSecurityRequest { } ``` +### Request Example + +```python +# 獲取輪證實時行情 +# https://open.longbridgeapp.com/docs/quote/pull/warrant-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, MultiSecurityRequest, WarrantQuoteResponse) + +class MyWsCallback(WsCallback): + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = MultiSecurityRequest(symbol=["21125.HK"]) +result = ws.send_request(Command.QueryWarrantQuote, req.SerializeToString()) +resp = WarrantQuoteResponse() +resp.ParseFromString(result) + +print(f"Warrant quote:\n\n {resp.secu_quote}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/broker.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/broker.md index 2fe449f88..e608a23de 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/broker.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/broker.md @@ -44,6 +44,54 @@ message Brokers { } ``` +### Example + +```python +# 實時經紀隊列推送 +# https://open.longbridgeapp.com/docs/quote/push/push-brokers +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushBrokers, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushBrokersData: + quote = PushBrokers() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SubscribeRequest(symbol=["700.HK"], sub_type=[SubType.BROKERS], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/depth.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/depth.md index 27cf11cce..6da9f6527 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/depth.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/depth.md @@ -50,6 +50,54 @@ message Depth { } ``` +### Example + +```python +# 實時盤口推送 +# https://open.longbridgeapp.com/docs/quote/push/push-depth +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushDepth, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushDepthData: + quote = PushDepth() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.DEPTH], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/quote.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/quote.md index 339d3cbb7..be25b9acb 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/quote.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/quote.md @@ -49,6 +49,54 @@ message PushQuote { } ``` +### Example + +```python +# 實時價格推送 +# https://open.longbridgeapp.com/docs/quote/push/push-quote +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/trade.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/trade.md index b97bc3077..353950f51 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/trade.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/push/trade.md @@ -48,6 +48,54 @@ message Trade { } ``` +### Example + +```python +# 實時成交明細推送 +# https://open.longbridgeapp.com/docs/quote/push/push-trade +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushTrade, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushTradeData: + quote = PushTrade() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.TRADE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ### JSON Example ```json diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md index d651830f3..5f0d61f7b 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md @@ -22,6 +22,78 @@ message SubscriptionRequest { } ``` +### Request Example + +```python +# 獲取已訂閱標的行情 +# https://open.longbridgeapp.com/docs/quote/subscribe/subscription +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType, SubscriptionRequest, UnsubscribeRequest, UnsubscribeResponse) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 + +#訂閱標的 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=False) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#取消訂閱 +req = UnsubscribeRequest(symbol=["700.HK"], unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#查詢已訂閱標的 +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#取消訂閱 +req = UnsubscribeRequest(unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#查詢已訂閱標的 +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"Subscribed symbol:\n\n {resp.sub_list}") +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md index 8e5f20245..57883a812 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md @@ -33,6 +33,54 @@ message SubscribeRequest { } ``` +### Request Example + +```python +# 訂閱行情數據 +# https://open.longbridgeapp.com/docs/quote/subscribe/subscribe +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=True) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +print("\n\nWaiting for push...\nPress [Ctrl + c] to quit.") +while True: + time.sleep(10) +``` + ## Response ### Response Properties diff --git a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md index 7826fbaac..c8ab1b898 100644 --- a/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md +++ b/i18n/zh-HK/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md @@ -33,6 +33,65 @@ message SubscribeRequest { } ``` +### Request Example + +```python +# 取消訂閱行情數據 +# https://open.longbridgeapp.com/docs/quote/subscribe/unsubscribe +import os +import time +from longbridge.http import Auth, Config, HttpClient +from longbridge.ws import ReadyState, WsCallback, WsClient +# Protobuf 變量定義參見:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto +from longbridge.proto.quote_pb2 import (Command, PushQuote, SubscribeRequest, SubscriptionResponse, SubType, SubscriptionRequest, UnsubscribeRequest, UnsubscribeResponse) + +class MyWsCallback(WsCallback): + def on_push(self, command: int, body: bytes): + if command == Command.PushQuoteData: + quote = PushQuote() + quote.ParseFromString(body) + print(f"quote-> {quote}") + else: + print(f"-> unknow: {command}") + + def on_state(self, state: ReadyState): + print(f"-> state: {state}") + +auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN")) +http = HttpClient(auth, Config(base_url="https://openapi.lbkrs.com")) +ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) + +# 訂閱行情數據請檢查 “開發者中心“ - “行情權限” 是否正確 +# https://open.longbridgeapp.com/account +# +# - 港股 - BMP 基礎報價,無實時行情推送,無法用 WebSocket 訂閱 +# - 美股 - LV1 納斯達克最優報價 (只限 Open API) +# +# 運行前請訪問 “開發者中心“ 確保賬戶有正確的行情權限。 +# 如沒有開通行情權限,可以通過 "長橋" 手機客戶端,並進入 “我的 - 我的行情 - 行情商城“ 購買開通行情權限。 + +#訂閱標的 +req = SubscribeRequest(symbol=["700.HK", "AAPL.US"], sub_type=[SubType.QUOTE], is_first_push=False) +result = ws.send_request(Command.Subscribe, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print(f"Subscribed symbol:\n\n {resp.sub_list}") + +#取消訂閱 +req = UnsubscribeRequest(unsub_all=True) +result = ws.send_request(Command.Unsubscribe, req.SerializeToString()) + +#查詢已訂閱標的 +req = SubscriptionRequest() +result = ws.send_request(Command.Subscription, req.SerializeToString()) +resp = SubscriptionResponse() +resp.ParseFromString(result) + +print("\n") +print(f"After unsubscribing, subscribed symbol:\n\n {resp.sub_list}") +``` + ## Response ### Protobuf From 0b6fe9f852f69ebd6e25998d3a660d3975517a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E8=BD=A9=E4=BC=9F?= Date: Mon, 9 May 2022 18:24:57 +0800 Subject: [PATCH 3/3] auto correct --- .../docusaurus-plugin-content-docs/current/quote/push/broker.md | 2 +- .../docusaurus-plugin-content-docs/current/quote/push/depth.md | 2 +- .../docusaurus-plugin-content-docs/current/quote/push/quote.md | 2 +- .../docusaurus-plugin-content-docs/current/quote/push/trade.md | 2 +- .../current/quote/subscribe/subsciption.md | 2 +- .../current/quote/subscribe/subscribe.md | 2 +- .../current/quote/subscribe/unsubscribe.md | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md index 4d3922a1e..23d05345a 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/broker.md @@ -76,7 +76,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md index 16979f692..820dd00da 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/depth.md @@ -82,7 +82,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md index 985ac6d69..5280e089e 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/quote.md @@ -81,7 +81,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers" to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md index eb48c4cb7..37510479f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/push/trade.md @@ -80,7 +80,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md index 822f03846..a199c2b77 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subsciption.md @@ -54,7 +54,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md index 24239a43b..4f23cc678 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/subscribe.md @@ -65,7 +65,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md index a6d0c7362..41307dad3 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/quote/subscribe/unsubscribe.md @@ -65,7 +65,7 @@ ws = WsClient("wss://openapi-quote.longbridge.global", http, MyWsCallback()) # https://open.longbridgeapp.com/account # # - HK Market - BMP basic quotation is unable to subscribe with WebSocket as it has no real-time quote push. -# - US Market - LV1 Nasdaq Basic (Only Open API). +# - US Market - LV1 NASDAQ Basic (Only Open API). # # Before running, please visit the "Developers to ensure that the account has the correct quotes authority. # If you do not have the quotes authority, you can enter "Me - My Quotes - Store" to purchase the authority through the "Longbridge" mobile client.