Objects
PortfolioAccount Assets (Prime/Paper Trading Account)
Description
Account asset object, applicable to prime/paper trading accounts. Contains information about the account's total assets, profit and loss, position market value, cash, available funds, margin, leverage, and other related information.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| account | str | Corresponding account ID |
| update_timestamp | int | Update time, 13-digit timestamp in milliseconds |
| segments | tigeropen.trade.domain.prime_account.Segment | Account information classified by trading instrument. The content is a dict with two keys: 'S' for securities, with values being |
Segment Assets by Category (Prime/Paper Trading Account)
Description
Assets are divided by stock trading instruments, with each part being a Segment.
Object Properties
Property Name | Type | Description |
|---|---|---|
currency | str | Currency, such as USD |
capability | str | Account type, margin or cash |
category | str | Trading instrument category S: (Securities stocks) |
cash_balance | float | Account cash balance |
cash_available_for_trade | float | Available funds. Used to check whether opening positions or IPO subscriptions are possible. Calculated using total assets, option position market value, frozen funds, and initial margin. |
cash_available_for_withdrawal | float | Cash amount that can be withdrawn from the current account |
buying_power | float | Maximum buying power. |
gross_position_value | float | Total securities value. The sum of the total market value of securities held in the account. |
equity_with_loan | float | Total equity with loan value (ELV). ELV is used to calculate opening and closing positions. Cash accounts: ELV = Cash balance Margin accounts: ELV = Cash balance + Total securities market value – US stock options market value (equivalently: ELV = Total assets – US stock options) |
net_liquidation | float | Total assets (NLV). Total assets are the sum of the account's net liquidation cash balance and total securities market value. |
init_margin | float | Initial margin. The sum of initial margin requirements for all current position contracts. When first executing trades, opening positions is only allowed when equity with loan is greater than the initial margin. |
maintain_margin | float | Maintenance margin. The sum of maintenance margin requirements for all current position contracts. When holding positions, forced liquidation will be triggered when equity with a loan is less than the maintenance margin. |
overnight_margin | float | Overnight margin. |
unrealized_pl | float | Position profit and loss. |
realized_pl | float | Realized profit and loss is the sum of realized profit and loss of individual stocks and derivatives that have been reduced during the current holding cycle. |
excess_liquidation | float | Current excess liquidity. Example: (1) Customer total assets $10,000, bought Apple $12,000 (assuming Apple's opening and maintenance margin ratio is 50%). Current excess liquidity = Total assets 10,000 - Account maintenance margin 6,000 = 4,000. |
overnight_liquidation | float | Overnight excess liquidity. Hhow much liquidity your account has after meeting overnight margin requirements. It helps indicate whether your positions are safe to hold after the market closes. |
leverage | float | Leverage shows how much buying power your account is using relative to your total assets. It helps you quickly understand your account’s risk level and how much of your funds are being borrowed. Leverage = (Sum of absolute market values of all securities) / Total assets |
currency_assets | dict | Account asset information classified by trading currency, is a dict with currency as key, value is CurrencyAsset object |
uncollected | float | Funds in transit |
locked_funds | float | Locked funds |
CurrencyAsset Assets by Currency (Prime/Paper Trading Account)
Description
Assets classified by currency.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| currency | str | Current currency type, common currencies include: USD-US Dollar |
| cash_balance | float | Cash available for trading, plus locked cash portion (such as purchased but not yet executed stocks, and other situations that may have locked cash) |
| cash_available_for_trade | float | Cash amount currently available for trading in the account |
Position
Description
Account position information. Includes contract, position quantity, cost, profit and loss, and other information.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| account | str | Corresponding account ID |
| contract | tigeropen.trade.domain.contract.Contract | Contract object |
| position_qty | float | Position quantity |
| quantity | int | (Deprecated) Position quantity. When the actual position has decimals, need to combine with position_scale |
| position_scale | int | (Deprecated) Position quantity decimal offset. If position=11123, positionScale=2, then actual position=11123*10^(-2)=111.23 |
| average_cost | float | Average cost including commission |
| market_value | float | Market value |
| salable_qty | float | Sellable quantity |
| average_cost_of_carry | float | Cumulative position cost (A-share calculation method) |
| market_price | float | Market price |
| is_level0_price | boolean | Whether it is lv0 (delayed) quotes |
| realized_pnl | float | Realized P&L under FIFO mode |
| unrealized_pnl | float | Unrealized P&L |
| unrealized_pnl_by_cost_of_carry | float | Unrealized P&L (A-share calculation method) |
| unrealized_pnl_percent_by_cost_of_carry | float | Unrealized P&L percentage (A-share calculation method) |
| today_pnl | float | Today's P&L amount |
| today_pnl_percent | float | Today's P&L percentage |
| yesterday_pnl | float | Fund yesterday's P&L |
| last_close_price | float | Last intraday close price (forward adjusted), for US stocks intraday it's previous trading day's close price |
Order
Description
Order object. Order queries will return this object, and placing/modifying orders also requires using this object.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| account | str | Account to which the order belongs |
| id | long | Global order ID |
| order_id | int | Account auto-increment order number, deprecated |
| order_time | int | Order time, 13-digit timestamp in milliseconds |
| trade_time | int | Order status update time. For filled orders, represents fill time; for cancelled orders, represents successful cancellation time, 13-digit timestamp in milliseconds |
| update_time | int | Order update time. When order properties change (such as order modification), this time will be updated, 13-digit timestamp in milliseconds |
| expire_time | int | GTD order expiration time, 13-digit timestamp in milliseconds |
| reason | str | When order placement fails, returns description of failure reason |
| action | str | Trade direction, 'BUY' / 'SELL' |
| quantity | int | Order quantity |
| quantity_scale | int | Order quantity offset, default is 0. For fractional shares, quantity and quantity_scale combined represent actual order quantity, e.g., quantity=111 quantity_scale=2, then actual quantity=111*10^(-2)=1.11 |
| total_cash_amount | float | Total order amount, None when ordering by shares |
| filled_cash_amount | float | Filled amount, None when ordering by shares |
| refund_cash_amount | float | Refund amount, equals total order amount minus filled amount. None when ordering by shares or order is not terminated |
| filled | int | Filled quantity |
| avg_fill_price | float | Average fill price excluding commission |
| commission | float | Includes commission, stamp duty, regulatory fees and other charges |
| gst | float | Tax - Goods and Service Tax |
| realized_pnl | float | Realized P&L |
| limit_price | float | Limit order price |
| aux_price | float | In stop orders, represents the trigger price for stop order. |
| percent_offset | float | <This field is not used> |
| order_type | str | Order type, 'MKT' market order / 'LMT' limit order / 'STP' stop order / 'STP_LMT' stop limit order |
| time_in_force | str | Time in force, 'DAY' day order / 'GTC' good till cancelled / 'GTD' good till date (requires additional expire_time) |
| outside_rth | bool | Whether to support pre-market and after-hours trading, US stocks only |
| trading_session_type | str | Night trading session |
| contract | Contract |
tigeropen.trade.domain.order.Charge Object Properties
| Property | Type | Description |
|---|---|---|
| category | str | Fee category (TIGER/THIRD_PARTY) |
| category_desc | str | Fee category description: TradeUP Charges; Third Party Fees |
| total | float | Total fees for current category |
| details | tigeropen.trade.domain.order.ChargeDetail | Fee details |
tigeropen.trade.domain.order.ChargeDetail Object Properties
| Property | Type | Description |
|---|---|---|
| type | str | Fee type: SETTLEMENT_FEE/STAMP_DUTY/TRANSACTION_LEVY/EXCHANGE_FEE/FRC_TRANSACTION_LEVY |
| type_desc | str | Fee type description: Settlement Fee; Stamp Duty; Transaction Levy; Exchange Fee; AFRC Transaction Levy |
| original_amount | float | Fee amount |
| after_discount_amount | float | Fee amount after discount |
Construction Method:
Generate order objects locally through tigeropen.common.util.order_utils in the SDK: order_utils only provides commonly used parameters. If additional parameters are needed, you can generate the order object first and then modify its properties.
from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import (market_order, # Market order
limit_order, # Limit order
stop_order, # Stop order
stop_limit_order) # Stop limit order
contract = stock_contract('XYZX', currency='USD')
order = limit_order('your account', contract, 'BUY', 100, 150.5)
order.time_in_force = 'GTC' # Set order properties
# Subsequent operations... market_order Market Order
market_order(account, contract, action, quantity)Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Trading account, can use prime account or paper account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
limit_order Limit Order
limit_order(account, contract, action, quantity, limit_price)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Trading account, can use prime account or paper account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
stop_order Stop Order
stop_order(account, contract, action, quantity, aux_price)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Trading account, can use prime account or paper account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
stop_limit_order Stop Limit Order
stop_limit_order(account, contract, action, quantity, limit_price, aux_price)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Trading account, can use prime account or paper account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
order_leg Additional Order
order_leg(leg_type, price, time_in_force='DAY', outside_rth=None)
Parameters
| Parameter Name | Type | Description |
|---|---|---|
| leg_type | str | Additional order type. 'PROFIT' for take profit order, 'LOSS' for stop loss order |
| price | float | Additional order price |
| time_in_force | str | Additional order time in force. 'DAY' (Day) and 'GTC' (Good-Til-Canceled) |
| outside_rth | bool | Whether additional order allows pre-market and after-hours trading (US stocks only). True allows, False disallows |
Returns
OrderLeg object tigeropen.trade.domain.order.OrderLeg
auction_limit_order Auction Limit Order
auction_limit_order(account, contract, action, quantity, limit_price, time_in_force)
Parameters
| Parameter Name | Type | Description |
|---|---|---|
| account | str | Trading account, can use prime account or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
auction_market_order Auction Market Order
auction_market_order(account, contract, action, quantity, time_in_force)
Parameters
| Parameter Name | Type | Description |
|---|---|---|
| account | str | Trading account, can use prime account or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Transaction Trade Record
tigeropen.trade.domain.order.Transaction
Description
Trade execution record of an order
Object Properties
| Property | Type | Description |
|---|---|---|
| account | str | Account |
| order_id | int | Order ID |
| contract | Contract |
OrderLeg Additional Order
tigeropen.trade.domain.order.OrderLeg
Description
Additional orders carried with the main order
Object Properties
| Property | Type | Description |
|---|---|---|
| leg_type | str | Additional order type. 'PROFIT' for take profit order, 'LOSS' for stop loss order |
| price | float | Additional order price |
| time_in_force | str | Additional order time in force. 'DAY' (Day) and 'GTC' (Good-Til-Canceled) |
| outside_rth | bool | Whether additional order allows pre-market and after-hours trading (US stocks only). True allows, False disallows |
Contract
tigeropen.trade.domain.contract.Contract source
Description
A contract refers to the trading object or underlying asset (such as a stock or an option), which is standardized by the exchange. Similarly, when purchasing options, other identifying fields may be needed. Through contract information, we can uniquely determine an underlying asset when placing orders or obtaining quotes. In the OpenAPI Python SDK, contract information is stored through the tigeropen.trade.domain.contract.Contract object. The Contract object can be passed to utility functions for constructing Order objects, used for placing orders.
Common contracts include stock contracts, option contracts, etc. Most contracts include the following elements:
- Symbol - Generally, US and UK contract codes are alphabetic, e.g., XYZX.
- Security Type - Common contract types include: STK (stock), OPT (option), CASH, e.g., stock contract type is STK.
- Currency - Common currencies include USD (US Dollar)
- Exchange - STK type contracts generally don't use the exchange field, as orders are automatically routed.
Most stocks, CFDs, or indices pairs can be uniquely determined by these four attributes. Due to their nature, more complex contracts (such as options) require some additional information. Here are several common contract types and their constituent elements:
Stocks:
from tigeropen.common.util.contract_utils import stock_contract
contract = stock_contract(symbol='XYZX', currency='USD')Options
from tigeropen.common.util.contract_utils import option_contract, option_contract_by_symbol
contract = option_contract(identifier='XYZX 190118P00160000')
contract = option_contract_by_symbol('JD', expiry='20211015', strike=45.0, put_call='PUT', currency='USD')
from tigeropen.common.util.contract_utils import war_contract_by_symbol
contract = war_contract_by_symbol('01810', '20221116', 14.52, 'CALL', local_symbol='14759', multiplier=2000,
currency='USD')MarketStatus Market Status
tigeropen.quote.domain.market_status.MarketStatus
Description
Market trading status
Object Properties
| Property | Type | Description |
|---|---|---|
| market | str | Market. (US: US stocks) |
| trading_status | str | Market trading status code. Not yet open NOT_YET_OPEN; Pre-market trading PRE_HOUR_TRADING; Trading TRADING; Midday break MIDDLE_CLOSE; After-hours trading POST_HOUR_TRADING; Closed CLOSING; Early close EARLY_CLOSED; Market closed MARKET_CLOSED; |
| status | str | Market status description (not yet open, trading, closed, etc.) |
| open_time | datetime.datetime | Most recent open time |
OptionFilter Option Chain Filter
tigeropen.quote.domain.filter.OptionFilter
Description
Option filter parameter object
Object Properties
| Parameter | Type | Required | Description |
|---|---|---|---|
| implied_volatility | float | No | Implied volatility, reflects market expectations of future stock price volatility. Higher implied volatility indicates more expected stock price volatility |
| in_the_money | bool | No | Whether in the money |
| open_interest | int | No | Open interest, number of uncleared contracts held by market participants at the end of each trading day. Reflects market depth and liquidity |
| delta | float | No | Delta reflects the impact of stock price changes on option price changes. For every $1 change in stock price, the option price changes approximately delta. Range -1.0 ~ 1.0 |
| gamma | float | No | Gamma, reflects the impact of stock price changes on delta. For every $1 change in stock price, delta changes by gamma |
| theta | float | No | Theta reflects the impact of time changes on option price changes. For every day reduction in time, the option price changes approximately theta |
| vega | float | No | Vega reflects the impact of volatility on option price changes. For every 1% change in volatility, the option price changes approximately vega |
| rho | float | No | Rho reflects the impact of risk-free interest rate on option price changes. For every 1% change in risk-free interest rate, the option price changes approximately rho |
Order Changes
| Field | Description |
|---|---|
| id | Order ID |
| account | Account |
| symbol | Position symbol |
| expiry | Options, CBBC only |
| strike | Options, CBBC only |
| right | Options, CBBC only |
| identifier | Asset identifier. Stock identifier is the same as the symbol. |
| multiplier | Quantity per lot, options, CBBC only |
| action | Buy/sell direction. BUY for buy, SELL for sell |
| market | Market. US |
| currency | Currency. USD US Dollar |
| segType | Classification by trading type. S for stocks |
| secType | STK Stocks, OPT Options, IOPT CBBC |
| orderType | Order type. 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order |
| isLong | Whether long position |
| totalQuantity | Order quantity |
| totalQuantityScale | Order quantity offset, e.g., totalQuantity=111, totalQuantityScale=2, then actual totalQuantity=111*10^(-2)=1.11 |
| filledQuantity | Total filled quantity (for orders filled in multiple trades, filledQuantity is cumulative total filled) |
| filledQuantityScale | Total filled quantity offset |
| avgFillPrice | Average fill price |
| limitPrice | Limit order price |
| stopPrice | Stop price |
| realizedPnl | Realized P&L (only prime accounts have this field) |
| status | Order Status |
| replaceStatus | Order Replace Status |
| cancelStatus | Order Cancel Status |
| outsideRth | Whether allows pre-market and after-hours trading, US stocks only |
| canModify | Whether can modify |
| canCancel | Whether can cancel |
| liquidation | Whether it's a closing order |
| name | Asset name |
| source | Order source (from 'OpenApi', or other) |
| errorMsg | Error message |
| attrDesc | Order description |
| commissionAndFee | Total commission and fees |
| openTime | Order time |
| timestamp | Order status last update time |
Position Changes
| Field | Description |
|---|---|
| account | User account |
| symbol | Stock code |
| expiry | Expiry date, options, CBBC only |
| strike | Strike price, options, CBBC only |
| right | Option direction PUT/CALL, options, CBBC only |
| identifier | Asset identifier |
| multiplier | Lot size, options, CBBC only |
| market | Trading market |
| currency | Currency type |
| segType | Classification by trading type. S for stocks |
| secType | Contract type |
| position | Position |
| positionScale | Position quantity offset |
| averageCost | Average cost |
| latestPrice | Latest price |
| marketValue | Market value |
| unrealizedPnl | Unrealized P&L |
| name | Asset name |
| timestamp | Server time |
Asset Changes
| Field | Description |
|---|---|
| account | User account |
| currency | Currency type |
| segType | Classification by trading type. S for stocks |
| availableFunds | Available funds (loan value equity - initial margin) |
| excessLiquidity | Excess liquidity (loan value equity - maintenance margin) |
| netLiquidation | Net liquidation value |
| equityWithLoan | Equity with loan value (loan value assets) |
| buyingPower | Buying power |
| cashBalance | Account cash balance |
| grossPositionValue | Position market value |
| initMarginReq | Current initial margin |
| maintMarginReq | Current maintenance margin |
| timestamp | Server time |
Quote Changes
- Basic quotes
| Field | Sub-field | Description |
|---|---|---|
| symbol | Stock code | |
| type | Type | |
| timestamp | Quote data time | |
| serverTimestamp | Server time | |
| avgPrice | Average price | |
| latestPrice | Latest price | |
| latestPriceTimestamp | Latest price timestamp (no value in pre/post market) | |
| latestTime | Latest price time | |
| preClose | Previous close | |
| volume | Daily cumulative volume | |
| amount | Daily cumulative turnover (options not supported) | |
| open | Open price | |
| high | High price | |
| low | Low price | |
| hourTradingTag | Pre/post market tag (no value during US market hours), values: Pre-market/After-hours | |
| marketStatus | Market status | |
| identifier | Asset identifier (options only) | |
| openInt | Open interest (options only) | |
| mi | p | Minute price |
| mi | a | Minute average price |
| mi | t | Minute time |
| mi | v | Minute volume |
- Best bid/ask quotes
| Field | Description |
|---|---|
| askPrice | Ask price |
| askSize | Ask size |
| askTimestamp | Ask timestamp (Pre/Post-Mkt data not supported) |
| bidPrice | Bid price |
| bidSize | Bid size |
| bidTimestamp | Bid timestamp (Pre/Post-Mkt data not supported) |
Updated 7 days ago