A Python library for Longbridge Open API
Project description
Longbridge OpenAPI SDK for Python
longbridge
provides an easy-to-use interface for invokes Longbridge OpenAPI
.
Quickstart
Install Longbridge OpenAPI SDK
pip install longbridge
Setting environment variables(MacOS/Linux)
export LONGBRIDGE_APP_KEY="App Key get from user center"
export LONGBRIDGE_APP_SECRET="App Secret get from user center"
export LONGBRIDGE_ACCESS_TOKEN="Access Token get from user center"
Setting environment variables(Windows)
setx LONGBRIDGE_APP_KEY "App Key get from user center"
setx LONGBRIDGE_APP_SECRET "App Secret get from user center"
setx LONGBRIDGE_ACCESS_TOKEN "Access Token get from user center"
Quote API (Get basic information of securities)
from longbridge.openapi import Config, QuoteContext
# Load configuration from environment variables
config = Config.from_env()
# Create a context for quote APIs
ctx = QuoteContext(config)
# Get basic information of securities
resp = ctx.quote(["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"])
print(resp)
Quote API (Subscribe quotes)
from time import sleep
from longbridge.openapi import Config, QuoteContext, SubType, PushQuote
# Load configuration from environment variables
config = Config.from_env()
# A callback to receive quote data
def on_quote(self, symbol: str, event: PushQuote):
print(symbol, event)
# Create a context for quote APIs
ctx = QuoteContext(config)
ctx.set_on_quote(on_quote)
# Subscribe
resp = ctx.subscribe(["700.HK"], [SubType.Quote], is_first_push=True)
# Receive push duration to 30 seconds
sleep(30)
Trade API (Submit order)
from decimal import Decimal
from longbridge.openapi import TradeContext, Config, OrderType, OrderSide, TimeInForceType
# Load configuration from environment variables
config = Config.from_env()
# Create a context for trade APIs
ctx = TradeContext(config)
# Submit order
resp = ctx.submit_order("700.HK", OrderType.LO, OrderSide.Buy, Decimal(
"500"), TimeInForceType.Day, submitted_price=Decimal("50"), remark="Hello from Python SDK")
print(resp)
License
Licensed under either of
- Apache License, Version 2.0,(LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
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 Distribution
longbridge-0.2.53.tar.gz
(320.1 kB
view hashes)
Built Distributions
Close
Hashes for longbridge-0.2.53-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f97dfaac58e6d9294620c1e5e3314d14530e60083a3e3898b9409eaa25754f79 |
|
MD5 | e9382103a01a1c7dff5900c362ad2990 |
|
BLAKE2b-256 | d9fb2999e2777433c4f2e64cc16b54fc9d04a287d2a4c4ffd0c3b0ab9abfe727 |
Close
Hashes for longbridge-0.2.53-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b78e87ade4c5c3bad1e51df34e18f99aed57b7469fce88508a4f919d496a593d |
|
MD5 | 6ccfe73279c05083c5c7bb893af7f9b4 |
|
BLAKE2b-256 | a4478e850423ea2f748bd9ca6be325113f2e2fb02fca99f8a20bc83f3fb75250 |
Close
Hashes for longbridge-0.2.53-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00f57b6dafa18e9bed9cf7bf4ef42b1d2030a4dbb4fcdb11356391daa5529ac6 |
|
MD5 | 44084230820be738208e0b3a34540686 |
|
BLAKE2b-256 | 2e9d8dfefb9791c37f326561a5ae1939b86b64ed83677974f954eab563dffc1c |
Close
Hashes for longbridge-0.2.53-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c38ed645948ac2a55f5ff1917cbeca7b5ed53c25879ba5709bb0c9cf9d0fc19b |
|
MD5 | 1115dcfb34a0fb6a32761cb1ec3b0c24 |
|
BLAKE2b-256 | ba3ad4b810378d4819ad95e3108ccfc787158d4ddc971d190c8bac1b2b7a083d |
Close
Hashes for longbridge-0.2.53-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a344bd3316d51fdb51c7296c98d47cbdcb7e3a376dd2bfed8ad6a449b44519 |
|
MD5 | e6971958b974f22f5098da1c556b896f |
|
BLAKE2b-256 | ede6e584eba9c00be8c4dc9857c07712e765c0590572dd2a4eea1e6a42d88b54 |
Close
Hashes for longbridge-0.2.53-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 972815d993ae2eb5abca58d36b3c5120f169144dd7ccf733073c267c5ced51b5 |
|
MD5 | 95c9082862ac4418761fbe67f19aa862 |
|
BLAKE2b-256 | e3287a4a3d2522a376008a6d29dc0afc3691950b112d668a7f0f844471c7ad38 |
Close
Hashes for longbridge-0.2.53-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d85202eb663fcc025d5a499968b5cc668a6bc8d13b2f8edae5694d36be30ebef |
|
MD5 | 582572b6dfc380bae98560ffdab47ab5 |
|
BLAKE2b-256 | da367091d2c7d697108c5be834391533bcb2274ac281f149a7586f114ac20ab8 |
Close
Hashes for longbridge-0.2.53-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d1c08eb251ab5284a35ab4297635ec88bdc44e5d1eb5a835d7049f6067c009a |
|
MD5 | fe443e5a58a773ddc9a36f4591ceb910 |
|
BLAKE2b-256 | 2e0e9d90c5602eb1754660ffb022b8be3b547494af4479eba242eb3943ee3223 |
Close
Hashes for longbridge-0.2.53-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8055cec7d186dd41b3df62dc01d2628bae1d0e52a8afc71abd091223b69df04 |
|
MD5 | c64558fc661b8251c0f969caea1aeb0f |
|
BLAKE2b-256 | ca004eb398871b01174eddb642bf3390c371c3e4792791e06cfed4fa0e24e5dd |
Close
Hashes for longbridge-0.2.53-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f43b8f078d4afe522e8bca83c3bf5dadce8cd42a2cbb1668075c31254a53f9aa |
|
MD5 | 72c68cca17d71c2f985776780b5d623d |
|
BLAKE2b-256 | d0b0c625a1478680fc0dcf448dea20ccb14faeb48d4f857d5749744255e0a6c6 |
Close
Hashes for longbridge-0.2.53-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda3902f8461006a39cc4b892ea47dfcbb1f0d29519d6eab82c35f19d6265cbf |
|
MD5 | 87fe2fe489137439e0b302bec691ff2b |
|
BLAKE2b-256 | 7fa472fe5304782aec33752050e883154a17de312856ec531c3e8b091dd2564e |
Close
Hashes for longbridge-0.2.53-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cf4af279acbfdcc52320fe1d6e60c2547972c510e3794f6d820e9d5286d8f2d |
|
MD5 | 7eedadcd5b16d74f68f7c07f9e229cdf |
|
BLAKE2b-256 | 4cfb17b3c419dced64676d5e0e4bf01db994406ae3ea2891d7f00b04e69eec7c |
Close
Hashes for longbridge-0.2.53-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d8d4c368b3b5186977ffcd3e6d246e13fc5ad063bae0ea095d27d1f631c425e |
|
MD5 | 905ad493415437711cc9b636e55bc3b3 |
|
BLAKE2b-256 | cf55cbe0362108a824006658da1216de83508598d53ad1b16b0767fa3f43e08b |
Close
Hashes for longbridge-0.2.53-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f93da7ca5347b8cf62bdb7f6454f270124acf9f8274dfb7d8c74bc0c3ae9efe1 |
|
MD5 | 223b05f230bcf79974b89bd106f55bfb |
|
BLAKE2b-256 | 4da4c76c14d1e3525afc70217b039c82ae785c64316d136ed5896fb6406fcde9 |
Close
Hashes for longbridge-0.2.53-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76341fc104113141a0362e6d6c254ec98c0d126a6529a2c013047bfbfe9545e6 |
|
MD5 | 839ac0a8dc3953e23e86499728544e05 |
|
BLAKE2b-256 | cac22d12e9221c466dffc2dd8713abe9964553f9c4773071f793deff78ee1aae |
Close
Hashes for longbridge-0.2.53-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 147b88cb44da8e79d5fb9c84094d9532b56d8f23dd78803050dba6cebc15bad3 |
|
MD5 | 05e0d44647320b465b82d62a96d28cd7 |
|
BLAKE2b-256 | 603f31231b14485ed8df1c1b472c1a0091958e2dca8c752b853f947e6fa39f4b |
Close
Hashes for longbridge-0.2.53-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce14151ce0678722cabcbef87d9938d49030aee6f39a5506acdc6cbb0981183f |
|
MD5 | 6e5acc1d3cf04826a0631747d1ac48cc |
|
BLAKE2b-256 | 4cd88c337a771bfaa26db622b55a5e7d5871572fa72eb4ad95b276818bf94ab8 |
Close
Hashes for longbridge-0.2.53-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebf945969e2b1ee451c756eb63942c91a18a4024e658c00f723ef8adf4318763 |
|
MD5 | fb0e95387cb8c83b53b86e83c4edfe08 |
|
BLAKE2b-256 | 0a3aad1213cad7fe3285e7b2b363cafaff9820d53a9251775f6f101d46cce38d |
Close
Hashes for longbridge-0.2.53-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2dfebb219944a974ca2a7d62bef2767ff8faf2e3b515b275a1beed3f36064b1 |
|
MD5 | cd13f01406da9c8bc0b359173715d8a6 |
|
BLAKE2b-256 | 318683d6d7759b50c50824530136650d0482c33a2f157a1fd7a9c1f1d02bbffe |
Close
Hashes for longbridge-0.2.53-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dee1c26f7cd5313eebfa6eb6c6528f98f7d8c220c791e428f02877d37273bb8 |
|
MD5 | 55a5851177e5a6c894c2d1bc5e6ee453 |
|
BLAKE2b-256 | aa411622b9756a24f229978b48a3af35f70cb61831a7f3cbe19be9c53ba590f8 |
Close
Hashes for longbridge-0.2.53-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4acf2b640dd4cd55055ab9b8d7459a248518d2ddf6a74e7da225fc09114e5a58 |
|
MD5 | da3971853dd0819093047b4af9172abe |
|
BLAKE2b-256 | a4ab767d39f66a6072d8cf20208c42efec98f7dddf8215e1f080c766fe40f60e |
Close
Hashes for longbridge-0.2.53-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5391a89cab99e526a690b516798562fd1e65695666ebd3e5bcc97267d10a36eb |
|
MD5 | 0ea7b0695b009545eeb21cd52c81480e |
|
BLAKE2b-256 | 7df005dd6f9290759a0f1b2a22d972f35d088d947dbdc452e43d38e15a9562d7 |
Close
Hashes for longbridge-0.2.53-cp37-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0884ce02996d259d8c2e0ae8e2e0062c8d245c8a2161b5f2818dc3633c9d7f5 |
|
MD5 | 052af1f4be74b45101cbaf5b1c2f5b26 |
|
BLAKE2b-256 | 0693442cbb5d82a75fe0b2f1d90916190edd7566221a5f0795fc47b62770d2dd |
Close
Hashes for longbridge-0.2.53-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 859ba34b01c95863862307568155c86abb02026b747b9d90ebcc2ecf66cfdf39 |
|
MD5 | a7c53cf21974958e4b7b793709a91954 |
|
BLAKE2b-256 | a19dbb928b406190427d618d341dff30b35a0603e333ce10f481a698e6fe8c3e |
Close
Hashes for longbridge-0.2.53-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 636b9ce6c8fe1d0ec44c823e25703932a96fa024c051ebff159e60200bc0ef2d |
|
MD5 | f1a77c100c14d9037cb69188400244e8 |
|
BLAKE2b-256 | aa0b11667081e17fca53c538ce6b83add8edf0eb981c85d748bc9b88a0e73ea2 |
Close
Hashes for longbridge-0.2.53-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb295f3b1b337a8a8baabc4ccde4e8fb80bc460f80ee749eee08d683b6b113b9 |
|
MD5 | ed5ed87a0ff73e5565d7da4b58c768dc |
|
BLAKE2b-256 | fedd973c0978954d0b1da5e08bbe5c1adfc6e95cc584fa99fc8e2de80b0d7bb7 |
Close
Hashes for longbridge-0.2.53-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0187c4b3a61b2d295ea62bdd25dc6649f205e7c331e1bb372452fa5cdd60dfe4 |
|
MD5 | 0f31407237efba3739c2773dd5043833 |
|
BLAKE2b-256 | 6d90c834ffc0cabf25d24e724663cf3d1ed3eec4d4ed40ce46abece0acd96014 |