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 NameTypeDescription
accountstrCorresponding account ID
update_timestampintUpdate time, 13-digit timestamp in milliseconds
segmentstigeropen.trade.domain.prime_account.SegmentAccount 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.
Account's maximum available purchase amount. Margin accounts have at most four times the buying power of available funds (funds not used as margin) intraday.

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.
The minimum amount of money required in your account if you want to hold a margin trade after the market closes.

unrealized_pl

float

Position profit and loss.
The unrealized profit and loss amount of held individual stocks and derivatives.

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. 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 NameTypeDescription
currencystrCurrent currency type, common currencies include: USD-US Dollar
cash_balancefloatCash 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_tradefloatCash 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 NameTypeDescription
accountstrCorresponding account ID
contracttigeropen.trade.domain.contract.ContractContract object
position_qtyfloatPosition quantity
quantityint(Deprecated) Position quantity. When the actual position has decimals, need to combine with position_scale
position_scaleint(Deprecated) Position quantity decimal offset. If position=11123, positionScale=2, then actual position=11123*10^(-2)=111.23
average_costfloatAverage cost including commission
market_valuefloatMarket value
salable_qtyfloatSellable quantity
average_cost_of_carryfloatCumulative position cost (A-share calculation method)
market_pricefloatMarket price
is_level0_pricebooleanWhether it is lv0 (delayed) quotes
realized_pnlfloatRealized P&L under FIFO mode
unrealized_pnlfloatUnrealized P&L
unrealized_pnl_by_cost_of_carryfloatUnrealized P&L (A-share calculation method)
unrealized_pnl_percent_by_cost_of_carryfloatUnrealized P&L percentage (A-share calculation method)
today_pnlfloatToday's P&L amount
today_pnl_percentfloatToday's P&L percentage
yesterday_pnlfloatFund yesterday's P&L
last_close_pricefloatLast 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 NameTypeDescription
accountstrAccount to which the order belongs
idlongGlobal order ID
order_idintAccount auto-increment order number, deprecated
order_timeintOrder time, 13-digit timestamp in milliseconds
trade_timeintOrder status update time. For filled orders, represents fill time; for cancelled orders, represents successful cancellation time, 13-digit timestamp in milliseconds
update_timeintOrder update time. When order properties change (such as order modification), this time will be updated, 13-digit timestamp in milliseconds
expire_timeintGTD order expiration time, 13-digit timestamp in milliseconds
reasonstrWhen order placement fails, returns description of failure reason
actionstrTrade direction, 'BUY' / 'SELL'
quantityintOrder quantity
quantity_scaleintOrder 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_amountfloatTotal order amount, None when ordering by shares
filled_cash_amountfloatFilled amount, None when ordering by shares
refund_cash_amountfloatRefund amount, equals total order amount minus filled amount. None when ordering by shares or order is not terminated
filledintFilled quantity
avg_fill_pricefloatAverage fill price excluding commission
commissionfloatIncludes commission, stamp duty, regulatory fees and other charges
gstfloatTax - Goods and Service Tax
realized_pnlfloatRealized P&L
limit_pricefloatLimit order price
aux_pricefloatIn stop orders, represents the trigger price for stop order.
percent_offsetfloat<This field is not used>
order_typestrOrder type, 'MKT' market order / 'LMT' limit order / 'STP' stop order / 'STP_LMT' stop limit order
time_in_forcestrTime in force, 'DAY' day order / 'GTC' good till cancelled / 'GTD' good till date (requires additional expire_time)
outside_rthboolWhether to support pre-market and after-hours trading, US stocks only
trading_session_typestrNight trading session
contractContract

tigeropen.trade.domain.order.Charge Object Properties

PropertyTypeDescription
categorystrFee category (TIGER/THIRD_PARTY)
category_descstrFee category description: TradeUP Charges; Third Party Fees
totalfloatTotal fees for current category
detailstigeropen.trade.domain.order.ChargeDetailFee details

tigeropen.trade.domain.order.ChargeDetail Object Properties

PropertyTypeDescription
typestrFee type: SETTLEMENT_FEE/STAMP_DUTY/TRANSACTION_LEVY/EXCHANGE_FEE/FRC_TRANSACTION_LEVY
type_descstrFee type description: Settlement Fee; Stamp Duty; Transaction Levy; Exchange Fee; AFRC Transaction Levy
original_amountfloatFee amount
after_discount_amountfloatFee 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

ParameterTypeDescription
accountstrTrading account, can use prime account or paper account
contracttigeropen.trade.domain.contract.ContractContract to trade

Returns

Order object


limit_order Limit Order

limit_order(account, contract, action, quantity, limit_price)

Parameters

ParameterTypeDescription
accountstrTrading account, can use prime account or paper account
contracttigeropen.trade.domain.contract.ContractContract to trade

Returns

Order object


stop_order Stop Order

stop_order(account, contract, action, quantity, aux_price)

Parameters

ParameterTypeDescription
accountstrTrading account, can use prime account or paper account
contracttigeropen.trade.domain.contract.ContractContract to trade

Returns

Order object


stop_limit_order Stop Limit Order

stop_limit_order(account, contract, action, quantity, limit_price, aux_price)

Parameters

ParameterTypeDescription
accountstrTrading account, can use prime account or paper account
contracttigeropen.trade.domain.contract.ContractContract to trade

Returns

Order object


order_leg Additional Order

order_leg(leg_type, price, time_in_force='DAY', outside_rth=None)

Parameters

Parameter NameTypeDescription
leg_typestrAdditional order type. 'PROFIT' for take profit order, 'LOSS' for stop loss order
pricefloatAdditional order price
time_in_forcestrAdditional order time in force. 'DAY' (Day) and 'GTC' (Good-Til-Canceled)
outside_rthboolWhether 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 NameTypeDescription
accountstrTrading account, can use prime account or paper trading account
contracttigeropen.trade.domain.contract.ContractContract to trade

Returns

Order object


auction_market_order Auction Market Order

auction_market_order(account, contract, action, quantity, time_in_force)

Parameters

Parameter NameTypeDescription
accountstrTrading account, can use prime account or paper trading account
contracttigeropen.trade.domain.contract.ContractContract to trade

Returns

Order object


Transaction Trade Record

tigeropen.trade.domain.order.Transaction

Description

Trade execution record of an order

Object Properties

PropertyTypeDescription
accountstrAccount
order_idintOrder ID
contractContract

OrderLeg Additional Order

tigeropen.trade.domain.order.OrderLeg

Description

Additional orders carried with the main order

Object Properties

PropertyTypeDescription
leg_typestrAdditional order type. 'PROFIT' for take profit order, 'LOSS' for stop loss order
pricefloatAdditional order price
time_in_forcestrAdditional order time in force. 'DAY' (Day) and 'GTC' (Good-Til-Canceled)
outside_rthboolWhether 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

PropertyTypeDescription
marketstrMarket. (US: US stocks)
trading_statusstrMarket 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;
statusstrMarket status description (not yet open, trading, closed, etc.)
open_timedatetime.datetimeMost recent open time

OptionFilter Option Chain Filter

tigeropen.quote.domain.filter.OptionFilter

Description

Option filter parameter object

Object Properties

ParameterTypeRequiredDescription
implied_volatilityfloatNoImplied volatility, reflects market expectations of future stock price volatility. Higher implied volatility indicates more expected stock price volatility
in_the_moneyboolNoWhether in the money
open_interestintNoOpen interest, number of uncleared contracts held by market participants at the end of each trading day. Reflects market depth and liquidity
deltafloatNoDelta 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
gammafloatNoGamma, reflects the impact of stock price changes on delta. For every $1 change in stock price, delta changes by gamma
thetafloatNoTheta reflects the impact of time changes on option price changes. For every day reduction in time, the option price changes approximately theta
vegafloatNoVega reflects the impact of volatility on option price changes. For every 1% change in volatility, the option price changes approximately vega
rhofloatNoRho 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

FieldDescription
idOrder ID
accountAccount
symbolPosition symbol
expiryOptions, CBBC only
strikeOptions, CBBC only
rightOptions, CBBC only
identifierAsset identifier. Stock identifier is the same as the symbol.
multiplierQuantity per lot, options, CBBC only
actionBuy/sell direction. BUY for buy, SELL for sell
marketMarket. US
currencyCurrency. USD US Dollar
segTypeClassification by trading type. S for stocks
secTypeSTK Stocks, OPT Options, IOPT CBBC
orderTypeOrder type. 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order
isLongWhether long position
totalQuantityOrder quantity
totalQuantityScaleOrder quantity offset, e.g., totalQuantity=111, totalQuantityScale=2, then actual totalQuantity=111*10^(-2)=1.11
filledQuantityTotal filled quantity (for orders filled in multiple trades, filledQuantity is cumulative total filled)
filledQuantityScaleTotal filled quantity offset
avgFillPriceAverage fill price
limitPriceLimit order price
stopPriceStop price
realizedPnlRealized P&L (only prime accounts have this field)
statusOrder Status
replaceStatusOrder Replace Status
cancelStatusOrder Cancel Status
outsideRthWhether allows pre-market and after-hours trading, US stocks only
canModifyWhether can modify
canCancelWhether can cancel
liquidationWhether it's a closing order
nameAsset name
sourceOrder source (from 'OpenApi', or other)
errorMsgError message
attrDescOrder description
commissionAndFeeTotal commission and fees
openTimeOrder time
timestampOrder status last update time

Position Changes

FieldDescription
accountUser account
symbolStock code
expiryExpiry date, options, CBBC only
strikeStrike price, options, CBBC only
rightOption direction PUT/CALL, options, CBBC only
identifierAsset identifier
multiplierLot size, options, CBBC only
marketTrading market
currencyCurrency type
segTypeClassification by trading type. S for stocks
secTypeContract type
positionPosition
positionScalePosition quantity offset
averageCostAverage cost
latestPriceLatest price
marketValueMarket value
unrealizedPnlUnrealized P&L
nameAsset name
timestampServer time

Asset Changes

FieldDescription
accountUser account
currencyCurrency type
segTypeClassification by trading type. S for stocks
availableFundsAvailable funds (loan value equity - initial margin)
excessLiquidityExcess liquidity (loan value equity - maintenance margin)
netLiquidationNet liquidation value
equityWithLoanEquity with loan value (loan value assets)
buyingPowerBuying power
cashBalanceAccount cash balance
grossPositionValuePosition market value
initMarginReqCurrent initial margin
maintMarginReqCurrent maintenance margin
timestampServer time

Quote Changes

  • Basic quotes
FieldSub-fieldDescription
symbolStock code
typeType
timestampQuote data time
serverTimestampServer time
avgPriceAverage price
latestPriceLatest price
latestPriceTimestampLatest price timestamp (no value in pre/post market)
latestTimeLatest price time
preClosePrevious close
volumeDaily cumulative volume
amountDaily cumulative turnover (options not supported)
openOpen price
highHigh price
lowLow price
hourTradingTagPre/post market tag (no value during US market hours), values: Pre-market/After-hours
marketStatusMarket status
identifierAsset identifier (options only)
openIntOpen interest (options only)
mipMinute price
miaMinute average price
mitMinute time
mivMinute volume
  • Best bid/ask quotes
FieldDescription
askPriceAsk price
askSizeAsk size
askTimestampAsk timestamp (Pre/Post-Mkt data not supported)
bidPriceBid price
bidSizeBid size
bidTimestampBid timestamp (Pre/Post-Mkt data not supported)