Object
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 name | type | description |
---|---|---|
account | str | corresponding account id |
update_timestamp | int | Update time, 13-digit timestamp in milliseconds |
segments | tigeropen.trade.domain.prime_account.Segment | Account 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 name | type | description |
---|---|---|
currency | str | Currency, such as USD, HKD |
capability | str | Account Type, Margin: RegTMargin, Cash: Cash |
category | str | Securities Category C: (Commodities Futures), S: (Securities Stocks) |
cash_balance | float | 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) |
cash_available_for_trade | float | Amount of cash that can be traded in the current account |
cash_available_for_withdrawal | float | Amount of cash that can be withdrawn in the current account |
gross_position_value | float | Total 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_loan | float | Equity with loan value (including loan value assets). Securities Segment: cash value + stock value, futures Segment: cash value - maintenance margin |
net_liquidation | float | Net Liquidation Value |
init_margin | float | initial margin requirement |
maintain_margin | float | Maintenance margin requirement |
overnight_margin | float | Overnight margin requirement |
unrealized_pl | float | floating profit and loss |
realized_pl | float | Realized P&L |
excess_liquidation | float | 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 |
overnight_liquidation | float | 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 |
buying_power | float | 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 |
leverage | float | 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. |
currency_assets | dict | Account 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 name | type | description |
---|---|---|
currency | str | Current currency, commonly used currencies include: USD-US dollar, HKD-Hong Kong dollar, SGD-Singapore dollar, CNH-RMB |
cash_balance | float | 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_trade | float | The amount of cash that can be traded in the current account |
gross_position_value | float | gross value |
stock_market_value | float | The market value of the stock, when the category is C (futures type), there will be no stock market value |
futures_market_value | float | The market value of futures, when the category is S (stock type), there will be no futures market value |
option_market_value | float | Market value of the option |
unrealized_pl | float | Unrealizd profit and loss of the account |
realized_pl | float | The 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 name | type | description |
---|---|---|
account | str | The corresponding account ID |
contract | tigeropen.trade.domain.contract.Contract | Contract object |
quantity | int | Contract quantity |
average_cost | float | Average cost with commission |
market_price | float | Market Price |
market_value | float | Market Cap |
realized_pnl | float | Realized P&L |
unrealized_pnl | float | Floating 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 name | type | description |
---|---|---|
account | str | The account to which the order belongs |
id | int | Global order id |
order_id | int | The account automatically increments the order number, which is obsolete |
parent_id | int | Parent order id, currently only used for additional orders on TigerTrade App |
order_time | int | Order time, 13-digit timestamp in milliseconds |
reason | str | When the order fails, the description of the reason for the failure will be returned |
trade_time | int | Latest trade time, 13-digit timestamp in milliseconds |
update_time | int | Order latest status change time |
expire_time | int | GTD Order expire time |
action | str | Trade direction, 'BUY' / 'SELL' |
quantity | int | Order quantity |
filled | int | Number of transactions |
avg_fill_price | float | Average fill price including commission |
commission | float | Including commissions, stamp duties, SFC fees and other series of fees |
realized_pnl | float | Realized Pnl |
trail_stop_price | float | Trailing stop price |
limit_price | float | Limit order price |
aux_price | float | In 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_percent | float | Trailing stop order-percent, the value range is 0-100 |
percent_offset | float | <This field is not used> |
order_type | str | Order type, 'MKT' market order/'LMT' limit order/'STP' stop order/'STP_LMT' stop limit order/'TRAIL' trailing stop order |
time_in_force | str | Valid period, valid within 'DAY'/valid until 'GTC' is revoked/ 'GTD' good till date |
outside_rth | bool | Whether it supports pre-market and post-market trading, exclusive to US stocks. |
contract | Contract | tigeropen.trade.domain.contract.Contract contract object |
status | OrderStatus | tigeropen.common.consts.OrderStatus Enumeration, indicating order status |
remaining | int | Unfilled 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 name | type | description |
---|---|---|
account | str | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | str | trading action, 'BUY' / 'SELL' |
quantity | int | The 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 name | type | description |
---|---|---|
account | str | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | str | trading action, 'BUY' / 'SELL' |
quantity | int | The quantity of the order, which must be an integer greater than 0 |
limit_price | float | Limit price |
return
Order
object
Stop Order
stop_order(account, contract, action, quantity, aux_price)
parameter
parameter name | type | description |
---|---|---|
account | str | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | str | trading action, 'BUY' / 'SELL' |
quantity | int | The quantity of the order, which must be an integer greater than 0 |
aux_price | float | aux price |
return
Order
Order object
Stop Limit Order
stop_limit_order(account, contract, action, quantity, limit_price, aux_price)
parameter
parameter name | type | description |
---|---|---|
account | str | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | str | trading action, 'BUY' / 'SELL' |
quantity | int | The quantity of the order, which must be an integer greater than 0 |
limit_price | float | Limit price |
aux_price | float | aux price |
return
Order
Order Object
Trail Order
trail_order(account, contract, action, quantity, trailing_percent=None, aux_price=None)
parameter
parameter name | type | description |
---|---|---|
account | str | Order account, you can use an integrated account, a global account or a demo account |
contract | Contract | Contract object to trade |
action | str | trading action, 'BUY' / 'SELL' |
quantity | int | The quantity of the order, which must be an integer greater than 0 |
trailing_percent | float | Trailing stop loss order-percentage, the value range is 0-100, aux_price and trailing_percent are mutually exclusive |
aux_price | float | spread, mutually exclusive with trailing_percent |
return
Order
Order
Attach Order
order_leg(leg_type, price, time_in_force='DAY', outside_rth=None)
parameter
parameter name | type | description |
---|---|---|
leg_type | str | Additional order types. 'PROFIT' for take profit order type, 'LOSS' for stop loss order type |
price | float | Additional order price |
time_in_force | str | Additional order validity period. 'DAY'(Valid for the day)and 'GTC'( Good-Til-Canceled). |
outside_rth | bool | Whether 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 name | type | description |
---|---|---|
account | str | account |
order_id | int | order id |
contract | Contract | Contract object to trade |
id | int | order transaction id |
action | str | SELL or BUY |
filled_quantity | int | filled quantity |
filled_price | float | filled price |
filled_amount | float | filled amount |
transacted_at | str | transaction 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 name | type | description |
---|---|---|
symbol | str | Contract code |
contract_id | int | contract id |
sec_type | str | Securities Type |
name | str | Contract name |
currency | str | currency |
exchange | str | Exchange |
expiry | str | Expiration date (for options/futures) |
strike | float | Strike Price (for options) |
multiplier | float | Number per lot |
put_call | str | Option direction, bullish bearish |
local_symbol | str | |
short_margin | float | short margin ratio(deprecated, use short_initial_margin instead |
short_initial_margin | float | short initial margin ratio |
short_maintenance_margin | float | short maintenance margin ratio |
short_fee_rate | float | Short rate |
shortable | int | Short pool remaining |
long_initial_margin | float | Long initial margin |
long_maintenance_margin | float | Long Maintenance Margin |
contract_month | str | Contract month, such as 202201, means January 2022 |
identifier | str | Contract identifier |
primary_exchange | str | Stock Listing Exchange |
market | str | Market |
min_tick | float | Minimum tick unit |
trading_class | str | The trading class name of the contract |
status | str | Status |
continuous | bool | Exclusive to futures, whether it is a continuous contract |
trade | bool | Futures are exclusive, whether they can be traded |
last_trading_date | str | Exclusive to futures, the last trading day, such as '20211220', means December 20, 2021 |
first_notice_date | str | Exclusively 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_time | int | Futures exclusive, bid closing timestamp |
is_etf | bool | is ETF |
etf_leverage | int | ETF leverage |
build method
Contract objects can be generated by the following utility functions:
Get contract information get_contract
/get_contracts
parameter:
Parameters | Required or not | Description |
---|---|---|
symbol | Yes | Contract code such as 00700/AAPL |
sec_type | Yes | Contract type such as SecurityType.STK/SecurityType.OPT |
currency | No | Currency such as Currency.USD/Currency.HKD |
exchange | No | Exchange such as SMART/SEHK |
expiry | No | Expiration date Required when the trading type is an option yyyyMMdd |
strike | No | Strike price Required when the trading type is an option |
put_call | No | CALL/PUT must be passed when the symbol is an option |
secret_key | No | Institutional 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
Parameters | Type | Description |
---|---|---|
market | str | market. (US: US stocks, CN: Shanghai and Shenzhen, HK: Hong Kong stocks) |
trading_status | str | Market 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; |
status | str | Market status description (closed, trading, closed, etc.) |
open_time | datetime.datetime | Last opening time |
OptionFilter Option Filter Chain
tigeropen.quote.domain.filter.OptionFilter
description
option filter parameter object
Parameters
Parameters | Type | Required | Description |
---|---|---|---|
implied_volatility | float | No | Implied 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_money | bool | No | in the money |
open_interest | int | No | Open 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 |
delta | float | No | delta, 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 |
gamma | float | No | gamma, Reflects the impact of stock price changes on delta. Every time the stock price changes by 1 yuan, delta changes gamma |
theta | float | No | theta, 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 |
vega | float | No | vega, Reflects the impact of volatility on option price changes. For every 1% change in volatility, the option price changes approximately vega |
rho | float | No | rho, 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 |