Objects
PortfolioAccount Assets (Prime and Paper Trading Accounts)
Description
Account assets for prime and paper trading accounts, including total assets, P&L, position value, cash, available funds, margin, and leverage.
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 dict keys are S for securities, C for futures, and F for funds; each value is a Segment object |
Segment Assets by Category (Prime and Paper Trading Accounts)
Description
Each Segment groups assets by instrument category, such as securities or futures.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| currency | str | Currency, such as USD, HKD |
| capability | str | Account capability: RegTMargin for a margin account or Cash for a cash account. Margin accounts support margin trading and unlimited intraday trades, with buying power of up to 4x intraday and 2x overnight. |
| category | str | Instrument category: C for commodity futures, S for securities, or F for funds |
| cash_balance | float | Total cash balance across all currencies. Financing and borrowing interest is generally calculated daily based on the number of financing days, accrued throughout the month, and deducted around the fifth day of the following month. The displayed balance does not include accrued interest before that deduction. If the balance is zero before interest is deducted, it may become negative afterward. |
| cash_available_for_trade | float | Funds available for opening positions or subscribing to IPOs. Opening a position includes buying stock or selling stock short with borrowed shares. This value is not the same as available cash. It is calculated as: Available funds = Total assets - US stock option market value - Current total position initial margin - Frozen funds. Position initial margin is Σ(Individual stock position market value × Current opening margin ratio). A positive value means that the account may open positions. Maximum buying power is four times available funds. Example: With $10,000 in total assets, $1,000 in US stock options, $2,000 in Apple stock, a 45% Apple initial margin ratio, and no frozen funds, available funds are 10,000 - 1,000 - 2,000 × 45% = $8,100. |
| cash_available_for_withdrawal | float | Cash amount that can be withdrawn from the current account |
| buying_power | float | Maximum purchase amount. The displayed value is an estimate because each stock has its own margin ratio. Maximum buying power = 4 × Available funds. For example, $100,000 in available funds gives maximum buying power of $400,000. At a 30% Apple initial margin ratio, the account can buy at most $100,000 / 30% = $333,400 of Apple. At a 25% ratio, it can buy at most $100,000 / 25% = $400,000. Margin accounts provide up to 4x buying power intraday and 2x overnight on funds not already used as margin. |
| gross_position_value | float | Sum of all position market values in the account's base currency. Long values are positive and short values are negative. Example 1: $3,000 of Apple + (-$1,000 of Google) = $2,000. Example 2: $10,000 of Apple + $5,000 of long Apple options = $15,000. |
| equity_with_loan | float | Equity with loan value (ELV), used to assess opening and closing positions. Cash account = Cash balance. Margin account = Cash balance + Total securities market value - US stock option market value. Equivalently, ELV = Total assets - US stock options. |
| net_liquidation | float | Total assets (net liquidation value) = Total securities market value + Cash balance + Accrued dividends - Accrued interest. Example: $1,000 cash plus a $1,000 long Apple position = $2,000. For a $1,000 Apple short, securities market value is -$1,000 and cash is $2,000, so total assets are $2,000 + (-$1,000) = $1,000. |
| init_margin | float | Sum of the initial margin requirements for all positions. Positions may be opened only when equity with loan exceeds initial margin. During the 15 minutes before market close, initial and maintenance margin requirements are raised to at least 50% to meet regulatory requirements. |
| maintain_margin | float | Sum of the maintenance margin requirements for all positions. Forced liquidation occurs when equity with loan falls below maintenance margin. During the 15 minutes before market close, initial and maintenance margin requirements are raised to at least 50% to meet regulatory requirements. |
| overnight_margin | float | Required margin starting 15 minutes before market close. Initial and maintenance margin requirements are raised to at least 50% during this period, and Tiger International's overnight margin ratios are above 50%. If equity with loan is below overnight margin, forced liquidation may occur. Overnight margin = Σ(Individual stock overnight maintenance margin). Find individual rates under Stock Details Page > Quote Area > Margin Trading Symbol. Example: With $100,000 in assets, a 40% Apple opening margin ratio, a 20% intraday maintenance margin ratio, and $250,000 of Apple bought intraday, the ratio rises to 50% before close. Overnight margin is $250,000 × 50% = $125,000. Because equity with loan is $100,000, some positions will be liquidated. |
| unrealized_pl | float | Unrealized P&L for held stocks and derivatives = Current price × Number of shares - Position cost |
| realized_pl | float | Realized P&L for stocks and derivatives reduced during the current holding cycle = Σ[(Selling price - Buying price) × Number of shares sold - Commission] |
| excess_liquidation | float | Current excess liquidity measures liquidation risk: lower values indicate greater risk, and a value below 0 triggers liquidation of some positions. Current excess liquidity = Equity with loan - Account maintenance margin. Initial and maintenance margin requirements rise to at least 50% during the 15 minutes before market close. Example: (1) With $10,000 in assets and $12,000 of Apple at a 50% opening and maintenance margin ratio, excess liquidity = 10,000 - 6,000 = 4,000. (2) If the market value falls to 8,000, excess liquidity = (-2,000 + 8,000) - 4,000 = 2,000. (3) Buying another $1,000 of US stock options leaves 2,000 - 1,000 = 1,000. Forced liquidations use market prices, and the broker selects the positions. Monitor risk-control values and leverage indicators. |
| overnight_liquidation | float | Overnight excess liquidity = Equity with loan - Overnight margin. Initial and maintenance margin requirements rise to at least 50% during the 15 minutes before market close. A value below 0 creates a risk that some positions will be liquidated from that point. Forced liquidations use market prices, and the broker selects the positions. Monitor risk-control values and leverage indicators. |
| leverage | float | Leverage measures account financing and risk. Leverage = Sum of absolute securities market values / Total assets. Margin accounts support up to 4x intraday and 2x overnight leverage. Actual leverage depends on historical volatility, liquidity, and risk. Long margin ratios generally range from 25%-100%: 25% corresponds to 4x leverage, while 100% means buying entirely with cash (0x leverage). Short-selling margin may exceed 100%. Find individual rates under Stock Details Page > Quote Area > Margin Trading Symbol. Example: With $100,000 in assets, a 50% Apple ratio (1/50% = 2x) allows $200,000 of Apple; a 200% Google short ratio allows 10/200% = $50,000 of Google; and a 100% Microsoft ratio (1/100% = 1x) allows $100,000 of Microsoft. |
| currency_assets | dict | Assets grouped by trading currency. Each key is a currency and each value is a 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 | Notes |
|---|---|---|---|
| currency | str | Current currency type, common currencies include: USD-US Dollar, HKD-Hong Kong Dollar, SGD-Singapore Dollar, CNH-Chinese Yuan | |
| cash_balance | float | Cash available for trading plus locked cash, such as cash reserved for submitted orders that have not filled | |
| cash_available_for_trade | float | Cash amount currently available for trading in the account | |
| forex_rate | float | Exchange rate from the current currency to base_currency. For example, when base_currency=USD and currency=HKD, forex_rate=0.128 |
PortfolioAccount Assets (Global Account)
Description
Account assets for global accounts, including total assets, P&L, position value, cash, available funds, margin, and leverage.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| account | str | Corresponding account ID |
| summary | tigeropen.trade.domain.account.Account | Account summary aggregated across segments |
| segments | dict | Assets grouped by instrument category; S identifies the securities segment |
Account Summary Assets (Global Account)
Description
Account summary aggregated across instrument categories.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| accrued_cash | float | Current month's accumulated accrued interest payable, updated daily |
| accrued_dividend | float | Accrued dividends. Refers to the cumulative value of all executed but still unpaid dividends |
| available_funds | float | Funds available for trading. Calculation: equity_with_loan - initial_margin_requirement |
| ∆ buying_power | float | Buying power: Estimated how much more USD stock assets you can purchase. Margin accounts have at most four times the buying power of funds (funds not used as margin) intraday. At most two times buying power overnight |
| cash | float | Cash amount |
| currency | str | Currency. See Currency Type |
| cushion | float | Ratio of excess liquidity to total assets, calculation method: excess_liquidity/net_liquidation |
| ∆ day_trades_remaining | int | Remaining day trades for the day, -1 means unlimited |
| equity_with_loan | float | Equity with loan value (equity with loan value assets). Securities Segment: Cash value + Stock value. Futures Segment: Cash value - Maintenance margin |
| excess_liquidity | float | Excess liquidity. Securities segment: equity_with_loan - maintenance_margin_requirement. Futures segment: net_liquidation - maintenance_margin_requirement |
| ∆ gross_position_value | float | Total securities value: Long stock value + Short stock value + Long option value + Short option value |
| initial_margin_requirement | float | Initial margin |
| maintenance_margin_requirement | float | Maintenance margin |
| realized_pnl | float | Today's realized P&L |
| unrealized_pnl | float | Unrealized P&L |
| net_liquidation | float | Total assets (net liquidation value). Securities segment: Cash value + Stock value + Stock option value. Futures segment: Cash value + Mark-to-market P&L |
| ∆ regt_equity | float | Only for Securities Segment, i.e., equity with loan calculated according to Regulation T |
| ∆ regt_margin | float | Only for Securities Segment, i.e., initial margin requirements calculated according to Regulation T |
| ∆ sma | float | Only for Securities Segment. Overnight risk control value, checks account overnight risk about 10 minutes before market close each trading day. Overnight risk control value needs to be greater than 0, otherwise some positions will be forcibly liquidated before market close. If overnight risk control value is below 0 during intraday trading but time hasn't reached 10 minutes before market close, the account will not trigger forced liquidation. |
| timestamp | int | Update time |
SecuritySegment Stock Assets (Global Account)
Description
Stock asset information.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| accrued_cash | float | Current month's accumulated accrued interest payable, updated daily |
| accrued_dividend | float | Accrued dividends. Refers to the cumulative value of all executed but still unpaid dividends |
| available_funds | float | Funds available for trading. Calculation: equity_with_loan - initial_margin_requirement |
| cash | float | Cash |
| equity_with_loan | float | Equity with loan value. Calculation: Cash value + Stock value |
| excess_liquidity | float | Excess liquidity. Calculation: equity_with_loan - maintenance_margin_requirement |
| gross_position_value | float | Total securities value: Long stock value + Short stock value + Long option value + Short option value |
| initial_margin_requirement | float | Initial margin |
| maintenance_margin_requirement | float | Maintenance margin |
| leverage | float | Only for Securities Segment gross_position_value / net_liquidation |
| net_liquidation | float | Total assets (net liquidation value). Calculation: Cash value + Stock value + Stock option value |
| ∆ regt_equity | float | Only for Securities Segment, i.e., equity with loan calculated according to Regulation T |
| ∆ regt_margin | float | Only for Securities Segment, i.e., initial margin requirements calculated according to Regulation T |
| ∆ sma | float | Only for Securities Segment. Overnight risk control value, checks account overnight risk about 10 minutes before market close each trading day. Overnight risk control value needs to be greater than 0, otherwise some positions will be forcibly liquidated before market close. If overnight risk control value is below 0 during intraday trading but time hasn't reached 10 minutes before market close, the account will not trigger forced liquidation. |
| timestamp | int | Update time |
CommoditySegment Futures Assets (Global Account)
Description
Futures asset information.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| accrued_cash | float | Current month's accumulated accrued interest payable, updated daily |
| accrued_dividend | float | Accrued dividends. Refers to the cumulative value of all executed but still unpaid dividends |
| available_funds | float | Funds available for trading. Calculation: equity_with_loan - initial_margin_requirement |
| cash | float | Cash |
| equity_with_loan | float | Equity with loan value. Calculation: Cash value - Maintenance margin |
| excess_liquidity | float | Excess liquidity. Calculation: net_liquidation - maintenance_margin_requirement |
| initial_margin_requirement | float | Initial margin |
| maintenance_margin_requirement | float | Maintenance margin |
| net_liquidation | float | Total assets (net liquidation value). Calculation: Cash value + Mark-to-market P&L |
| timestamp | int | Update time |
MarketValue Assets by Currency (Global Account)
Description
Asset information classified by currency.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| currency | str | Currency unit |
| net_liquidation | float | Total assets (net liquidation value) |
| cash_balance | float | Cash |
| stock_market_value | float | Stock market value |
| option_market_value | float | Option market value |
| warrant_value | float | Warrant market value |
| futures_pnl | float | Mark-to-market P&L |
| unrealized_pnl | float | Unrealized P&L |
| realized_pnl | float | Realized P&L |
| exchange_rate | float | Exchange rate to account base currency |
| net_dividend | float | Net value of dividends payable and receivable |
| timestamp | int | Update time |
Position
Description
Position details, including the contract, quantity, cost, and P&L.
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 | Position quantity (deprecated). When actual position has decimals, need to combine with position_scale |
| position_scale | int | Position quantity decimal offset (deprecated). 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 | Indicates whether the price is a Level 0 delayed quote |
| 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's P&L for the previous day |
| 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 queries return this object. Order placement and modification methods also accept it.
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 |
| parent_id | long | Parent order ID, currently used only for attached orders in the Tiger Trade app |
| order_time | int | Order time, 13-digit timestamp in milliseconds |
| trade_time | int | Time of the most recent order state transition, as a 13-digit millisecond timestamp. For filled orders this is the last fill time; for canceled orders it is the cancellation confirmation time; for new orders it is the submission confirmation time |
| update_time | int | Time any order field was last modified, as a 13-digit millisecond timestamp. Unlike trade_time, this changes for modifications, fills, state transitions, and any other field update |
| expire_time | int | GTD order expiration time, 13-digit timestamp in milliseconds |
| reason | str | Server-provided reason for a failed order operation, including placement rejection, modification failure, or cancellation failure. None or empty on success |
| 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 including commission |
| commission | float | Includes commission, stamp duty, regulatory fees and other charges |
| gst | float | Goods and Services Tax for orders in the AU and SG markets; 0 for other markets |
| realized_pnl | float | Realized P&L calculated using FIFO. Relevant after a closing order fills; generally 0 for opening or unfilled orders |
| trail_stop_price | float | Trailing stop price |
| limit_price | float | Limit order price |
| aux_price | float | In stop orders, represents the trigger price for stop order. In trailing stop orders, represents the trailing spread |
| trailing_percent | float | Trailing stop order - percentage, range 0-100 |
| 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 / 'TRAIL' trailing stop order |
| time_in_force | str | Time in force: DAY for a day order, GTC for good-till-canceled, or GTD for good-till-date (requires expire_time) |
| outside_rth | bool | Allows pre-market and after-hours trading for US stocks |
| trading_session_type | str | Trading session type: RTH, PRE_RTH_POST, OVERNIGHT, FULL, HK_AUC, HK_CTS, or HK_AUC_CTS |
| status | str | Order status. See Order Status |
| filled_scale | int | Decimal offset for filled; for example, filled=111 and filled_scale=2 represents 1.11 |
| is_open | bool | Indicates whether this is an opening order |
| can_modify | bool | Indicates whether the order can currently be modified |
| liquidation | bool | Indicates whether forced liquidation triggered the order |
| latest_price | float | Latest contract price populated at query time for reference |
| algo_strategy | str | Algorithmic strategy, such as TWAP or VWAP; None for regular orders |
| algo_params | AlgoParams | Algorithmic order parameters. See AlgoParams |
| charges | list | Itemized fee details as Charge objects |
| source | str | Order source, such as OpenApi |
| attr_desc | str | Additional description of the order |
| contract | Contract | Contract object. See Contract |
tigeropen.trade.domain.order.Charge Object Properties
| Property | Type | Description |
|---|---|---|
| category | str | Fee category (TIGER/THIRD_PARTY) |
| category_desc | str | Fee category description: Tiger Charge; Third Parties |
| 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 |
Constructing an Order
Use tigeropen.common.util.order_utils to construct order objects locally. These utilities accept the most common parameters. To set other parameters, construct the order first and then update 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
trail_order, # Trailing stop order
order_leg) # Attached order
contract = stock_contract('AAPL', 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(account, contract, action, quantity)Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Prime, global, or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Limit Order
limit_order(account, contract, action, quantity, limit_price)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Prime, global, or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Stop Order
stop_order(account, contract, action, quantity, aux_price)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Prime, global, or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Stop-Limit Order
stop_limit_order(account, contract, action, quantity, limit_price, aux_price)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Prime, global, or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Trailing Stop Order
trail_order(account, contract, action, quantity, trailing_percent=None, aux_price=None)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Prime, global, or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Attached Order
order_leg(leg_type, price, time_in_force='DAY', outside_rth=None)
Parameters
| Parameter Name | Type | Description |
|---|---|---|
| leg_type | str | Attached order type: PROFIT for a take-profit order or LOSS for a stop-loss order |
| price | float | Attached order price |
| time_in_force | str | Attached order time in force: DAY or GTC (good-till-canceled) |
| outside_rth | bool | Allows the attached order to trade during pre-market and after-hours sessions for US stocks |
Returns
OrderLeg object tigeropen.trade.domain.order.OrderLeg
Auction Limit Order
auction_limit_order(account, contract, action, quantity, limit_price, time_in_force)
Parameters
| Parameter Name | Type | Description |
|---|---|---|
| account | str | Prime or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Auction Market Order
auction_market_order(account, contract, action, quantity, time_in_force)
Parameters
| Parameter Name | Type | Description |
|---|---|---|
| account | str | Prime or paper trading account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
Transaction
tigeropen.trade.domain.order.Transaction
Description
Execution record for an order.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| account | str | Account ID |
| order_id | int | Order ID |
| contract | Contract | Contract object |
| id | int | Transaction record ID |
| action | str | Order direction |
| filled_quantity | int | Filled quantity |
| filled_quantity_scale | int | Decimal offset for the filled quantity; defaults to 0. filled_quantity and filled_quantityScale together represent the actual quantity. For example, qty=111 and scale=2 represent 111*10^(-2)=1.11 |
| filled_price | float | Fill price |
| filled_amount | float | Filled amount |
| transacted_at | str | Execution time |
OrderLeg Attached Order
tigeropen.trade.domain.order.OrderLeg
Description
An attached order submitted with the primary order.
Object Properties
| Property | Type | Description |
|---|---|---|
| leg_type | str | Attached order type: PROFIT for a take-profit order or LOSS for a stop-loss order |
| price | float | Attached order price |
| time_in_force | str | Attached order time in force: DAY or GTC (good-till-canceled) |
| outside_rth | bool | Allows the attached order to trade during pre-market and after-hours sessions for US stocks |
AlgoParams Algorithmic Order Parameters
tigeropen.trade.domain.order.AlgoParams
Description
Parameters for VWAP and TWAP orders.
Object Properties
| Property | Type | Description |
|---|---|---|
| start_time | str/int | Effective start time (time string or timestamp, TWAP and VWAP only), e.g. '2020-11-19 23:00:00' or 1640159945678 |
| end_time | str/int | Expiry time (time string or timestamp, TWAP and VWAP only) |
| no_take_liq | bool | Minimizes trading frequency for VWAP orders |
| allow_past_end_time | bool | Allows fills after the end time for TWAP and VWAP orders |
| participation_rate | float | Participation rate (VWAP only, 0.01-0.5) |
Contract
tigeropen.trade.domain.contract.Contract source
Description
A contract identifies a tradable instrument, such as a stock, option, or futures contract. For example, the symbol TIGR and market='US' identify Tiger Brokers stock. Options and futures require additional identifying fields. The Python SDK stores this information in tigeropen.trade.domain.contract.Contract, which can be passed to utilities that construct Order objects.
Most contracts use the following fields:
- Symbol: US and UK symbols are generally alphabetic, while Hong Kong and A-share symbols are numeric. For example, Tiger Brokers' symbol is
TIGR. - Security type: Common values include
STK(stock),OPT(option),FUT(futures), andCASH(forex). Tiger Brokers stock usesSTK. - Currency: Common values include
USDandHKD. - Exchange: Stock orders are generally routed automatically and do not require this field. Futures contracts require it.
These four fields identify most stocks, CFDs, indices, and forex pairs. Options and futures require additional fields. The following examples construct common contract types.
Stocks
from tigeropen.common.util.contract_utils import stock_contract
contract = stock_contract(symbol='TIGR', currency='USD')
contract1 = stock_contract(symbol='00700', currency='HKD')Options
from tigeropen.common.util.contract_utils import option_contract, option_contract_by_symbol
contract = option_contract(identifier='AAPL 190118P00160000')
contract = option_contract_by_symbol('JD', expiry='20211015', strike=45.0, put_call='PUT', currency='USD')
Futures
from tigeropen.common.util.contract_utils import future_contract
contract = future_contract(symbol='CL', currency='USD', expiry='20190328', multiplier=1.0, exchange='SGX')Hong Kong Warrants
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='HKD')Hong Kong CBBC
from tigeropen.common.util.contract_utils import iopt_contract_by_symbol
contract = iopt_contract_by_symbol('02318', '20200420', 87.4, 'CALL', local_symbol='63379', currency='HKD')The following table lists the available fields.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| identifier | str | Unique identifier. For stocks, this is the symbol. For options, it is a 21-character identifier such as AAPL 220729C00150000. Futures also use a contract identifier |
| symbol | str | Stock symbol; for an option, the symbol of the underlying asset |
| sec_type | str | Security type, such as STK for stock, OPT for option, FUT for futures, WAR for warrant, or IOPT for CBBC; defaults to STK |
| name | str | Contract name |
| currency | str | Currency, USD/HKD/CNH |
| exchange | str | Exchange |
| expiry | str | Options and futures only, option or futures expiry date |
| strike | float | Options only, option strike price |
| multiplier | float | Quantity per lot |
| put_call | str | Options only, option direction, CALL or PUT |
| local_symbol | str | Global account only, Hong Kong stocks used to identify warrants and CBBC |
| short_margin | float | Short margin ratio (deprecated, please use short_initial_margin instead) |
| short_initial_margin | float | Short initial margin ratio in the range (0, 1]; for example, 0.6 means 60% |
| short_maintenance_margin | float | Short maintenance margin ratio in the range (0, 1], typically below short_initial_margin. Available for prime/paper accounts but not global-account contracts |
| short_fee_rate | float | Annualized short-borrow fee rate; for example, 0.03 means 3% |
| shortable | bool | Indicates that the borrow pool currently has inventory (shortable_count > 0). This does not indicate that the account has short-selling permission |
| long_initial_margin | float | Long initial margin ratio in the range (0, 1]; for example, 0.3 means a 30% requirement |
| long_maintenance_margin | float | Long maintenance margin ratio in the range (0, 1], typically below long_initial_margin |
| contract_month | str | Contract month, e.g., 202201, represents January 2022 |
| primary_exchange | str | Stock listing exchange |
| market | str | Market, such as US, HK, or CN |
| min_tick | float | Minimum tick size. Fixed for futures; for stocks it varies by price range and may be None, so prefer tick_sizes |
| tick_sizes | list | Tick-size rules by price range. Each item includes begin, end, tickSize, and interval type (OPEN, OPEN_CLOSED, CLOSED, or CLOSED_OPEN) |
| trading_class | str | Contract trading class name |
| continuous | bool | Futures only. Indicates whether this is a continuous contract |
| status | int | Tradability status: 0 for not tradable, 1 for tradable |
| trade | bool | Futures only. Indicates whether the contract is tradable |
| last_trading_date | str | Futures only, last trading date, e.g., '20211220', represents December 20, 2021 |
| first_notice_date | str | Futures only, first notice date, contracts cannot open long positions after first notice date. Existing long positions will be forcibly closed before the first notice date (usually three trading days prior), e.g., '20211222', represents December 22, 2021 |
| last_bidding_close_time | int | Futures only, bidding close timestamp |
| is_etf | bool | Indicates whether the contract is an ETF |
| etf_leverage | int | ETF leverage multiple; present only for ETFs |
| discounted_day_initial_margin | float | Futures only. Discounted intraday initial margin |
| discounted_day_maintenance_margin | float | Futures only. Discounted intraday maintenance margin |
| discounted_time_zone_code | str | Futures only, time zone for the intraday margin discount period, such as America/New_York |
| discounted_start_at | int | Futures only, intraday margin discount start time as a millisecond timestamp |
| discounted_end_at | int | Futures only, intraday margin discount end time as a millisecond timestamp |
| lot_size | float | Units per lot, such as 100 shares for a Hong Kong stock, 1 share for a US stock, or 100 shares for an A-share. Order quantities usually must be multiples of this value except for fractional-share trading |
| support_overnight_trading | bool | Indicates whether the contract supports overnight trading |
Warning
print(contract)displays only some attributes. Useprint(contract.to_str())to display all attributes.
Retrieve Contracts Through the API
Use get_contract or get_contracts to retrieve contract information.
Parameters:
| Parameter | Required | Description |
|---|---|---|
| symbol | Yes | Contract symbol, such as 00700 or AAPL |
| sec_type | Yes | Contract type, such as SecurityType.STK or SecurityType.OPT |
| currency | No | Currency, such as Currency.USD or Currency.HKD |
| exchange | No | Exchange, such as SMART or SEHK |
| expiry | No | Expiration date in yyyyMMdd format; required for options |
| strike | No | Strike price, required when trading options |
| put_call | No | CALL/PUT, required when trading options |
| secret_key | No | Institutional trader key; available only to institutional users and configured in client_config |
Returns
get_contract returns a Contract; get_contracts returns a list of Contract objects. Their properties are listed above.
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.common.consts import SecurityType
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account', secret_key='institutional trader exclusive key')
trade_client = TradeClient(client_config)
# Get stock contract
contract = trade_client.get_contract('FB', sec_type=SecurityType.STK)
contracts = trade_client.get_contracts(['AAPL', 'TSLA'], sec_type=SecurityType.STK)
# Get futures contract
fut_contract = trade_client.get_contract('CL', sec_type=SecurityType.FUT)
# Get option contract
opt_contract = trade_client.get_contract('SPY', sec_type=SecurityType.OPT, expiry='20231215', strike=435.0, put_call='CALL')MarketStatus
tigeropen.quote.domain.market_status.MarketStatus
Description
Trading status for a market.
Object Properties
| Property | Type | Description |
|---|---|---|
| market | str | Market. (US: US stocks, CN: A-shares, HK: Hong Kong stocks) |
| trading_status | str | Market trading status code: NOT_YET_OPEN, PRE_HOUR_TRADING, TRADING, MIDDLE_CLOSE, POST_HOUR_TRADING, CLOSING, OVERNIGHT_TRADING, EARLY_CLOSED, or MARKET_CLOSED |
| status | str | Market status description (not yet open, trading, closed, etc.) |
| open_time | datetime.datetime | Most recent open time |
OptionFilter
tigeropen.quote.domain.filter.OptionFilter
Description
Filters for an option chain request.
Option-chain Greeks are deprecated
Greek-related option-chain filters
delta,gamma,theta,vega, andrhoare Deprecated. Their values are updated daily and are not timely enough for intraday use. Do not use them for real-time trading decisions. Use Option Calculation Tools with current market inputs instead.
Object Properties
| Parameter | Type | Required | Description |
|---|---|---|---|
| implied_volatility | float | No | Implied volatility, which reflects the market's expectation of future price volatility |
| in_the_money | bool | No | Indicates whether the option is in the money |
| open_interest | int | No | Number of open contracts held by market participants at the end of each trading day; an indicator of market depth and liquidity |
| delta | float | No | Deprecated. Daily-updated Delta filter; not suitable for intraday use |
| gamma | float | No | Deprecated. Daily-updated Gamma filter; not suitable for intraday use |
| theta | float | No | Deprecated. Daily-updated Theta filter; not suitable for intraday use |
| vega | float | No | Deprecated. Daily-updated Vega filter; not suitable for intraday use |
| rho | float | No | Deprecated. Daily-updated Rho filter; not suitable for intraday use |
Order Changes
| Field | Description |
|---|---|
| id | Order ID |
| account | Account |
| symbol | Position symbol, e.g., 'AAPL', '00700', 'ES', 'CN' |
| expiry | Options, warrants, CBBC only |
| strike | Options, warrants, CBBC only |
| right | Options, warrants, CBBC only |
| identifier | Asset identifier. Stock identifier is same as symbol. Futures include contract month, e.g., 'CN2201' |
| multiplier | Quantity per lot, futures, options, warrants, CBBC only |
| action | Buy/sell direction. BUY for buy, SELL for sell |
| market | Market. US, HK |
| currency | Currency. USD US Dollar, HKD Hong Kong Dollar |
| segType | Classification by trading type. S for stocks, C for futures |
| secType | STK Stocks, OPT Options, WAR Warrants, IOPT CBBC, CASH FOREX, FUT Futures, FOP Future Options |
| orderType | Order type. 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order/'TRAIL' trailing stop order |
| isLong | Indicates whether this is a 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 | Allows pre-market and after-hours trading for US stocks |
| canModify | Indicates whether the order can be modified |
| canCancel | Indicates whether the order can be canceled |
| liquidation | Indicates whether this is 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 symbol |
| expiry | Expiry date, options, warrants, CBBC only |
| strike | Strike price, options, warrants, CBBC only |
| right | Option direction PUT/CALL, options, warrants, CBBC only |
| identifier | Asset identifier |
| multiplier | Lot size, options, warrants, CBBC only |
| market | Trading market |
| currency | Currency type |
| segType | Classification by trading type. S for stocks, C for futures |
| 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, C for futures |
| 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 symbol | |
| 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/futures 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: Trading, WaitingOpen, OpeningAuction, InAuction, ClosingAuction, Closed, MiddayBreak, AfterHoursTrading, AfterHoursMatching, ExtendedTrading, PreMarket, or Overnight | |
| identifier | Asset identifier (options only) | |
| openInt | Open interest (options only) | |
| tradeTime | Trade time (futures only) | |
| preSettlement | Previous settlement price (futures only) | |
| minTick | Minimum tick size (futures only) | |
| mi | p | Minute price |
| mi | a | Minute average price |
| mi | t | Minute time |
| mi | v | Minute volume |
| mi | o | Minute open price (futures only) |
| mi | h | Minute high price (futures only) |
| mi | l | Minute low price (futures only) |
- 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 2 days ago
