Quick Start

Installation

[dependencies]
tigeropen = "0.5.7"
tokio = { version = "1", features = ["full"] }

The SDK requires Rust 1.70+. tiger_id and the RSA private_key are required; trade APIs also require account. A TBHK license requires a token. High-risk institutional operations require secret_key.

Configuration

Precedence is environment variables, builder values, an auto-discovered properties file, then SDK defaults. Auto-discovery checks ./tiger_openapi_config.properties, then ~/.tigeropen/tiger_openapi_config.properties.

tiger_id=YOUR_TIGER_ID
private_key=YOUR_RSA_PRIVATE_KEY
account=YOUR_ACCOUNT
license=TBUS

Environment variables are TIGEROPEN_TIGER_ID, TIGEROPEN_PRIVATE_KEY, TIGEROPEN_ACCOUNT, TIGEROPEN_TOKEN, and TIGEROPEN_TOKEN_FILE. The request timeout defaults to 15 seconds; dynamic domain resolution is enabled by default.

QuoteClient::from_config

pub fn from_config(config: ClientConfig) -> QuoteClient

Constructs a client using the quote server. Market-data permissions still apply.

TradeClient::from_config

pub fn from_config(config: ClientConfig) -> TradeClient

Uses config.account and constructs the trade client. Account type controls order, funding, and exercise permissions.

Example

use tigeropen::config::ClientConfig;
use tigeropen::model::quote_requests::KlineRequest;
use tigeropen::quote::QuoteClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::builder().build()?;
    let quote = QuoteClient::from_config(config);
    let states = quote.get_market_state("US").await?;
    let bars = quote.get_kline(KlineRequest {
        symbols: Some(vec!["AAPL".into()]),
        period: Some("day".into()),
        limit: Some(10),
        ..Default::default()
    }).await?;
    println!("states={}, series={}", states.len(), bars.len());
    Ok(())
}
[{"market":"US","marketStatus":"Trading","status":"TRADING","openTime":"09:30"}]

Source: ClientConfig, QuoteClient, and TradeClient.


Did this page help you?