Object
Portfolio Account
tigerapi/model.h PortfolioAccount
)
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
Field | Type | Description |
---|---|---|
account | utility::string_t | corresponding account id |
update_timestamp | long | Update time, 13-digit timestamp in milliseconds |
segments | vector<Segment> | Account information by trade type. The value is Segment object。 |
Segment
Description Divide assets by stock/futures trading categories, with each section as a Segment.
Object Properties
Field | Type | Description |
---|---|---|
category | utility::string_t | Securities Category C: (Commodities Futures), S: (Securities Stocks) |
capability | utility::string_t | Account Type, Margin: RegTMargin, Cash: Cash |
currency | utility::string_t | Currency, such as USD, HKD |
buying_power | double | buying 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_trade | double | Amount of cash that can be traded in the current account |
cash_available_for_withdrawal | double | Amount of cash that can be withdrawn in the current account |
cash_balance | double | The 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_loan | double | Equity with loan value (including loan value assets). Securities Segment: cash value + stock value, futures Segment: cash value - maintenance margin |
excess_liquidation | double | Excess 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_value | double | Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values |
init_margin | double | initial margin requirement |
leverage | double | The 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_funds | double | Locked funds |
maintain_margin | double | Maintenance margin requirement |
net_liquidation | double | Net Liquidation Value |
overnight_liquidation | double | Overnight 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_margin | double | Overnight margin requirement |
realized_pl | double | Realized P&L |
total_today_pl | double | P&L for today |
unrealized_pl | double | floating profit and loss |
unrealized_plby_cost_of_carry | double | Unrealized profit and loss by cost of carry |
currency_assets | vector<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 CurrencyAsset
Description
Assets by currency.
Object Properties
Field | Type | Description |
---|---|---|
cash_available_for_trade | double | The amount of cash that can be traded in the current account |
cash_balance | double | 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) |
currency | utility::string_t | Current currency |
gross_position_value | double | gross value |
option_market_value | double | Market value of the option |
realized_pl | double | Realized profit and loss of the account |
stock_market_value | double | The market value of the stock, when the category is C (futures type), there will be no stock market value |
unrealized_pl | double | Unrealized profit and loss of the account |
Position
Description
Account holding information. Including the contract subject of the position, the number of positions, cost, profit and loss and other information.
Object Properties
Field | Type | Description |
---|---|---|
account | utility::string_t | The corresponding account ID |
contract | Contract | Contract object |
position | long long | Position quantity |
average_cost | double | Average cost with commission |
market_value | double | Market Cap |
realized_pnl | double | Realized P&L |
unrealized_pnl | double | Floating profit and loss |
latest_price | double | Market price |
status | int | Status code |
update_timestamp | time_t | Timestamp of update |
Order
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
Field | Type | Description |
---|---|---|
contract | Contract | Contract object |
account | utility::string_t | The account to which the order belongs |
id | unsigned long long | Global order id |
order_id | long | The account automatically increments the order number, which is obsolete |
order_type | utility::string_t | Order type, 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order/'TRAIL' trailing stop order |
action | utility::string_t | Trade direction, 'BUY' / 'SELL' |
total_quantity | long long | Order quantity |
total_quantity_scale | long | Order 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_price | double | Limit price |
s_limit_price | utility::string_t | |
aux_price | double | In stop order, it represents the price to trigger the stop order, in trailing stop order, it represents the price to track |
trail_stop_price | double | Trailing stop price |
trailing_percent | double | Trailing stop order-percent, the value range is 0-100 |
percent_offset | double | |
time_in_force | utility::string_t | Valid period, valid within 'DAY'/valid until 'GTC' is revoked/ 'GTD' good till date |
outside_rth | bool | Whether to allow pre-market and post-market trading, exclusive to US stocks |
adjust_limit | double | Price 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_mark | utility::string_t | |
expire_time | time_t | GTD Order expire time |
status | OrderStatus | Enumeration indicating order status |
parent_id | unsigned long long | Parent order id, currently only used for additional orders on TigerTrade App |
open_time | time_t | Order time |
reason | utility::string_t | Reason for a failed order |
latest_time | time_t | Latest transaction time |
update_time | time_t | Order update time |
filled_quantity | long long | Filled quantity |
filled_quantity_scale | long | Filled quantity scale |
avg_fill_price | double | Average fill price including commission |
realized_pnl | double | Realized Pnl |
secret_key | utility::string_t | |
sub_ids | web::json::value | List of sub-order IDs for attached orders (this field will only have a value when attaching an order) |
algo_strategy | utility::string_t | |
commission | double | Includes commission, stamp duty, securities regulatory fees, and other related charges |
gst | double | Goods 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 Order
OrderUtil::market_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity)
Parameters
Parameter | Type | Description |
---|---|---|
account | utility::string_t | Order account |
contract | Contract | Contract object to trade |
action | utility::string_t | trading action, 'BUY' / 'SELL' |
quantity | long | The quantity of the order, which must be an integer greater than 0 |
return
Order
object
Limit Order
OrderUtil::limit_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
double limit_price)
Parameters
Parameter | Type | Description |
---|---|---|
account | utility::string_t | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract to trade |
action | utility::string_t | trading action, 'BUY' / 'SELL' |
quantity | long | The quantity of the order, which must be an integer greater than 0 |
limit_price | double | Limit price |
return
Order
object
Stop Order
OrderUtil::stop_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
double aux_price)
Parameters
Parameter | Type | Description |
---|---|---|
account | utility::string_t | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | utility::string_t | trading action, 'BUY' / 'SELL' |
quantity | long | The quantity of the order, which must be an integer greater than 0 |
aux_price | double | The price to trigger the stop order |
return
Order
Order object
Stop Limit Order
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
Parameter | Type | Description |
---|---|---|
account | utility::string_t | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | utility::string_t | trading action, 'BUY' / 'SELL' |
quantity | long | The quantity of the order, which must be an integer greater than 0 |
limit_price | double | Limit price |
aux_price | double | The price to trigger the stop order |
return
Order
Order Object
Trail Order
OrderUtil::trail_order(const utility::string_t account, Contract &contract, const utility::string_t action, long quantity,
double aux_price, double trailing_percent)
Parameters
Parameter | Type | Description |
---|---|---|
account | utility::string_t | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | utility::string_t | trading action, 'BUY' / 'SELL' |
quantity | long | The quantity of the order, which must be an integer greater than 0 |
aux_price | double | Price difference, mutually exclusive with trailing_percent |
trailing_percent | double | Percentage, the value range is 0-100, mutually exclusive with aux_price |
return
Order
Order
Contract object
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
Parameter | Type | Description |
---|---|---|
symbol | utility::string_t | Contract code |
currency | Currency | Currency type |
sec_type | SecType | Securities Type |
exchange | utility::string_t | Exchange |
local_symbol | utility::string_t | Local symbol |
expiry | utility::string_t | Expiration date (for options/futures) |
strike | utility::string_t | Strike Price (for options) |
right | utility::string_t | Option right |
multiplier | int | Number per lot |
contract_month | utility::string_t | Contract month, such as 202201, means January 2022 |
contract_id | long | contract id |
identifier | utility::string_t | Unique identifier, the stock identifier is the same as the symbol, the option is a 21-digit identifier, such as: 'AAPL 220729C00150000', the futures identifier |
market | utility::string_t | Market |