LongPort OpenAPI SDK for Rust
longport provides an easy-to-use interface for invoking LongPort OpenAPI.
Documentation
- SDK docs: https://longportapp.github.io/openapi/rust/longport/index.html
- crates.io: https://crates.io/crates/longport
- LongPort OpenAPI: https://open.longportapp.com/en/
Examples
Runnable examples live in examples/rust/:
examples/rust/account_asset/src/main.rsexamples/rust/http_client/src/main.rsexamples/rust/subscribe_quote/src/main.rsexamples/rust/subscribe_candlesticks/src/main.rsexamples/rust/submit_order/src/main.rsexamples/rust/today_orders/src/main.rs
Quickstart
Add dependencies to Cargo.toml
[]
= "1.0.0"
Setting environment variables(MacOS/Linux)
Setting environment variables(Windows)
setx LONGPORT_APP_KEY "App Key get from user center"
setx LONGPORT_APP_SECRET "App Secret get from user center"
setx LONGPORT_ACCESS_TOKEN "Access Token get from user center"
Quote API (Get basic information of securities)
use Arc;
use ;
async
Quote API (Subscribe quotes)
use Arc;
use ;
async
Trade API (Submit order)
use Arc;
use ;
async
Troubleshooting
- Windows
setxrequires a new terminal; usesetfor the currentcmd.exesession. - If you don't see push events, keep the process alive (receiver loop /
sleep). - For debugging, set
LONGPORT_LOG_PATHto enable SDK logs.
Crate features
To avoid compiling unused dependencies, longport gates certain features, all of which are disabled by default:
| Feature | Description |
|---|---|
| blocking | Provides the blocking client API. |
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.