Object
Portfolio Account
tigerapi/model.h PortfolioAccount
Description
Account asset object, applicable to Prime/Paper 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
Assets include the stock category, which corresponds to a segment.
Object Properties
| Field | Type | Description |
|---|---|---|
| category | utility::string_t | Securities Category 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 |
| excess_liquidation | double | Excess liquidity, used to represent intraday risk value. Calculation method for securities segment: equity_with_loan - 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 |
| unrealized_pl | double | Unrealized profit and loss of the account |
Position
Description
Account holding information. Including the contract object 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 for modifying an order also 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 |
| 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 |
| percent_offset | double | |
| time_in_force | utility::string_t | Valid period, valid within 'DAY'/valid until 'GTC' is revoked |
| 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 | |
| status | OrderStatus | Enumeration indicating order status |
| parent_id | unsigned long long | Parent order id, currently only used for additional orders on 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
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 |
Response
Order object
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 |
| 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 |
Response
Order object
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 |
| 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 |
Response
Order object
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 |
| 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 |
Response
Order object
Contract object
Description
A contract is a tradeable item (like a stock or options) whose terms are set by the exchange. For example, Wxy Holdings trades under the symbol WXY in the US market (market='US'). When purchasing options, 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 OpenAPI 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 an Order object.
Common contracts include stock contracts, options contracts etc. Most contracts include the following elements:
- The subject code (symbol), generally the contract codes such as US stocks are English letters, and the contract codes such as Hong Kong stocks and A shares are numbers. For example, the Wxy Holdings trades under the symbol, WXY.
- Contract type (security type), common contract types include: STK (stock), OPT (option). For example, the contract type of WXY is STK.
- Currency type (currency), common currencies include USD (US dollar), HKD (Hong Kong dollar).
The vast majority of stocks and indices can be uniquely identified by these four properties. Due to their nature, more complex contracts such as options require some additional information. Here are a few common types of contracts and what they consist of:
Stocks
Contract contract = ContractUtil::stock_contract(U("ABCD"), U("USD"));Options
Contract contract = ContractUtil::option_contract(U("ABCD"), U("20230721"), U("185.0"), U("PUT"), U("USD"));
Contract contract = ContractUtil::option_contract(U("ABCD 230721C00185000"));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) |
| 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: 'ABCD 220729C00150000' |
| market | utility::string_t | Market |
Updated about 1 month ago