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):

ParameterTypeRequiredDescription
accountOption<String>NoAccount (auto-injected if omitted)
symbolOption<String>YesSymbol, e.g. AAPL
sec_typeOption<String>YesSecurity type: STK/OPT/FUT/WAR/IOPT
actionOption<String>YesDirection: BUY/SELL
order_typeOption<String>YesOrder type: MKT/LMT/STP/STP_LMT/TRAIL
total_quantityOption<i64>YesOrder quantity
limit_priceOption<f64>ConditionalLimit price (required for LMT/STP_LMT)
aux_priceOption<f64>ConditionalStop price (required for STP/STP_LMT); trailing amount for TRAIL
trailing_percentOption<f64>NoTrailing stop percentage (mutually exclusive with aux_price)
time_in_forceOption<String>NoDAY/GTC/GTD, default DAY
outside_rthOption<bool>NoAllow extended hours trading
expire_timeOption<i64>ConditionalRequired for GTD (13-digit ms timestamp)
marketOption<String>NoMarket: US/HK/CN
currencyOption<String>NoCurrency: USD/HKD/CNH
expiryOption<String>NoOption expiry YYYYMMDD
strikeOption<String>NoOption strike price
rightOption<String>NoPUT/CALL
adjust_limitOption<f64>NoPrice adjustment tolerance
secret_keyOption<String>NoInstitutional trader key
user_markOption<String>NoUser remark
order_legsOption<Vec<OrderLegRequest>>NoAttached orders (take profit/stop loss)
algo_paramsOption<AlgoParamsRequest>NoAlgo order parameters

Response

Result<Option<PlaceOrderResult>, TigerError>

FieldTypeDescription
idi64Global order ID
order_idi64Order number
sub_idsVec<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>

FieldTypeDescription
is_passboolWhether the order is feasible
commissionf64Estimated commission
commission_currencyStringCommission currency
init_marginf64Initial margin
maint_marginf64Maintenance margin
equity_with_loanf64Equity with loan value
available_eef64Available funds
messageStringMessage

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": ""
}

Did this page help you?