Objects
PortfolioAccount Assets (Comprehensive/Simulation Account)
Description
Account asset object, applicable to comprehensive/simulation 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, 'C' for futures, with values being |
Segment Assets by Category (Comprehensive/Simulation Account)
Description
Assets are divided by stock/futures trading instruments, with each part being a Segment.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| currency | str | Currency, such as USD, HKD |
| capability | str | Account type, margin account: RegTMargin, cash account: Cash. Margin accounts support margin trading, unlimited T+0 trading times, maximum buying power of up to 4x intraday and 2x overnight. |
| category | str | Trading instrument category C: (Commodities futures), S: (Securities stocks), F: (Funds) |
| cash_balance | float | Cash amount. The cash amount is the sum of current cash balances in all currencies. If your current account has generated financing or borrowing, please note that interest is generally calculated daily and settled monthly, specifically calculated based on financing days. Accumulated daily, unified deduction around the 5th of the following month, so before deducting interest, the cash balance users see has not deducted interest. If the cash balance is zero before deducting interest, there may be a debt after deduction, i.e., the cash balance becomes negative. |
| cash_available_for_trade | float | Available funds. Available funds are used to check whether opening positions or IPO subscriptions are possible. Opening positions refers to trading behaviors such as buying stocks long, selling stocks short through margin lending, etc. Note that available funds do not equal available cash. It is a value calculated using total assets, option position market value, frozen funds, and initial margin. When available funds are greater than 0, it means the account can open positions. Available funds × 4 is the account's maximum available buying power. Algorithm: Available funds = Total assets - US stock option market value - Current total position initial margin - Frozen funds. The initial margin algorithm is ∑(Individual stock position market value × Current stock opening margin ratio). Example: Tiger's current account total assets are $10,000, holding $1,000 US stock options, holding Apple with total market value of $2,000, Apple's initial margin ratio is currently 45%, no frozen funds, Tiger's available funds = 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 buying power. Maximum buying power is the account's maximum available purchase amount. The maximum buying power value can be used to estimate how much stock the account can buy at most, but since each stock has different maximum leverage multiples, the actual buying power available when purchasing individual stocks must be calculated based on the specific stock's margin ratio. Algorithm: Maximum buying power = 4 × Available funds. Example: Tiger's available funds are $100,000, then Tiger's maximum buying power is $400,000. If Apple's current stock price is $250 per share and Apple's initial margin ratio is 30%, Tiger can buy at most $100,000/30% = $333,400 of Apple. If Apple's initial margin ratio is 25%, Tiger can buy at most $100,000/25% = $400,000 of Apple. Margin accounts have at most four times the buying power of funds (funds not used as margin) intraday and at most two times buying power overnight |
| gross_position_value | float | Total securities value, which is the sum of the total market value of securities held in the account, i.e., the total market value of all positions. Algorithm: Sum of all position market values; Note: All position market values are calculated in the main currency; Example 1: If Tiger simultaneously holds Apple worth $3,000 (i.e., long) and Google worth -$1,000 (i.e., short), Tiger's total securities value = $3,000 Apple + (-$1,000 Google) = $2,000; Example 2: Tiger holds Apple worth $10,000 and Apple long options worth $5,000, Tiger's total securities value = 10,000 + 5,000 = $15,000 |
| equity_with_loan | float | Total equity with loan value, i.e., ELV. ELV is a data indicator used to calculate opening and closing positions; Algorithm: Cash account = Cash balance, Margin account = Cash balance + Total securities market value - US stock option market value; ELV = Total assets - US stock options |
| net_liquidation | float | Total assets (net liquidation value). Total assets is the sum of our account's net liquidation cash balance and total securities market value, usually used to indicate how many assets are currently in the account. Algorithm: Total assets = Total securities market value + Cash balance + Accrued dividends - Accrued interest; Example: Tiger's account has $1,000 cash, holds Apple positions worth $1,000 (i.e., long Apple), no pending dividends and financing interest and undeducted interest, then Tiger's total assets = Cash 1,000 + Position value 1,000 = $2,000. If Tiger's account has $1,000 cash and shorts Apple worth $1,000, at this time the total securities market value is -$1,000, cash is $2,000, user's total assets = Cash 2,000 + (Position market value -1,000), total account assets amount to $1,000. |
| 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 initial margin. To meet regulatory margin requirements, we will increase initial margin and maintenance margin requirements to a minimum of 50% during the 15 minutes before market close. |
| 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 loan is less than maintenance margin. To meet regulatory margin requirements, we will increase initial margin and maintenance margin requirements to a minimum of 50% during the 15 minutes before market close. |
| overnight_margin | float | Overnight margin. Overnight margin is the margin required when checking accounts starting 15 minutes before market close. To meet regulatory margin requirements, we will increase initial margin and maintenance margin requirements to a minimum of 50% during the 15 minutes before market close. Tiger International's overnight margin ratios are all above 50%. If the account's equity with loan is below overnight margin, the account risks forced liquidation during the 15 minutes before market close. Algorithm: ∑(Individual stock overnight maintenance margin). Individual stock maintenance margin rates can be queried by users at "Stock Details Page - Quote Area - Click Margin Trading Symbol". Example: Tiger's account total assets are $100,000, Apple's opening margin ratio is 40%, intraday maintenance margin is 20%, intraday full position buying Apple totaling $250,000, during the 15 minutes before market close (overnight period) maintenance margin ratio will be raised to 50%, at this time the user's overnight margin is: $250,000 × 50% = $125,000, the user's equity with loan is $100,000, which is less than $125,000, the user will be liquidated for some stocks. |
| unrealized_pl | float | Position profit and loss. Definition: Unrealized profit and loss amount of held individual stocks and derivatives; Algorithm: Current price × Number of shares - Position cost |
| 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. Realized profit and loss = Σ[(Selling price - Buying price) × Number of shares sold - Commission |
| excess_liquidation | float | Current excess liquidity. Current excess liquidity is an indicator measuring the current account's potential liquidation risk. The lower the current excess liquidity, the higher the account's liquidation risk. When it is less than 0, some positions will be forcibly liquidated. The specific algorithm is: Current excess liquidity = Equity with loan - Account maintenance margin. To meet regulatory margin requirements, we will increase initial margin and maintenance margin requirements to a minimum of 50% during the 15 minutes before market close. 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. (2) As the stock falls, assume the stock market value drops to 8,000, at this time current excess liquidity = Total assets (-2,000 + 8,000) - Account maintenance margin 4,000 = 2,000. (3) At this time the user bought another $1,000 US stock options, then the account's current excess liquidity remains 2,000 - 1,000 = 1,000. If your account is forcibly liquidated, it will be executed at market price during forced liquidation, and the liquidated stock targets are decided by the broker. Please pay attention to risk control values and leverage indicators. |
| overnight_liquidation | float | Overnight excess liquidity. Overnight excess liquidity refers to the value calculated by Equity with loan - Overnight margin. To meet regulatory margin requirements, we will increase initial margin and maintenance margin requirements to a minimum of 50% during the 15 minutes before market close. If the account's overnight excess liquidity is below 0, there is a risk of forced liquidation of some positions starting 15 minutes before market close. If your account is forcibly liquidated, it will be executed at market price during forced liquidation, and the liquidated stock targets are decided by the broker. Please pay attention to risk control values and leverage indicators. |
| leverage | float | Leverage. Leverage is an important indicator measuring account risk level, which can help users quickly understand account financing ratio and risk level; Algorithm: Leverage = Sum of absolute values of securities market values / Total assets; Note 1: Margin accounts have maximum leverage of 4x intraday and 2x overnight; Note 2: Tiger considers historical volatility, liquidity and risk factors, and not every stock can be bought with 4x leverage. Generally, long margin ratios range from 25%-100%. Stocks with margin ratio equal to 25% can be understood as 4x leverage buying, stocks with margin ratio equal to 100% can be understood as 0x leverage buying, i.e., buying entirely with cash. Note that short selling margin may exceed 100%. Note 3: Individual stock margin ratios can be queried by users at "Stock Details Page - Quote Area - Click Margin Trading Symbol"; Example: Tiger's account total assets $100,000, wants to buy Apple, Apple's current individual stock long initial margin ratio is 50% (1/50% = 2x leverage), Tiger can buy at most $200,000 market value of Apple stock; Tiger wants to short Google, Google's short selling margin ratio is 200%, Tiger can short at most 10/200% = $50,000 of Google stock; Tiger wants to buy Microsoft, Microsoft's initial margin is 100% (1/100% = 1x leverage), Tiger can buy at most $100,000 of Microsoft stock |
| 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 (Comprehensive/Simulation Account)
Description
Assets classified by currency.
Object Properties
| Property Name | Type | Description |
|---|---|---|
| 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 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 |
PortfolioAccount Assets (Global Account)
Description
Account asset object, applicable to global 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 |
| summary | tigeropen.trade.domain.account.Account | Account summary information, statistics of segments |
| segments | dict | Account information classified by trading instrument. Has two keys: 'S' corresponds to securities, value is a |
Account Summary Assets (Global Account)
Description
Account summary information for various trading instrument assets.
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 | Available funds (available for trading). Calculation method: 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, meaning refers to enumeration parameters - Currency |
| 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: Calculation method: equity_with_loan - maintenance_margin_requirement - Futures Segment: Calculation method: 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 profit and loss |
| unrealized_pnl | float | Floating profit and loss |
| net_liquidation | float | Total assets (net liquidation value). Securities Segment: Cash value + Stock value + Stock option value. Futures Segment: Cash value + Mark-to-market profit and loss |
| ∆ 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 | Available funds (available for trading). Calculation method: equity_with_loan - initial_margin_requirement |
| cash | float | Cash |
| equity_with_loan | float | Equity with loan value (equity with loan value assets). Calculation method: Cash value + Stock value |
| excess_liquidity | float | Excess liquidity. Calculation method: 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 method: 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 | Available funds (available for trading). Calculation method: equity_with_loan - initial_margin_requirement |
| cash | float | Cash |
| equity_with_loan | float | Equity with loan value (equity with loan value assets) Calculation method: Cash value - Maintenance margin |
| excess_liquidity | float | Excess liquidity. Calculation method: 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 method: Cash value + Mark-to-market profit and loss |
| 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 profit and loss |
| unrealized_pnl | float | Unrealized profit and loss |
| realized_pnl | float | Realized profit and loss |
| 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
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 | 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 | 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 |
| parent_id | long | Parent order ID, currently only used for attached orders in TigerTrade App |
| 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 |
| 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' 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: 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 |
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
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
market_order(account, contract, action, quantity)Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Trading account, can use integrated account, global 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 integrated account, global 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 integrated account, global 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 integrated account, global account or paper account |
| contract | tigeropen.trade.domain.contract.Contract | Contract to trade |
Returns
Order object
trail_order Trailing Stop Order
trail_order(account, contract, action, quantity, trailing_percent=None, aux_price=None)
Parameters
| Parameter | Type | Description |
|---|---|---|
| account | str | Trading account, can use integrated account, global 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 integrated account or simulation 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 integrated account or simulation 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 |
AlgoParams Algorithm Order Parameters
tigeropen.trade.domain.order.AlgoParams
Description
Algorithm order (VWAP/TWAP) parameter object
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 | Whether to minimize trading frequency (VWAP orders only) |
| allow_past_end_time | bool | Whether to allow completion of trades after expiry time (TWAP and VWAP only) |
| participation_rate | float | Participation rate (VWAP only, 0.01-0.5) |
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. For example, to purchase Tiger Brokers stock, it can be uniquely identified by the ticker symbol TIGR and market information (i.e., market='US', US market). Similarly, when purchasing options or futures products, other identifying fields may be needed. Through contract information, we can uniquely determine an underlying asset when placing orders or obtaining quotes. In the Open API 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, futures contracts, etc. Most contracts include the following elements:
- Symbol - Generally, US and UK contract codes are alphabetic, while Hong Kong and A-share contract codes are numeric, e.g., Tiger Brokers' symbol is TIGR.
- Security Type - Common contract types include: STK (stock), OPT (option), FUT (futures), CASH (forex), e.g., Tiger Brokers stock contract type is STK.
- Currency - Common currencies include USD (US Dollar), HKD (Hong Kong Dollar).
- Exchange - STK type contracts generally don't use the exchange field as orders are automatically routed, futures contracts use the exchange field.
Most stocks, CFDs, indices, or forex pairs can be uniquely determined by these four attributes. Due to their nature, more complex contracts (such as options and futures) 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='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')See below for specific fields and construction methods
Object Properties
| Property Name | Type | Description |
|---|---|---|
| identifier | str | Unique identifier, stock identifier is same as symbol, option is 21-character identifier, e.g., 'AAPL 220729C00150000', futures identifier |
| symbol | str | Stock ticker, option contract symbol is the underlying asset code |
| sec_type | str | STK stock/OPT option/FUT futures/WAR warrant/IOPT CBBC etc., default 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 |
| short_maintenance_margin | float | Short maintenance margin ratio (has value for integrated accounts, no value for global account contracts) |
| short_fee_rate | float | Short fee rate |
| shortable | int | Short pool remaining |
| long_initial_margin | float | Long initial margin |
| long_maintenance_margin | float | Long maintenance margin |
| contract_month | str | Contract month, e.g., 202201, represents January 2022 |
| primary_exchange | str | Stock listing exchange |
| market | str | Market /US/HK/CN |
| min_tick | float | Minimum tick size |
| tickSizes | list | Stocks only, minimum tick size price ranges, i.e., when order price is in the begin and end range, must meet tickSize requirements, begin: left price range, end: right price range, type: range type OPEN/OPEN_CLOSED/CLOSED/CLOSED_OPEN (open/left open right closed/closed/left closed right open), tickSize: minimum price unit. Example: [{"begin":"0","end":"1","tickSize":1.0E-4,"type":"CLOSED"},{"begin":"1","end":"Infinity","tickSize":0.01,"type":"OPEN"}] |
| trading_class | str | Contract trading class name |
| status | str | Contract status |
| continuous | bool | Futures only, whether it's a continuous contract |
| trade | bool | Futures only, whether it's 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 | Whether it's an ETF |
| etf_leverage | int | ETF leverage multiple, exists only when contract is ETF |
| discounted_day_initial_margin | float | Futures only, Intraday initial margin discount |
| discounted_day_maintenance_margin | float | Futures only, Intraday maintenance margin discount |
| discounted_time_zone_code | float | Futures only, Intraday margin discount period time zone |
| discounted_start_at | float | Futures only, Intraday margin discount start time |
| discounted_end_at | float | Futures only, Intraday margin discount end time |
| lot_size | float | Minimum quantity of assets that can be traded in a single transaction |
| support_overnight_trading | bool | Whether supports overnight trading |
Warningprint will only display partial attributes, use
print(contract.to_str())to print all attributes
Get via API
Contract objects can be queried through the following methods:
Get contract information get_contract/get_contracts
Parameters:
| Parameter | Required | Description |
|---|---|---|
| symbol | Yes | Contract code e.g., 00700/AAPL |
| sec_type | Yes | Contract type e.g., SecurityType.STK/SecurityType.OPT |
| currency | No | Currency e.g., Currency.USD/Currency.HKD |
| exchange | No | Exchange e.g., SMART/SEHK |
| expiry | No | Expiry date, required when trading options yyyyMMdd |
| strike | No | Strike price, required when trading options |
| put_call | No | CALL/PUT, required when trading options |
| secret_key | No | Institutional trader key, for institutional users only, needs to be configured in client_config |
Returns
get_contract returns Contract object; get_contracts returns list of Contract objects. Object properties see description section above
Example
from tigeropen.trade.trade_client import TradeClient
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 Market Status
tigeropen.quote.domain.market_status.MarketStatus
Description
Market trading status
Object Properties
| Property | Type | Description |
|---|---|---|
| market | str | Market. (US: US stocks, CN: Shanghai/Shenzhen, HK: Hong Kong 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, 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, option price changes approximately theta |
| vega | float | No | Vega, reflects the impact of volatility on option price changes. For every 1% change in volatility, 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, option price changes approximately rho |
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 | 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 integrated 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, 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 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/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 | |
| 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 9 days ago
