A Python library for Longbridge Open API
Project description
Welcome to longbridge's documentation!
Longbridge OpenSDK 提供了 Http/Ws Clients,方便地使用 Longbridge OpenAPI。
示例
-
从 https://github.com/longbridgeapp/openapi-protobufs 下载 quote.proto 文件
-
编译 quote.proto:
protoc --python_out=. quote.proto
-
项目安装依赖:
pip install longbridge protobuf
-
Happy Coding:
from longbridge.http import Auth, Config, HttpClient
from longbridge.ws import ReadyState, WsCallback, WsClient
from quote_pb2 import Command, SubscribeRequest, SubType
auth = Auth("{app_key}", "{app_secret}", access_token=None)
config = Config(base_url="https://openapi.lbkrs.com")
http = HttpClient(auth, config)
response = http.get("/v1/test")
class MyWsCallback(WsCallback):
def on_push(self, command: int, body: bytes):
print(f"received push message: {command} {body}")
def on_state(self, state: ReadyState):
print(f"received state change: {state}")
ws = WsClient("wss://openapi-quote.lbkrs.com", MyWsCallback())
resp = ws.send_request(
Command.Subscribe,
SubscribeRequest(
symbol=["00700.HK"], sub_type=[SubType.QUOTE, SubType.DEPTH], is_first_push=True
),
)
We Love Rust
Longbridge OpenSDK 基于 Rust 提供标准实现,通过 FFI 提供给 Python 使用。
目前,我们支持如下系统架构:
- Windows x86
- Windows x86_64
- Linux x86_64
- Linux arm64
- Mac x86_64 & arm64
如有其他需求,请提 issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for longbridge-0.0.1-py3-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4150c1c2d9456bc91a0c4eca312633844a0c2251d75bf84c0593327989ff8dd9 |
|
MD5 | 385c633377d80c0c29202923bffeac69 |
|
BLAKE2b-256 | 8d746aa8b10f0e044d0b4cf21a5e8ddfd0bd5c73264e91fa32681a90c4e29612 |