Rust SDK
老虎证券 OpenAPI Rust SDK,提供行情查询、交易下单、账户管理和实时推送等功能。
- 要求 Rust 1.70 或更高版本
- 源码仓库:openapi-rust-sdk
- Crates.io:tigeropen
安装
在 Cargo.toml 中添加依赖:
[dependencies]
tigeropen = "0.1.0"
tokio = { version = "1", features = ["full"] }要求 Rust 1.70 或更高版本。
配置
SDK 支持三种配置方式,优先级:环境变量 > Builder 设置(含配置文件) > 默认值。
方式一:从 properties 配置文件加载
use tigeropen::config::ClientConfig;
let config = ClientConfig::builder()
.properties_file("tiger_openapi_config.properties")
.build()?;配置文件格式:
tiger_id=你的开发者ID
private_key=你的RSA私钥
account=你的交易账户方式二:Builder 模式
use tigeropen::config::ClientConfig;
let config = ClientConfig::builder()
.tiger_id("你的 tiger_id")
.private_key("你的 RSA 私钥")
.account("你的交易账户")
.build()?;方式三:环境变量
export TIGEROPEN_TIGER_ID=你的开发者ID
export TIGEROPEN_PRIVATE_KEY=你的RSA私钥
export TIGEROPEN_ACCOUNT=你的交易账户配置项说明
| 配置项 | 说明 | 必填 | 默认值 |
|---|---|---|---|
| tiger_id | 开发者 ID | 是 | - |
| private_key | RSA 私钥 | 是 | - |
| account | 交易账户 | 否 | - |
| language | 语言(ZhCn/EnUs) | 否 | ZhCn |
| timeout | 请求超时 | 否 | 15s |
Updated about 21 hours ago
