Object

About 8 min

Account PortfolioAccount Assets

tigeropen.trade.domain.prime_account.PortfolioAccount

Instruction

Account Equity object, for Prime/Paper accounts. Contains the account's total assets, profit and loss, market value of positions, 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 by trade type. The content is a dict with two keys, 'S' for securities, 'C' for futures, and the value is Segment object

Account Segment Assets

tigeropen.trade.domain.prime_account.Segment

Instruction Divide assets according to stock/futures trading varieties, and each part is a segment.

Object Properties

property nametypedescription
currencystrCurrency, such as USD, HKD
capabilitystrAccount Type, Margin: RegTMargin, Cash: Cash
categorystrSecurities Category C: (Commodities Futures), S: (Securities Stocks)
cash_balancefloatThe cash that can be traded, plus the cash that has been locked (such as stocks that have been purchased but not yet traded, and some other situations will also have locked cash)
cash_available_for_tradefloatAmount of cash that can be traded in the current account
cash_available_for_withdrawalfloatAmount of cash that can be withdrawn in the current account
gross_position_valuefloatTotal value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values
equity_with_loanfloatEquity with loan value (including loan value assets). Securities Segment: cash value + stock value, futures Segment: cash value - maintenance margin
net_liquidationfloatNet Liquidation Value
init_marginfloatinitial margin requirement
maintain_marginfloatMaintenance margin requirement
overnight_marginfloatOvernight margin requirement
unrealized_plfloatfloating profit and loss
realized_plfloatRealized P&L
excess_liquidationfloatExcess liquidity, used to represent intraday risk value. Calculation method for securities segment: equity_with_loan - maintenance_margin_requirement. Calculation method for futures segment: net_liquidation - maintenance_margin_requirement
overnight_liquidationfloatOvernight risk control value, when it is less than 0, account positions will be forced to liquidate, you need to pay attention to the risks
buying_powerfloatbuying power. Estimate how many more dollars you can buy in stock assets. The margin account has a maximum of four times the purchasing power of the funds (funds that are not used for margin) during the day. Up to twice the purchasing power overnight
leveragefloatThe leverage multiplier currently used. When it is less than 1, it indicates that no leverage is used. When it is greater than 1, it indicates that leverage is used.
currency_assetsdictAccount asset information differentiated by transaction currency, is a dict with currency as key, and value as CurrencyAsset object

CurrencyAsset

tigeropen.trade.domain.prime_account.CurrencyAsset

Instruction
Assets by currency.

Object Properties

member nametypedescription
currencystrCurrent currency, commonly used currencies include: USD-US dollar, HKD-Hong Kong dollar, SGD-Singapore dollar, CNH-RMB
cash_balancefloatCash that can be traded, plus the cash that has been locked (such as stocks that have been purchased but not yet traded, and some other situations will also have locked cash)
cash_available_for_tradefloatThe amount of cash that can be traded in the current account
gross_position_valuefloatgross value
stock_market_valuefloatThe market value of the stock, when the category is C (futures type), there will be no stock market value
futures_market_valuefloatThe market value of futures, when the category is S (stock type), there will be no futures market value
option_market_valuefloatMarket value of the option
unrealized_plfloatUnrealizd profit and loss of the account
realized_plfloatThe realized profit and loss in the account


Position

tigeropen.trade.domain.position.Position

instruction
Account holding information. Including the contract subject of the position, the number of positions, cost, profit and loss and other information.

Object Properties

property nametypedescription
accountstrThe corresponding account ID
contracttigeropen.trade.domain.contract.ContractContract object
quantityintContract quantity
average_costfloatAverage cost with commission
market_pricefloatMarket Price
market_valuefloatMarket Cap
realized_pnlfloatRealized P&L
unrealized_pnlfloatFloating profit and loss

Order

tigeropen.trade.domain.order.Order

Instruction
Order object. Querying an order will return this object, and the parameters of placing an order to change an order also need to use this object.

Object Properties

property nametypedescription
accountstrThe account to which the order belongs
idintGlobal order id
order_idintThe account automatically increments the order number, which is obsolete
parent_idintParent order id, currently only used for additional orders on TigerTrade App
order_timeintOrder time, 13-digit timestamp in milliseconds
reasonstrWhen the order fails, the description of the reason for the failure will be returned
trade_timeintLatest trade time, 13-digit timestamp in milliseconds
update_timeintOrder latest status change time
expire_timeintGTD Order expire time
actionstrTrade direction, 'BUY' / 'SELL'
quantityintOrder quantity
filledintNumber of transactions
avg_fill_pricefloatAverage fill price including commission
commissionfloatIncluding commissions, stamp duties, SFC fees and other series of fees
realized_pnlfloatRealized Pnl
trail_stop_pricefloatTrailing stop price
limit_pricefloatLimit order price
aux_pricefloatIn a stop order, it indicates the price at which the stop loss started, and in a trailing stop order, it indicates the trailing spread
trailing_percentfloatTrailing stop order-percent, the value range is 0-100
percent_offsetfloat<This field is not used>
order_typestrOrder type, 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order/'TRAIL' trailing stop order
time_in_forcestrValid period, valid within 'DAY'/valid until 'GTC' is revoked/ 'GTD' good till date
outside_rthboolWhether it supports pre-market and post-market trading, exclusive to US stocks.
contractContracttigeropen.trade.domain.contract.Contract contract object
statusOrderStatustigeropen.common.consts.OrderStatusopen in new window Enumeration, indicating order status
remainingintUnfilled Quantity

Build method:

Use SDK's order_util tool to generate: order_util only provides common parameters, if you need additional parameters, you can modify its attributes after generating the order object

Market Order

parameter

parameter nametypedescription
accountstrOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionstrtrading action, 'BUY' / 'SELL'
quantityintThe quantity of the order, which must be an integer greater than 0

return

Order object

Limit Order

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

parameter

parameter nametypedescription
accountstrOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionstrtrading action, 'BUY' / 'SELL'
quantityintThe quantity of the order, which must be an integer greater than 0
limit_pricefloatLimit price

return

Order object

Stop Order

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

parameter

parameter nametypedescription
accountstrOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionstrtrading action, 'BUY' / 'SELL'
quantityintThe quantity of the order, which must be an integer greater than 0
aux_pricefloataux price

return

Order Order object

Stop Limit Order

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

parameter

parameter nametypedescription
accountstrOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionstrtrading action, 'BUY' / 'SELL'
quantityintThe quantity of the order, which must be an integer greater than 0
limit_pricefloatLimit price
aux_pricefloataux price

return

Order Order Object

Trail Order

trail_order(account, contract, action, quantity, trailing_percent=None, aux_price=None)

parameter

parameter nametypedescription
accountstrOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionstrtrading action, 'BUY' / 'SELL'
quantityintThe quantity of the order, which must be an integer greater than 0
trailing_percentfloatTrailing stop loss order-percentage, the value range is 0-100, aux_price and trailing_percent are mutually exclusive
aux_pricefloatspread, mutually exclusive with trailing_percent

return

Order Order

Attach Order

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

parameter

parameter nametypedescription
leg_typestrAdditional order types. 'PROFIT' for take profit order type, 'LOSS' for stop loss order type
pricefloatAdditional order price
time_in_forcestrAdditional order validity period. 'DAY'(Valid for the day)and 'GTC'( Good-Til-Canceled).
outside_rthboolWhether to allow pre-market and after-market trading for additional orders (exclusive to US stocks). True is allowed, False is not allowed

return

OrderLeg tigeropen.trade.domain.order.OrderLeg

Order Transaction

tigeropen.trade.domain.order.Transaction

Description transaction record of the order

Object Attribute

parameter nametypedescription
accountstraccount
order_idintorder id
contractContractContract object to trade
idintorder transaction id
actionstrSELL or BUY
filled_quantityintfilled quantity
filled_pricefloatfilled price
filled_amountfloatfilled amount
transacted_atstrtransaction time

Contract

Contract

Description

instruction
A contract refers to the transaction object or subject matter (such as a stock or an option), and the contract is uniformly formulated by the exchange. For example, buying stocks of Tiger Securities can be uniquely identified by the letter code TIGR and market information (ie market='US', the US market). Similarly, when purchasing options or futures products, other identification fields may be required. Through the contract information, we can uniquely determine a target when placing an order or obtaining market quotations. In the Open API Python SDK, contract information is stored through the tigeropen.trade.domain.contract.Contract object. The Contract object can be passed into the tool function that constructs the Order order object to create the Order object for placing an order

Common contracts include stock contracts, options contracts, futures contracts, etc. Most contracts include the following elements:

  • The subject code (symbol), generally the contract codes such as US stocks and British stocks are English letters, and the contract codes such as Hong Kong stocks and A shares are numbers. For example, the symbol of Tiger Securities is TIGR.
  • Contract type (security type), common contract types include: STK (stock), OPT (option), FUT (futures), CASH (foreign exchange). For example, the contract type of Tiger Securities stock is STK.
  • Currency type (currency), common currencies include USD (US dollar), HKD (Hong Kong dollar).
  • Exchange, STK type contracts generally do not use the exchange field, orders will be automatically routed, and futures contracts use the exchange field.

The vast majority of stocks, CFDs, indices or forex pairs can be uniquely identified by these four properties. Due to their nature, more complex contracts such as options and futures require some additional information. Here are a few common types of contracts and what they consist of:

Stock:

Contract contract = ContractUtil::stock_contract(U("AAPL"), U("USD"));

Option:

Contract contract = ContractUtil::option_contract(U("AAPL"), U("20230312"), U("150.5"), U("CALL"), U("USD"));
Contract contract = ContractUtil::option_contract(U("AAPL  230630C00187500")

Futures:

Contract contract = ContractUtil::future_contract(U("CL2309"), U("USD"))

See below for specific fields and construction methods

Data Member

member nametypedescription
symbolstrContract code
contract_idintcontract id
sec_typestrSecurities Type
namestrContract name
currencystrcurrency
exchangestrExchange
expirystrExpiration date (for options/futures)
strikefloatStrike Price (for options)
multiplierfloatNumber per lot
put_callstrOption direction, bullish bearish
local_symbolstr
short_marginfloatshort margin ratio(deprecated, use short_initial_margin instead
short_initial_marginfloatshort initial margin ratio
short_maintenance_marginfloatshort maintenance margin ratio
short_fee_ratefloatShort rate
shortableintShort pool remaining
long_initial_marginfloatLong initial margin
long_maintenance_marginfloatLong Maintenance Margin
contract_monthstrContract month, such as 202201, means January 2022
identifierstrContract identifier
primary_exchangestrStock Listing Exchange
marketstrMarket
min_tickfloatMinimum tick unit
trading_classstrThe trading class name of the contract
statusstrStatus
continuousboolExclusive to futures, whether it is a continuous contract
tradeboolFutures are exclusive, whether they can be traded
last_trading_datestrExclusive to futures, the last trading day, such as '20211220', means December 20, 2021
first_notice_datestrExclusively for futures, on the first notice day, long positions cannot be opened after the first notice day. Existing long positions will be forced to close before the first notice day (usually the first three trading days). , such as '20211222', which means December 22, 2021
last_bidding_close_timeintFutures exclusive, bid closing timestamp
is_etfboolis ETF
etf_leverageintETF leverage

build method

Contract objects can be generated by the following utility functions:

Get contract information get_contract/get_contracts

parameter:

ParametersRequired or notDescription
symbolYesContract code such as 00700/AAPL
sec_typeYesContract type such as SecurityType.STK/SecurityType.OPT
currencyNoCurrency such as Currency.USD/Currency.HKD
exchangeNoExchange such as SMART/SEHK
expiryNoExpiration date Required when the trading type is an option yyyyMMdd
strikeNoStrike price Required when the trading type is an option
put_callNoCALL/PUT must be passed when the symbol is an option
secret_keyNoInstitutional trader key, exclusive to institutional users, needs to be configured in client_config

return: get_contract returns a Contract object; get_contracts returns a list of Contract objects. See the contract description for object properties

Example



MarketStatus Market Status

tigeropen.quote.domain.market_status.MarketStatus

description

Market trading status

Parameters

ParametersTypeDescription
marketstrmarket. (US: US stocks, CN: Shanghai and Shenzhen, HK: Hong Kong stocks)
trading_statusstrMarket transaction status code. Not open NOT_YET_OPEN; Pre-market trading PRE_HOUR_TRADING; Trading in TRADING; Midday closed MIDDLE_CLOSE; After-hours trading POST_HOUR_TRADING; Closed CLOSING;Close early EARLY_CLOSED; Close MARKET_CLOSED;
statusstrMarket status description (closed, trading, closed, etc.)
open_timedatetime.datetimeLast opening time

OptionFilter Option Filter Chain

tigeropen.quote.domain.filter.OptionFilter

description

option filter parameter object

Parameters

ParametersTypeRequiredDescription
implied_volatilityfloatNoImplied volatility reflects the market's expected future stock price fluctuations. The higher the implied volatility, the more severe the expected stock price fluctuations
in_the_moneyboolNoin the money
open_interestintNoOpen interest, the number of outstanding contracts in the hands of market participants at the end of each trading day. Reflects the depth and liquidity of the market
deltafloatNodelta, Reflects the impact of stock price changes on option price changes. For every 1 yuan change in stock price, the option price changes approximately delta. e.g. -1.0 ~ 1.0
gammafloatNogamma, Reflects the impact of stock price changes on delta. Every time the stock price changes by 1 yuan, delta changes gamma
thetafloatNotheta, Reflects the impact of time changes on option price changes. When the time is reduced by one day, the option price changes by about 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 the risk-free interest rate on the option price change. For every 1% change in the risk-free interest rate, the option price changes approximately rho
Last update: