Place Orders
Place Order
Signature
pub async fn place_order(&self, order: OrderRequest) -> Result<Option<PlaceOrderResult>, TigerError>Description
Submit a real order. Requires trading permissions and sufficient buying power. Use preview_order to validate first.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| order.account | Option<String> | Do not set; the SDK always overwrites it with the TradeClient account | TradeClient account |
| order.id | Option<i64> | Do not set when placing an order; the server returns this global order ID after successful placement | None (omitted) |
| order.order_id | Option<i64> | Do not set when placing an order; the server returns this account-sequential order number after successful placement | None (omitted) |
| order.action | Option<String> | Required by the server; legal values: BUY, SELL; not prevalidated by the SDK | None (omitted) |
| order.order_type | Option<String> | Required by the server; legal values: MKT, LMT, STP, STP_LMT, VWAP, TWAP, TRAIL, ICEBERG; not prevalidated by the SDK | None (omitted) |
| order.total_quantity | Option<i64> | Required by the server; not prevalidated by the SDK | None (omitted) |
| order.limit_price | Option<f64> | Required for LMT/STP_LMT | None (omitted) |
| order.aux_price | Option<f64> | Required for STP/STP_LMT; for TRAIL, this is the trailing amount and should be used instead of trailing_percent as recommended | None (omitted) |
| order.trailing_percent | Option<f64> | For TRAIL, use one of this field or aux_price as recommended; if set, must be greater than 0 and less than 100 | None (omitted) |
| order.time_in_force | Option<String> | Optional; legal values: DAY, GTC, GTD | None (omitted) |
| order.outside_rth | Option<bool> | Optional; whether to allow pre-market and after-hours trading | None (omitted) |
| order.order_legs | Option<Vec<OrderLegRequest>> | Optional; attached profit-taker and stop-loss orders | None (omitted) |
| order.algo_params | Option<AlgoParamsRequest> | Optional; algorithm-order parameters | None (omitted) |
| order.symbol | Option<String> | Required by the server; not prevalidated by the SDK | None (omitted) |
| order.sec_type | Option<String> | Required by the server; legal values: STK, OPT, FUT, WAR, IOPT, FUND, FOREX, MLEG, CC; not prevalidated by the SDK | None (omitted) |
| order.market | Option<String> | Optional | None (omitted) |
| order.currency | Option<String> | Optional | None (omitted) |
| order.expiry | Option<String> | Optional; option expiry date, for example 2024-01-19 | None (omitted) |
| order.strike | Option<String> | Optional | None (omitted) |
| order.right | Option<String> | Required for OPT; legal values: CALL, PUT | None (omitted) |
| order.identifier | Option<String> | Optional | None (omitted) |
| order.remark | Option<String> | Optional | None (omitted) |
| order.user_mark | Option<String> | Optional; user remark | None (omitted) |
| order.display_size | Option<i64> | Optional | None (omitted) |
| order.min_display_size | Option<i64> | Optional | None (omitted) |
| order.check_intervals | Option<i64> | Optional | None (omitted) |
| order.price_type | Option<String> | Optional for ICEBERG; legal values: LIMIT_PRICE, ASK_PRICE, BID_PRICE, LATEST_PRICE | None (omitted) |
| order.start_time | Option<i64> | Optional; Iceberg effective start time as a Unix millisecond timestamp | None (omitted) |
| order.end_time | Option<i64> | Optional; Iceberg effective end time as a Unix millisecond timestamp | None (omitted) |
| order.secret_key | Option<String> | Optional; institutional-account trading key | Injected from client configuration when available; otherwise omitted |
| order.adjust_limit | Option<f64> | Optional; limit-price offset for scenarios such as STP | None (omitted) |
| order.expire_time | Option<i64> | Required for GTD; Unix millisecond timestamp | None (omitted) |
| order.trading_session_type | Option<String> | Optional | None (omitted) |
| order.exchange | Option<String> | Optional | None (omitted) |
| order.multiplier | Option<String> | Optional | None (omitted) |
| order.local_symbol | Option<String> | Optional | None (omitted) |
| order.alloc_accounts | Option<Vec<String>> | Optional | None (omitted) |
| order.alloc_shares | Option<Vec<f64>> | Optional | None (omitted) |
| order.total_quantity_scale | Option<i32> | Optional | None (omitted) |
| order.attach_type | Option<String> | Optional; legal values: PROFIT, LOSS, BRACKETS | None (omitted) |
| order.profit_taker_order_id | Option<i64> | Optional | None (omitted) |
| order.profit_taker_price | Option<f64> | Optional | None (omitted) |
| order.profit_taker_tif | Option<String> | Optional | None (omitted) |
| order.profit_taker_rth | Option<bool> | Optional | None (omitted) |
| order.stop_loss_order_type | Option<String> | Optional for stop-loss attachments; common values: STP, STP_LMT, TRAIL | None (omitted) |
| order.stop_loss_order_id | Option<i64> | Optional | None (omitted) |
| order.stop_loss_price | Option<f64> | Optional | None (omitted) |
| order.stop_loss_limit_price | Option<f64> | Optional | None (omitted) |
| order.stop_loss_tif | Option<String> | Optional | None (omitted) |
| order.stop_loss_trailing_percent | Option<f64> | For a TRAIL stop-loss attachment, use one of this field or stop_loss_trailing_amount as recommended; if set, must be greater than 0 and less than 100 | None (omitted) |
| order.stop_loss_trailing_amount | Option<f64> | For a TRAIL stop-loss attachment, use one of this field or stop_loss_trailing_percent as recommended; if set, must be nonzero | None (omitted) |
| order.combo_type | Option<String> | Optional | None (omitted) |
| order.contract_legs | Option<Vec<ContractLegRequest>> | Optional | None (omitted) |
| order.oca_orders | Option<Vec<Box<OrderRequest>>> | Optional | None (omitted) |
| order.cash_amount | Option<f64> | Optional | None (omitted) |
Response
Result<Option<PlaceOrderResult>, TigerError>
| Field | Type | Description |
|---|---|---|
| id | i64 | Global order ID |
| order_id | i64 | Account-sequential order number |
| sub_ids | Vec<i64> | Sub-order IDs |
| orders | Vec<Order> | Orders returned with the placement result; empty when none are returned |
Example
use tigeropen::config::ClientConfig;
use tigeropen::model::order::limit_order;
use tigeropen::trade::TradeClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ClientConfig::builder().build()?;
let account = config.account.clone();
let trade = TradeClient::from_config(config);
let order = limit_order(&account, "AAPL", "STK", "BUY", 100, 195.50);
let result = trade.place_order(order).await?;
if let Some(r) = result {
println!("Order placed, id={}, order_id={}", r.id, r.order_id);
}
Ok(())
}Response Example
{
"id": 31234567,
"order_id": 100234,
"subIds": []
}Rate limit
The base rate limit is 120 requests/min.
Preview Order
Signature
pub async fn preview_order(&self, order: OrderRequest) -> Result<Option<PreviewResult>, TigerError>Description
Preview an order without actually submitting it. Use to check commission, margin requirements, and feasibility.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| order.account | Option<String> | Do not set; the SDK always overwrites it with the TradeClient account | TradeClient account |
| order.id | Option<i64> | Not used for preview; leave as None | None (omitted) |
| order.order_id | Option<i64> | Not used for preview; leave as None | None (omitted) |
| order.action | Option<String> | Required by the server; legal values: BUY, SELL; not prevalidated by the SDK | None (omitted) |
| order.order_type | Option<String> | Required by the server; legal values: MKT, LMT, STP, STP_LMT, VWAP, TWAP, TRAIL, ICEBERG; not prevalidated by the SDK | None (omitted) |
| order.total_quantity | Option<i64> | Required by the server; not prevalidated by the SDK | None (omitted) |
| order.limit_price | Option<f64> | Required for LMT/STP_LMT | None (omitted) |
| order.aux_price | Option<f64> | Required for STP/STP_LMT; for TRAIL, this is the trailing amount and should be used instead of trailing_percent as recommended | None (omitted) |
| order.trailing_percent | Option<f64> | For TRAIL, use one of this field or aux_price as recommended; if set, must be greater than 0 and less than 100 | None (omitted) |
| order.time_in_force | Option<String> | Optional; legal values: DAY, GTC, GTD | None (omitted) |
| order.outside_rth | Option<bool> | Optional; whether to allow pre-market and after-hours trading | None (omitted) |
| order.order_legs | Option<Vec<OrderLegRequest>> | Optional; attached profit-taker and stop-loss orders | None (omitted) |
| order.algo_params | Option<AlgoParamsRequest> | Optional; algorithm-order parameters | None (omitted) |
| order.symbol | Option<String> | Required by the server; not prevalidated by the SDK | None (omitted) |
| order.sec_type | Option<String> | Required by the server; legal values: STK, OPT, FUT, WAR, IOPT, FUND, FOREX, MLEG, CC; not prevalidated by the SDK | None (omitted) |
| order.market | Option<String> | Optional | None (omitted) |
| order.currency | Option<String> | Optional | None (omitted) |
| order.expiry | Option<String> | Optional; option expiry date, for example 2024-01-19 | None (omitted) |
| order.strike | Option<String> | Optional | None (omitted) |
| order.right | Option<String> | Required for OPT; legal values: CALL, PUT | None (omitted) |
| order.identifier | Option<String> | Optional | None (omitted) |
| order.remark | Option<String> | Optional | None (omitted) |
| order.user_mark | Option<String> | Optional; user remark | None (omitted) |
| order.display_size | Option<i64> | Optional | None (omitted) |
| order.min_display_size | Option<i64> | Optional | None (omitted) |
| order.check_intervals | Option<i64> | Optional | None (omitted) |
| order.price_type | Option<String> | Optional for ICEBERG; legal values: LIMIT_PRICE, ASK_PRICE, BID_PRICE, LATEST_PRICE | None (omitted) |
| order.start_time | Option<i64> | Optional; Iceberg effective start time as a Unix millisecond timestamp | None (omitted) |
| order.end_time | Option<i64> | Optional; Iceberg effective end time as a Unix millisecond timestamp | None (omitted) |
| order.secret_key | Option<String> | Optional; institutional-account trading key | Injected from client configuration when available; otherwise omitted |
| order.adjust_limit | Option<f64> | Optional; limit-price offset for scenarios such as STP | None (omitted) |
| order.expire_time | Option<i64> | Required for GTD; Unix millisecond timestamp | None (omitted) |
| order.trading_session_type | Option<String> | Optional | None (omitted) |
| order.exchange | Option<String> | Optional | None (omitted) |
| order.multiplier | Option<String> | Optional | None (omitted) |
| order.local_symbol | Option<String> | Optional | None (omitted) |
| order.alloc_accounts | Option<Vec<String>> | Optional | None (omitted) |
| order.alloc_shares | Option<Vec<f64>> | Optional | None (omitted) |
| order.total_quantity_scale | Option<i32> | Optional | None (omitted) |
| order.attach_type | Option<String> | Optional; legal values: PROFIT, LOSS, BRACKETS | None (omitted) |
| order.profit_taker_order_id | Option<i64> | Optional | None (omitted) |
| order.profit_taker_price | Option<f64> | Optional | None (omitted) |
| order.profit_taker_tif | Option<String> | Optional | None (omitted) |
| order.profit_taker_rth | Option<bool> | Optional | None (omitted) |
| order.stop_loss_order_type | Option<String> | Optional for stop-loss attachments; common values: STP, STP_LMT, TRAIL | None (omitted) |
| order.stop_loss_order_id | Option<i64> | Optional | None (omitted) |
| order.stop_loss_price | Option<f64> | Optional | None (omitted) |
| order.stop_loss_limit_price | Option<f64> | Optional | None (omitted) |
| order.stop_loss_tif | Option<String> | Optional | None (omitted) |
| order.stop_loss_trailing_percent | Option<f64> | For a TRAIL stop-loss attachment, use one of this field or stop_loss_trailing_amount as recommended; if set, must be greater than 0 and less than 100 | None (omitted) |
| order.stop_loss_trailing_amount | Option<f64> | For a TRAIL stop-loss attachment, use one of this field or stop_loss_trailing_percent as recommended; if set, must be nonzero | None (omitted) |
| order.combo_type | Option<String> | Optional | None (omitted) |
| order.contract_legs | Option<Vec<ContractLegRequest>> | Optional | None (omitted) |
| order.oca_orders | Option<Vec<Box<OrderRequest>>> | Optional | None (omitted) |
| order.cash_amount | Option<f64> | Optional | None (omitted) |
Response
Result<Option<PreviewResult>, TigerError>
| Field | Type | Description |
|---|---|---|
| is_pass | bool | Whether the order is feasible |
| account | String | Account |
| commission | f64 | Estimated commission |
| commission_currency | String | Commission currency |
| margin_currency | String | Margin currency |
| init_margin | f64 | Initial margin |
| init_margin_before | f64 | Initial margin before preview |
| maint_margin | f64 | Maintenance margin |
| maint_margin_before | f64 | Maintenance margin before preview |
| equity_with_loan | f64 | Equity with loan value |
| equity_with_loan_before | f64 | Equity with loan before preview |
| available_ee | f64 | Available excess equity after the hypothetical fill, in margin_currency |
| excess_liquidity | f64 | Excess liquidity after the hypothetical fill, in margin_currency |
| overnight_liquidation | f64 | Overnight excess liquidity after the hypothetical fill, in margin_currency |
| gst | f64 | Goods and services tax |
| message | String | Message |
These three asset fields may be absent for account types or scenarios where they do not apply. The Rust model uses non-nullable f64 values, so a missing field and an explicit zero both appear as 0.
Example
let order = limit_order(&account, "AAPL", "STK", "BUY", 100, 195.50);
let preview = trade.preview_order(order).await?;
if let Some(p) = preview {
println!("pass={} commission={} margin={}", p.is_pass, p.commission, p.init_margin);
}Response Example
{
"isPass": true,
"commission": 1.99,
"commissionCurrency": "USD",
"initMargin": 9775.0,
"maintMargin": 9775.0,
"equityWithLoan": 50000.0,
"availableEE": 40225.0,
"message": ""
}Updated about 1 month ago
Did this page help you?
