Object

About 7 min

Portfolio Account

tigerapi/model.h PortfolioAccountopen in new window)

Description

Account asset object, applicable to comprehensive/simulated accounts. Includes total assets, profit and loss, market value of holdings, cash, available funds, margin, leverage, and other related information.

Object Properties

FieldTypeDescription
accountutility::string_tcorresponding account id
update_timestamplongUpdate time, 13-digit timestamp in milliseconds
segmentsvector<Segment>Account information by trade type. The value is Segment object

Segment

tigerapi/model.h Segmentopen in new window

Description Divide assets by stock/futures trading categories, with each section as a Segment.

Object Properties

FieldTypeDescription
categoryutility::string_tSecurities Category C: (Commodities Futures), S: (Securities Stocks)
capabilityutility::string_tAccount Type, Margin: RegTMargin, Cash: Cash
currencyutility::string_tCurrency, such as USD, HKD
buying_powerdoublebuying 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
cash_available_for_tradedoubleAmount of cash that can be traded in the current account
cash_available_for_withdrawaldoubleAmount of cash that can be withdrawn in the current account
cash_balancedoubleThe 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)
equity_with_loandoubleEquity with loan value (including loan value assets). Securities Segment: cash value + stock value, futures Segment: cash value - maintenance margin
excess_liquidationdoubleExcess 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
gross_position_valuedoubleTotal value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values
init_margindoubleinitial margin requirement
leveragedoubleThe 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.
locked_fundsdoubleLocked funds
maintain_margindoubleMaintenance margin requirement
net_liquidationdoubleNet Liquidation Value
overnight_liquidationdoubleOvernight risk control value, when it is less than 0, account positions will be forced to liquidate, you need to pay attention to the risks
overnight_margindoubleOvernight margin requirement
realized_pldoubleRealized P&L
total_today_pldoubleP&L for today
unrealized_pldoublefloating profit and loss
unrealized_plby_cost_of_carrydoubleUnrealized profit and loss by cost of carry
currency_assetsvector<CurrencyAsset>Account asset information differentiated by transaction currency, is a dict with currency as key, and value as CurrencyAsset object

Currency Asset

tigerapi/model.h CurrencyAssetopen in new window

Description
Assets by currency.

Object Properties

FieldTypeDescription
cash_available_for_tradedoubleThe amount of cash that can be traded in the current account
cash_balancedoubleCash 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)
currencyutility::string_tCurrent currency
gross_position_valuedoublegross value
option_market_valuedoubleMarket value of the option
realized_pldoubleRealized profit and loss of the account
stock_market_valuedoubleThe market value of the stock, when the category is C (futures type), there will be no stock market value
unrealized_pldoubleUnrealized profit and loss of the account

Position

tigerapi/model.h Positionopen in new window

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

Object Properties

FieldTypeDescription
accountutility::string_tThe corresponding account ID
contractContractContract object
positionlong longPosition quantity
average_costdoubleAverage cost with commission
market_valuedoubleMarket Cap
realized_pnldoubleRealized P&L
unrealized_pnldoubleFloating profit and loss
latest_pricedoubleMarket price
statusintStatus code
update_timestamptime_tTimestamp of update

Order

tigerapi/model.h Orderopen in new window

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

FieldTypeDescription
contractContractContract object
accountutility::string_tThe account to which the order belongs
idunsigned long longGlobal order id
order_idlongThe account automatically increments the order number, which is obsolete
order_typeutility::string_tOrder type, 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order/'TRAIL' trailing stop order
actionutility::string_tTrade direction, 'BUY' / 'SELL'
total_quantitylong longOrder quantity
total_quantity_scalelongOrder quantity scale
For example, if total_quantity is 5 and total_quantity_scale is 1, then the actual order quantity is 5 * 10^-1 = 0.5
limit_pricedoubleLimit price
s_limit_priceutility::string_t
aux_pricedoubleIn stop order, it represents the price to trigger the stop order, in trailing stop order, it represents the price to track
trail_stop_pricedoubleTrailing stop price
trailing_percentdoubleTrailing stop order-percent, the value range is 0-100
percent_offsetdouble
time_in_forceutility::string_tValid period, valid within 'DAY'/valid until 'GTC' is revoked/ 'GTD' good till date
outside_rthboolWhether to allow pre-market and post-market trading, exclusive to US stocks
adjust_limitdoublePrice adjustment range (default 0 means no adjustment, positive means upward adjustment, negative means downward adjustment), automatically adjust the input price to a legal price.
For example: 0.001 means upward adjustment and the adjustment range is not more than 0.1%; -0.001 means downward adjustment and the adjustment range is not more than 0.1%
user_markutility::string_t
expire_timetime_tGTD Order expire time
statusOrderStatusEnumeration indicating order status
parent_idunsigned long longParent order id, currently only used for additional orders on TigerTrade App
open_timetime_tOrder time
reasonutility::string_tReason for a failed order
latest_timetime_tLatest transaction time
update_timetime_tOrder update time
filled_quantitylong longFilled quantity
filled_quantity_scalelongFilled quantity scale
avg_fill_pricedoubleAverage fill price including commission
realized_pnldoubleRealized Pnl
secret_keyutility::string_t
sub_idsweb::json::valueList of sub-order IDs for attached orders (this field will only have a value when attaching an order)
algo_strategyutility::string_t
commissiondoubleIncludes commission, stamp duty, securities regulatory fees, and other related charges
gstdoubleGoods and Service Tax

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 Orderopen in new window

OrderUtil::market_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity)

Parameters

ParameterTypeDescription
accountutility::string_tOrder account
contractContractContract object to trade
actionutility::string_ttrading action, 'BUY' / 'SELL'
quantitylongThe quantity of the order, which must be an integer greater than 0

return

Order object

Limit Orderopen in new window

OrderUtil::limit_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
                       double limit_price)

Parameters

ParameterTypeDescription
accountutility::string_tOrder account, you can use an integrated account, a global account or a demo account
contractContractContract to trade
actionutility::string_ttrading action, 'BUY' / 'SELL'
quantitylongThe quantity of the order, which must be an integer greater than 0
limit_pricedoubleLimit price

return

Order object

Stop Orderopen in new window

OrderUtil::stop_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
                      double aux_price)

Parameters

ParameterTypeDescription
accountutility::string_tOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionutility::string_ttrading action, 'BUY' / 'SELL'
quantitylongThe quantity of the order, which must be an integer greater than 0
aux_pricedoubleThe price to trigger the stop order

return

Order Order object

Stop Limit Orderopen in new window

OrderUtil::stop_limit_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
                     double limit_price, double aux_price)

Parameters

ParameterTypeDescription
accountutility::string_tOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionutility::string_ttrading action, 'BUY' / 'SELL'
quantitylongThe quantity of the order, which must be an integer greater than 0
limit_pricedoubleLimit price
aux_pricedoubleThe price to trigger the stop order

return

Order Order Object

Trail Orderopen in new window

OrderUtil::trail_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
                       double aux_price, double trailing_percent)

Parameters

ParameterTypeDescription
accountutility::string_tOrder account, you can use an integrated account, a global account or a demo account
contractContractContract object to trade
actionutility::string_ttrading action, 'BUY' / 'SELL'
quantitylongThe quantity of the order, which must be an integer greater than 0
aux_pricedoublePrice difference, mutually exclusive with trailing_percent
trailing_percentdoublePercentage, the value range is 0-100, mutually exclusive with aux_price

return

Order Order


Contract object

tigerapi/model.h Contractopen in new window

Description
A contract refers to the transaction object (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 C++ SDK, contract information is stored through the tigerapi/model.h Contract object. The Contract object can be passed into the tool function to create the Order object.

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"));

options

Contract contract = ContractUtil::option_contract(U("AAPL"), U("20230721"), U("185.0"), U("PUT"), U("USD"));
Contract contract = ContractUtil::option_contract(U("AAPL 230721C00185000"));

futures

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

See below for specific fields and construction methods

Parameter

ParameterTypeDescription
symbolutility::string_tContract code
currencyCurrencyCurrency type
sec_typeSecTypeSecurities Type
exchangeutility::string_tExchange
local_symbolutility::string_tLocal symbol
expiryutility::string_tExpiration date (for options/futures)
strikeutility::string_tStrike Price (for options)
rightutility::string_tOption right
multiplierintNumber per lot
contract_monthutility::string_tContract month, such as 202201, means January 2022
contract_idlongcontract id
identifierutility::string_tUnique identifier, the stock identifier is the same as the symbol, the option is a 21-digit identifier, such as: 'AAPL 220729C00150000', the futures identifier
marketutility::string_tMarket

Last update: