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
OrderRequest fields (all Option, SDK skips None fields when serializing):
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | Option<String> | No | Account (auto-injected if omitted) |
| symbol | Option<String> | Yes | Symbol, e.g. AAPL |
| sec_type | Option<String> | Yes | Security type: STK/OPT/FUT/WAR/IOPT |
| action | Option<String> | Yes | Direction: BUY/SELL |
| order_type | Option<String> | Yes | Order type: MKT/LMT/STP/STP_LMT/TRAIL |
| total_quantity | Option<i64> | Yes | Order quantity |
| limit_price | Option<f64> | Conditional | Limit price (required for LMT/STP_LMT) |
| aux_price | Option<f64> | Conditional | Stop price (required for STP/STP_LMT); trailing amount for TRAIL |
| trailing_percent | Option<f64> | No | Trailing stop percentage (mutually exclusive with aux_price) |
| time_in_force | Option<String> | No | DAY/GTC/GTD, default DAY |
| outside_rth | Option<bool> | No | Allow extended hours trading |
| expire_time | Option<i64> | Conditional | Required for GTD (13-digit ms timestamp) |
| market | Option<String> | No | Market: US/HK/CN |
| currency | Option<String> | No | Currency: USD/HKD/CNH |
| expiry | Option<String> | No | Option expiry YYYYMMDD |
| strike | Option<String> | No | Option strike price |
| right | Option<String> | No | PUT/CALL |
| adjust_limit | Option<f64> | No | Price adjustment tolerance |
| secret_key | Option<String> | No | Institutional trader key |
| user_mark | Option<String> | No | User remark |
| order_legs | Option<Vec<OrderLegRequest>> | No | Attached orders (take profit/stop loss) |
| algo_params | Option<AlgoParamsRequest> | No | Algo order parameters |
Response
Result<Option<PlaceOrderResult>, TigerError>
| Field | Type | Description |
|---|---|---|
| id | i64 | Global order ID |
| order_id | i64 | Order number |
| sub_ids | Vec<i64> | Sub-order IDs |
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,
"sub_ids": []
}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
Same as Place Order.
Response
Result<Option<PreviewResult>, TigerError>
| Field | Type | Description |
|---|---|---|
| is_pass | bool | Whether the order is feasible |
| commission | f64 | Estimated commission |
| commission_currency | String | Commission currency |
| init_margin | f64 | Initial margin |
| maint_margin | f64 | Maintenance margin |
| equity_with_loan | f64 | Equity with loan value |
| available_ee | f64 | Available funds |
| message | String | Message |
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
{
"is_pass": true,
"commission": 1.99,
"commission_currency": "USD",
"init_margin": 9775.0,
"maint_margin": 9775.0,
"equity_with_loan": 50000.0,
"available_ee": 40225.0,
"message": ""
}Updated 1 day ago
Did this page help you?
