Skip to main content

A Python library for Longbridge Open API

Project description

Welcome to longbridge's documentation!

Supported Versions Read the Docs

Longbridge OpenSDK 提供了 Http/Ws Clients,方便地使用 Longbridge OpenAPI。

示例

  1. https://github.com/longbridgeapp/openapi-protobufs 下载 quote.proto 文件

  2. 编译 quote.proto: protoc --python_out=. quote.proto

  3. 项目安装依赖:pip install longbridge protobuf

  4. 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

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page