账户与持仓
获取管理的账户
签名
pub async fn get_managed_accounts( &self, req: ManagedAccountsRequest, ) -> Result<Vec<ManagedAccount>, TigerError>
说明
机构主账户;account 默认注入。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Vec<ManagedAccount>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| account | String | 账户 |
| account_type | String | 账户类型 |
| capability | String | 账户能力 |
| status | String | 账户状态 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_managed_accounts(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_managed_accounts(ManagedAccountsRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
[
{
"account": "402901",
"accountType": "GLOBAL",
"capability": "RegTMargin",
"status": "TRADING"
}
]请求频率
基础限流为 60 次/分钟。
获取环球账户资产
签名
pub async fn get_assets(&self, req: AssetsRequest) -> Result<Vec<Asset>, TigerError>
说明
account 默认注入;segment、market_value 默认不发送。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.sub_accounts | Option<Vec<String>> | 可选 | None(不序列化) |
| req.segment | Option<bool> | 可选 | None(不序列化) |
| req.market_value | Option<bool> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Vec<Asset>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| account | String | 账户 |
| capability | String | 账户能力 |
| currency | String | 币种 |
| buying_power | f64 | 购买力 |
| cash_value | f64 | 现金价值 |
| net_liquidation | f64 | 净清算价值 |
| realized_pnl | f64 | 已实现盈亏 |
| unrealized_pnl | f64 | 未实现盈亏 |
| segments | Vec<AssetSegment> | 资产分段 |
AssetSegment 字段:
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| account | String | 账户 |
| category | String | 分段类别 |
| title | String | 分段标题 |
| net_liquidation | f64 | 净清算价值 |
| cash_value | f64 | 现金价值 |
| available_funds | f64 | 可用资金 |
| equity_with_loan | f64 | 含借贷权益 |
| excess_liquidity | f64 | 超额流动性 |
| accrued_cash | f64 | 应计现金 |
| accrued_dividend | f64 | 应计股息 |
| init_margin_req | f64 | 初始保证金要求 |
| maint_margin_req | f64 | 维持保证金要求 |
| gross_position_value | f64 | 持仓总市值 |
| leverage | f64 | 杠杆 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_assets(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_assets(AssetsRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
[
{
"account": "402901",
"capability": "RegTMargin",
"currency": "USD",
"buyingPower": 150000.0,
"cashValue": 85000.0,
"netLiquidation": 250000.0,
"realizedPnl": 3200.5,
"unrealizedPnl": 1850.75
}
]请求频率
基础限流为 60 次/分钟。
获取综合/模拟账户资产
签名
pub async fn get_prime_assets( &self, req: AssetsRequest, ) -> Result<Option<PrimeAsset>, TigerError>
说明
综合账户;请求同资产。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.sub_accounts | Option<Vec<String>> | 可选 | None(不序列化) |
| req.segment | Option<bool> | 可选 | None(不序列化) |
| req.market_value | Option<bool> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Option<PrimeAsset>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| account_id | String | 账户 ID |
| update_timestamp | i64 | 更新时间戳 |
| segments | Vec<PrimeAssetSegment> | 资产分段 |
PrimeAssetSegment 字段:
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| capability | String | 账户能力 |
| category | String | 分段类别 |
| currency | String | 币种 |
| cash_balance | f64 | 现金余额 |
| cash_available_for_trade | f64 | 可交易现金 |
| gross_position_value | f64 | 持仓总市值 |
| equity_with_loan | f64 | 含借贷权益 |
| net_liquidation | f64 | 净清算价值 |
| init_margin | f64 | 初始保证金 |
| maintain_margin | f64 | 维持保证金 |
| overnight_margin | f64 | 隔夜保证金 |
| unrealized_pl | f64 | 未实现盈亏 |
| unrealized_pl_by_cost_of_carry | f64 | 按资金成本计算的未实现盈亏 |
| realized_pl | f64 | 已实现盈亏 |
| total_today_pl | f64 | 当日总盈亏 |
| excess_liquidation | f64 | 超额流动性 |
| overnight_liquidation | f64 | 隔夜流动性 |
| buying_power | f64 | 购买力 |
| locked_funds | f64 | 冻结资金 |
| leverage | f64 | 杠杆 |
| uncollected | f64 | 未收资金 |
| currency_assets | Vec<CurrencyAsset> | 分币种资产 |
| consolidated_seg_types | Vec<String> | 合并分段类型 |
CurrencyAsset 字段:
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| currency | String | 币种 |
| cash_balance | f64 | 现金余额 |
| cash_available_for_trade | f64 | 可交易现金 |
| forex_rate | f64 | 外汇汇率 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_prime_assets(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_prime_assets(AssetsRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
{
"accountId": "402901",
"updateTimestamp": 1738180800000,
"segments": [
{
"category": "S",
"currency": "USD",
"buyingPower": 150000.0,
"cash": 85000.0,
"grossPositionValue": 165000.0
}
]
}请求频率
基础限流为 60 次/分钟。
获取聚合资产
签名
pub async fn get_aggregate_assets( &self, req: AggregateAssetsRequest, ) -> Result<Option<AggregateAssets>, TigerError>
说明
base_currency/分段可选;仅支持相应综合/机构账户。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.base_currency | Option<String> | 可选 | None(不序列化) |
| req.seg_type | Option<String> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Option<AggregateAssets>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| account_id | String | 账户 ID |
| net_liquidation | f64 | 净清算价值 |
| gross_position_value | f64 | 持仓总市值 |
| cash_balance | f64 | 现金余额 |
| base_currency | String | 基础币种 |
| currency_assets | Vec<CurrencyAsset> | 分币种资产;字段见 获取综合/模拟账户资产 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_aggregate_assets(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_aggregate_assets(AggregateAssetsRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
{
"accountId": "402901",
"netLiquidation": 250000.0,
"grossPositionValue": 165000.0,
"cashBalance": 85000.0,
"baseCurrency": "USD",
"currencyAssets": [
{
"currency": "USD",
"cashBalance": 85000.0,
"netLiquidation": 250000.0
}
]
}请求频率
基础限流为 60 次/分钟。
获取历史资产分析
签名
pub async fn get_analytics_asset( &self, req: AnalyticsAssetRequest, ) -> Result<Vec<AnalyticsAsset>, TigerError>
说明
起止为 YYYY-MM-DD;分段可选。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.seg_type | Option<String> | 可选 | None(不序列化) |
| req.start_date | Option<String> | 可选 | None(不序列化) |
| req.end_date | Option<String> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Vec<AnalyticsAsset>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| date | String | 日期 |
| holding_value | f64 | 持仓价值 |
| cash_balance | f64 | 现金余额 |
| pnl | f64 | 盈亏 |
| pnl_rate | f64 | 盈亏率 |
| net_value_index | f64 | 净值指数 |
| currency | String | 币种 |
| seg_type | String | 分段类型 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_analytics_asset(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_analytics_asset(AnalyticsAssetRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
[
{
"date": "2025-01-29",
"holdingValue": 165000.0,
"cashBalance": 85000.0,
"pnl": 2350.8,
"pnlRate": 0.0142,
"netValueIndex": 1.0142,
"currency": "USD",
"segType": "SEC"
}
]获取持仓
签名
pub async fn get_positions(&self, req: PositionsRequest) -> Result<Vec<Position>, TigerError>
说明
account 默认注入;可按类型、币种、市场、symbol、子账户、期权属性过滤。请求对象没有分页控制字段。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.sec_type | Option<String> | 可选 | None(不序列化) |
| req.currency | Option<String> | 可选 | None(不序列化) |
| req.market | Option<String> | 可选 | None(不序列化) |
| req.symbol | Option<String> | 可选 | None(不序列化) |
| req.sub_accounts | Option<Vec<String>> | 可选 | None(不序列化) |
| req.expiry | Option<String> | 可选 | None(不序列化) |
| req.strike | Option<String> | 可选 | None(不序列化) |
| req.right | Option<String> | 可选 | None(不序列化) |
| req.asset_quote_type | Option<String> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Vec<Position>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| account | Option<String> | 账户 |
| symbol | Option<String> | 标的代码 |
| sec_type | Option<String> | 证券类型 |
| market | Option<String> | 市场 |
| currency | Option<String> | 币种 |
| position | Option<i64> | 持仓数量 |
| average_cost | Option<f64> | 平均成本 |
| market_value | Option<f64> | 市值 |
| realized_pnl | Option<f64> | 已实现盈亏 |
| unrealized_pnl | Option<f64> | 未实现盈亏 |
| unrealized_pnl_percent | Option<f64> | 未实现盈亏率 |
| contract_id | Option<i64> | 合约 ID |
| identifier | Option<String> | 合约标识符 |
| name | Option<String> | 合约名称 |
| latest_price | Option<f64> | 最新价 |
| multiplier | Option<f64> | 合约乘数 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_positions(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_positions(PositionsRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
[
{
"account": "402901",
"symbol": "AAPL",
"secType": "STK",
"market": "US",
"currency": "USD",
"position": 100,
"averageCost": 178.35,
"marketValue": 19550.0
}
]请求频率
基础限流为 60 次/分钟。
预估可交易数量
签名
pub async fn get_estimate_tradable_quantity( &self, req: EstimateTradableQuantityRequest, ) -> Result<Option<EstimateTradableQuantity>, TigerError>
说明
symbol/sec_type/action 必填;限价类型需 limit_price;衍生品字段条件必填。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.symbol | Option<String> | 服务端必填;SDK 不预校验 | None(不序列化) |
| req.sec_type | Option<String> | 服务端必填;SDK 不预校验 | None(不序列化) |
| req.action | Option<String> | 服务端必填;SDK 不预校验 | None(不序列化) |
| req.order_type | Option<String> | 可选 | None(不序列化) |
| req.limit_price | Option<f64> | 可选 | None(不序列化) |
| req.market | Option<String> | 可选 | None(不序列化) |
| req.currency | Option<String> | 可选 | None(不序列化) |
| req.expiry | Option<String> | 可选 | None(不序列化) |
| req.strike | Option<String> | 可选 | None(不序列化) |
| req.right | Option<String> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Option<EstimateTradableQuantity>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| tradable_quantity | f64 | 可交易数量 |
| max_cash_buy_quantity | f64 | 最大现金买入数量 |
| max_margin_buy_quantity | f64 | 最大融资买入数量 |
| max_short_sell_quantity | f64 | 最大卖空数量 |
| max_position_sell_quantity | f64 | 最大持仓卖出数量 |
| cash_buying_power | f64 | 现金购买力 |
| currency | String | 币种 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_estimate_tradable_quantity(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_estimate_tradable_quantity(EstimateTradableQuantityRequest { symbol: Some("AAPL".into()), sec_type: Some("STK".into()), action: Some("BUY".into()), ..Default::default() }).await?;
Ok(())
}
返回示例
{
"tradableQuantity": 500,
"maxCashBuyQuantity": 430,
"maxMarginBuyQuantity": 760,
"maxShortSellQuantity": 300,
"maxPositionSellQuantity": 100,
"cashBuyingPower": 85000.0,
"currency": "USD"
}请求频率
基础限流为 60 次/分钟。
获取衍生品合约
签名
pub async fn get_derivative_contracts( &self, req: DerivativeContractsRequest, ) -> Result<Vec<Contract>, TigerError>
说明
symbols/sec_type 必填;expiry 可选;账户默认注入。
参数
| 参数 | Rust 类型 | 必填性/条件 | SDK 默认值 |
|---|---|---|---|
| req.account | Option<String> | 可选;多数 TradeClient 方法在 None 时注入默认账户 | None(不序列化) |
| req.symbols | Option<Vec<String>> | 可选 | None(不序列化) |
| req.sec_type | Option<String> | 可选 | None(不序列化) |
| req.expiry | Option<String> | 可选 | None(不序列化) |
| req.lang | Option<String> | 可选 | None(不序列化) |
返回
TradeClient:Result<Vec<Contract>, TigerError>.
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| contract_id | Option<i64> | 合约 ID |
| symbol | String | 标的代码 |
| sec_type | String | 证券类型 |
| currency | Option<String> | 币种 |
| exchange | Option<String> | 交易所 |
| primary_exchange | Option<String> | 主交易所 |
| expiry | Option<String> | 到期日 |
| strike | Option<f64> | 行权价 |
| right | Option<String> | PUT/CALL |
| multiplier | Option<f64> | 合约乘数 |
| identifier | Option<String> | 合约标识符 |
| name | Option<String> | 合约名称 |
| market | Option<String> | 市场 |
| tradeable | Option<bool> | 是否可交易 |
| conid | Option<i64> | 内部合约 ID |
| short_margin | Option<f64> | 做空保证金比例 |
| short_initial_margin | Option<f64> | 做空初始保证金比例 |
| short_maintenace_margin | Option<f64> | 做空维持保证金比例;Rust 字段名按 SDK 拼写保留 |
| long_initial_margin | Option<f64> | 做多初始保证金 |
| long_maintenace_margin | Option<f64> | 做多维持保证金;Rust 字段名按 SDK 拼写保留 |
| tick_sizes | Option<Vec<TickSize>> | 最小报价单位区间 |
| lot_size | Option<f64> | 每手数量 |
TickSize 字段:
| 字段 | Rust 类型 | 说明 |
|---|---|---|
| begin | Option<String> | 区间起始价格 |
| end | Option<String> | 区间结束价格 |
| tick_size | Option<f64> | 最小报价单位 |
| r#type | Option<String> | 区间类型 |
示例
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_get_derivative_contracts(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = trade.get_derivative_contracts(DerivativeContractsRequest { ..Default::default() }).await?;
Ok(())
}
返回示例
[
{
"contractId": 265598,
"symbol": "AAPL",
"secType": "OPT",
"currency": "USD",
"exchange": "CBOE",
"primaryExchange": "CBOE",
"expiry": "2025-02-21",
"strike": 195.0
}
]请求频率
基础限流为 60 次/分钟。get_quote_contract 与 get_derivative_contracts 均使用 quote_contract,共享此额度。
Updated about 1 month ago
Did this page help you?
