Query Account Information
Initialization
All examples on this page assume the following initialization has been completed:
from tigeropen.tiger_open_config import TigerOpenClientConfig
from tigeropen.trade.trade_client import TradeClient
client_config = TigerOpenClientConfig(props_path='your_config_directory_path')
trade_client = TradeClient(client_config)For details, see Prerequisites.
Get List of Managed Accounts
TradeClient.get_managed_accounts(account=None)
Description
Retrieves associated funding accounts. For institutional accounts, returns the main account and all sub-accounts.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID, optional, if not provided, returns all associated accounts |
Returns
A list of AccountProfile (tigeropen.trade.domain.profile.AccountProfile) objects
Each object has the following attributes:
| Parameter | Type | Description |
|---|---|---|
| account | Prime account: 50129912, Global: U5755619, Paper trading account: 20191221901212121 | Trading account. Prime account numbers contain 5-10 digits, paper trading account numbers contain 17 digits, and global account numbers start with U. |
| capability | RegTMargin | Account type (CASH: Cash account, RegTMargin: Reg T Margin account, PMGRN: Portfolio margin) |
| status | Funded | Account status, most scenarios return Funded status. Status includes: Funded (funded), Open (opened), Pending (pending opening), Rejected (opening rejected), Closed (closed) |
| account_type | STANDARD | Account category: GLOBAL (Global account), STANDARD (Prime account), PAPER (Paper Trading account) |
Example
accounts = trade_client.get_managed_accounts()
# View attributes of the first account
account1 = accounts[0]
print(account1.account) # Account number
print(account1.account_type) # Account category (prime/paper trading)
print(account1.capability) # Account capability (cash/margin)
Example Response
[AccountProfile({'account': 'DU000001', 'capability': None, 'status': 'Funded'})]
Get Prime/Paper Trading Account Asset Information
TradeClient.get_prime_assets(account=None, base_currency=None, consolidated=True)
Description
Retrieves asset information, applicable to prime/paper trading accounts.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID, if not specified, uses the default account in client_config |
| base_currency | str | No | Currency |
| consolidated | bool | No | Whether to display aggregated segment asset metrics. Only SEC and FUND category assets are aggregated. Defaults to True |
Returns
One PortfolioAccount object. Its structure is as follows.
For detailed explanations of fields in PortfolioAccount and Segment, please refer to Object Information
PortfolioAccount Object
├── account: Account ID
├── update_timestamp: Update time, timestamp in milliseconds
├── segments: Account information by product category, a dict with security category as key, value is Segment object
│ ├── 'S' represents Securities account, value is Segment object
│ │ ├── currency: Currency, such as USD, HKD
│ │ ├── capability: Account type, margin account: RegTMargin, cash account: Cash.
│ │ ├── category: Trading product category C: (Commodities futures), S: (Securities stocks)
│ │ ├── cash_balance: Cash amount.
│ │ ├── cash_available_for_trade: Available funds, including cash and financing limit, used as reference for maximum trading purchasing power.
│ │ ├── cash_available_for_withdrawal: Cash amount currently available for withdrawal from the account
│ │ ├── gross_position_value: Total securities value
│ │ ├── equity_with_loan: Total equity with loan value
│ │ ├── net_liquidation: Total assets; net liquidation value
│ │ ├── init_margin: Initial margin
│ │ ├── maintain_margin: Maintenance margin
│ │ ├── overnight_margin: Overnight margin
│ │ ├── unrealized_pl: Unrealized P&L
│ │ ├── realized_pl: Realized P&L
│ │ ├── excess_liquidation: Current excess liquidity
│ │ ├── overnight_liquidation: Overnight excess liquidity
│ │ ├── buying_power: Buying power
│ │ ├── leverage: Current leverage ratio used
│ │ ├── locked_funds: Locked funds
│ │ ├── uncollected: Funds in transit
│ │ ├── currency_assets: Account asset information by trading currency, a dict with currency as key
│ │ │ ├── 'USD' represents US Dollar, value is CurrencyAsset object
│ │ │ │ ├── currency: Current currency, common currencies include: USD-US Dollar, HKD-Hong Kong Dollar, SGD-Singapore Dollar, CNH-Renminbi
│ │ │ │ ├── cash_balance: Cash available for trading, plus locked cash portion (such as stocks purchased but not yet settled, and other situations that may have locked cash)
│ │ │ │ ├── cash_available_for_trade: Cash amount currently available for trading in the account
│ │ │ │ ├── forex_rate: Exchange rate from this currency to base_currency
│ │ │ ├── 'HKD' represents Hong Kong Dollar, value is CurrencyAsset object
│ │ └─ └── 'CNH' represents Renminbi, value is CurrencyAsset object
│ └── 'C' represents Futures account, value is Segment object
│ └── 'F' represents Fund account, value is Segment object
│ └── 'D' represents Crypto account, value is Segment object
Example
portfolio_account = trade_client.get_prime_assets(base_currency='USD') # Can set base currency
print(portfolio_account)
# Example of viewing account attributes
print(portfolio_account.account) # Account ID
print(portfolio_account.segments['S'].buying_power) # Securities account buying power
print(portfolio_account.segments['S'].cash_balance) # Securities account cash value
print(portfolio_account.segments['S'].unrealized_pl) # Unrealized P&L
print(portfolio_account.segments['S'].currency_assets['USD'].gross_position_value) # Total securities value in USD
print(portfolio_account.segments['S'].currency_assets['HKD'].gross_position_value) # Total securities value in HKD
print(portfolio_account.segments['S'].currency_assets['HKD'].cash_balance) # Cash value in HKD
print(portfolio_account.segments['C'].init_margin) # Futures account initial margin
print(portfolio_account.segments['C'].maintain_margin) # Futures account maintenance margin
print(portfolio_account.segments['C'].currency_assets['USD'].cash_balance) # Futures account cash value in USD
Example Response
PortfolioAccount(
{
'account': '1234567',
'update_timestamp': 1638949616442,
'segments': {
'S': Segment({
'currency': 'USD',
'capability': 'RegTMargin',
'category': 'S',
'cash_balance': 111978.7160247,
'cash_available_for_trade': 123905.775195,
'cash_available_for_withdrawal': 123905.775195,
'gross_position_value': 22113.5652986,
'equity_with_loan': 134092.2813233,
'net_liquidation': 135457.2802984,
'init_margin': 9992.3764097,
'maintain_margin': 8832.4423281,
'overnight_margin': 11607.5876493,
'unrealized_pl': -1121.0821891,
'realized_pl': -3256.0,
'excess_liquidation': 125259.8389952,
'overnight_liquidation': 122484.693674,
'buying_power': 495623.1007801,
'leverage': 0.164693,
'currency_assets': {
'USD': CurrencyAsset({
'currency': 'USD',
'cash_balance': 123844.77,
'cash_available_for_trade': 123792.77
}),
'HKD': CurrencyAsset({
'currency': 'HKD',
'cash_balance': -92554.07,
'cash_available_for_trade': -93664.15
}),
'CNH': CurrencyAsset({
'currency': 'CNH',
'cash_balance': 0.0,
'cash_available_for_trade': 0.0
})
}
}),
'C': Segment({
'currency': 'USD',
'capability': 'RegTMargin',
'category': 'C',
'cash_balance': 3483681.32,
'cash_available_for_trade': 3481701.32,
'cash_available_for_withdrawal': 3481701.32,
'gross_position_value': 1000000.0,
'equity_with_loan': 3481881.32,
'net_liquidation': 3483681.32,
'init_margin': 1980.0,
'maintain_margin': 1800.0,
'overnight_margin': 1800.0,
'unrealized_pl': 932722.41,
'realized_pl': -30.7,
'excess_liquidation': 3481881.32,
'overnight_liquidation': 3481881.32,
'buying_power': 0.0,
'leverage': 0.0,
'currency_assets': {
'USD': CurrencyAsset({
'currency': 'USD',
'cash_balance': 3483681.32,
'cash_available_for_trade': 3483681.32
}),
'HKD': CurrencyAsset({
'currency': 'HKD',
'cash_balance': 0.0,
'cash_available_for_trade': 0.0
}),
'CNH': CurrencyAsset({
'currency': 'CNH',
'cash_balance': 0.0,
'cash_available_for_trade': 0.0
})
}
})
}
})
Get Global Account Assets
TradeClient.get_assets(account=None, sub_accounts=None, segment=False, market_value=False)
Description
Returns account assets in the structure intended for global accounts. Prime and paper trading accounts can call this method, but many fields will be empty; use get_prime_assets for those account types.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID, if not specified, uses the default account in client_config |
| sub_accounts | list[str] or None | No | Sub-account list; None uses the account selected by account, which defaults to client_config.account |
| segment | bool | No | Whether to return data classified by product category (securities, futures), default False. When True, returns a dict where C represents futures, S represents stocks |
| market_value | bool | No | Whether to return data classified by currency (USD, HKD, CNH), default False |
Institutional users configure
secret_keyinclient_config; it is not aget_assetsmethod parameter.
Returns
list
Each element in the list is a PortfolioAccount object. If there is only one account, the list contains only one element.
The structure of the PortfolioAccount (tigeropen.trade.domain.account.PortfolioAccount) object is as follows.
For information about Account, SecuritySegment, CommoditySegment, please refer to Object Information
PortfolioAccount Object
├── account: Account ID
├── summary: Summary statistics for the current account. The value inside is an Account object
├── segments: Account information by product category, a dict
│ ├── 'S' represents Securities account, value is SecuritySegment object
│ └── 'C' represents Futures account, value is CommoditySegment object
├── market_values: Account statistics by currency, a dict
│ ├── 'USD' represents US Dollar, value is MarketValue object
│ ├── 'HKD' represents Hong Kong Dollar, value is MarketValue object
└─ └── 'CNH' represents Renminbi, value is MarketValue object
Example
portfolio_account = trade_client.get_assets(segment=True, market_value=True)
print(portfolio_account)
# View attributes of the first portfolio
portfolio1 = portfolio_account[0]
print(portfolio1.account) # Account ID
print(portfolio1.segments['S'].available_funds) # Available funds in securities account
print(portfolio1.segments['S'].gross_position_value) # Market value of securities account
print(portfolio1.segments['C'].available_funds) # Available funds in futures account (only has value if futures account is opened)
print(portfolio1.summary.buying_power) # Buying power
print(portfolio1.summary.cash) # Cash
Example Response
[PortfolioAccount({'account': 'DU111111',
'summary': Account({'accrued_cash': 0, 'accrued_dividend': 0, 'available_funds': 948.69,
'buying_power': 948.69, 'cash': 948.81, 'currency': 'USD', 'cushion': 0.5944,
'day_trades_remaining': 3, 'equity_with_loan': 1255.69, 'excess_liquidity': 948.81,
'gross_position_value': 647.53, 'initial_margin_requirement': 307,
'maintenance_margin_requirement': 307, 'net_liquidation': 1596.34,
'realized_pnl': 0, 'regt_equity': 1255.81,
'regt_margin': 153.5, 'sma': 3512.56,
'timestamp': 1561529631, 'unrealized_pnl': -885.36}),
'segments': defaultdict(<class 'tigeropen.trade.domain.account.Account'>,
{'C': CommoditySegment({'accrued_cash': 0, 'accrued_dividend': 0,
'available_funds': 0, 'cash': 0, 'equity_with_loan': 0, 'excess_liquidity': 0,
'initial_margin_requirement': 0, 'maintenance_margin_requirement': 0,
'net_liquidation': 0, 'timestamp': 1544393719}),
'S': SecuritySegment({'accrued_cash': 0, 'accrued_dividend': 0,
'available_funds': 120.73, 'cash': 120.73, 'equity_with_loan': 1292.04,
'excess_liquidity': 120.73, 'gross_position_value': 1171.31,
'initial_margin_requirement': 1171.31, 'leverage': 0.91,
'maintenance_margin_requirement': 1171.31, 'net_liquidation': 1292.04,
'regt_equity': 1292.04, 'regt_margin': 585.66, 'sma': 1973.39, 'timestamp': 1545206069})
}),
'market_values': defaultdict(<class 'tigeropen.trade.domain.account.MarketValue'>,
{'CNH': MarketValue({'currency': 'CNH', 'net_liquidation': 0, 'cash_balance': 0,
' stock_market_value': 0, 'option_market_value': 0,
'warrant_value': 0, 'futures_pnl': 0, 'unrealized_pnl': 0,
'realized_pnl': 0, 'exchange_rate': 0.14506,
'net_dividend': 0, 'timestamp': 1544078822}),
'HKD': MarketValue({'currency': 'HKD', 'net_liquidation': 0, 'cash_balance': 0,
'stock_market_value': 0, 'option_market_value': 0,
'warrant_value': 0, 'futures_pnl': 0, 'unrealized_pnl': 0,
'realized_pnl': 0, 'exchange_rate': 0.12743,
'net_dividend': 0, 'timestamp': 1550158606}),
'USD': MarketValue({'currency': 'USD', 'net_liquidation': 1596.34,
'cash_balance': 948.81, 'stock_market_value': 307,
'option_market_value': 340.53, 'warrant_value': 0,
'futures_pnl': 0, 'unrealized_pnl': -885.36,
'realized_pnl': 0, 'exchange_rate': 1,
'net_dividend': 0, 'timestamp': 1561519773})}
)}
)]Get Position Data
TradeClient.get_positions(account=None, sec_type=SecurityType.STK, currency=Currency.ALL, market=Market.ALL, symbol=None, sub_accounts=None, expiry=None, strike=None, put_call=None, asset_quote_type=None, lang=None)
Description
Retrieves account position information.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID; defaults to client_config.account |
| sec_type | SecurityType | No | Security type such as STK, OPT, or FUT; defaults to STK |
| currency | Currency | No | Currency such as ALL, USD, HKD, or CNH; defaults to ALL |
| market | Market | No | Market such as ALL, US, HK, or CN; defaults to ALL |
| symbol | str | No | Security symbol |
| sub_accounts | list[str] | No | Sub-account list |
| expiry | str | No | Option expiration date in yyyyMMdd format, e.g. 20220121 |
| strike | str | No | Option strike price, e.g. 100.5 |
| put_call | str | No | Option direction: PUT or CALL |
| asset_quote_type | str | No | Asset quote type, such as REAL_TIME |
| lang | Language | No | Language; defaults to the account configuration |
Returns
A list of Position objects. Common fields are:
| Field | Type | Description |
|---|---|---|
| account | str | Account ID |
| contract | Contract | Contract object; security attributes such as symbol, type, and currency are stored here |
| quantity | int | Legacy scaled position quantity |
| position_scale | int | Decimal scale for quantity; retained for compatibility |
| position_qty | float | Actual decimal position quantity |
| average_cost | float | Average cost including commission |
| average_cost_by_average | float | Average cost under average-cost accounting |
| average_cost_of_carry | float | Average cost under cost-of-carry accounting |
| market_price | float | Current market price; the API's latestPrice field maps to this property |
| market_value | float | Position market value |
| realized_pnl | float | Realized P&L |
| realized_pnl_by_average | float | Realized P&L under average-cost accounting |
| unrealized_pnl | float | Unrealized P&L |
| unrealized_pnl_by_average | float | Unrealized P&L under average-cost accounting |
| unrealized_pnl_percent | float | Unrealized P&L percentage |
| unrealized_pnl_percent_by_average | float | Unrealized P&L percentage under average-cost accounting |
| mm_value | float | Maintenance margin value |
| mm_percent | float | Maintenance margin percentage |
| salable_qty | float | Sellable quantity; also exposed through compatibility aliases salable and saleable |
| today_pnl | float | Today's P&L |
| today_pnl_percent | float | Today's P&L percentage |
| yesterday_pnl | float | Previous day's P&L |
| last_close_price | float | Previous close price |
| unrealized_pnl_by_cost_of_carry | float | Unrealized P&L under cost-of-carry accounting |
| unrealized_pnl_percent_by_cost_of_carry | float | Unrealized P&L percentage under cost-of-carry accounting |
| is_level0_price | bool | Whether the market price is a level-0 delayed quote |
Example
from tigeropen.common.consts import Currency, Market, SecurityType
positions = trade_client.get_positions(sec_type=SecurityType.STK, currency=Currency.ALL, market=Market.ALL)
position = positions[0]
print(position.contract.symbol)
print(position.average_cost)
print(position.quantity)
print(position.unrealized_pnl)Example Response
[contract: BABA/STK/USD, quantity: 1, average_cost: 178.99, market_price: 176.77,
contract: BIDU/STK/USD, quantity: 3, average_cost: 265.4633, market_price: 153.45]Get Historical Asset Analysis
TradeClient.get_analytics_asset(account=None, start_date=None, end_date=None, seg_type=None, currency=None, sub_account=None)
Description
Retrieves historical asset analysis for an account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID; defaults to client_config.account |
| start_date | str | No | Start date in yyyy-MM-dd format; defaults to 30 days before end_date |
| end_date | str | No | End date in yyyy-MM-dd format; defaults to the current date |
| seg_type | SegmentType | No | SegmentType.SEC for securities or SegmentType.FUT for futures |
| currency | Currency | No | Currency such as ALL, USD, HKD, or CNH |
| sub_account | str | No | Institutional sub-account |
Returns
dict[str, dict[str, float] | list[dict[str, int | float | str]]]
The result contains a summary dict and a history list.
summary fields
| Field | Type | Description |
|---|---|---|
| pnl | float | Profit or loss over the requested period |
| pnl_percentage | float | Return over the requested period |
| annualized_return | float | Estimated annualized return |
| over_user_percentage | float | Percentage of comparable users whose return was lower |
history item fields
| Field | Type | Description |
|---|---|---|
| date | int | Asset date as a millisecond timestamp |
| dt | str | SDK-generated local date in yyyy-MM-dd format |
| pnl | float | Profit or loss relative to the previous asset date |
| pnl_percentage | float | Return relative to the previous asset date |
| asset | float | Total asset value |
| cash_balance | float | Cash balance |
| gross_position_value | float | Gross market value of positions |
| deposit | float | Deposits recorded for the date |
| withdrawal | float | Withdrawals recorded for the date |
Example
from tigeropen.common.consts import SegmentType
result = trade_client.get_analytics_asset(start_date='2021-12-01', end_date='2021-12-07', seg_type=SegmentType.SEC)
print(result['summary']['pnl'])
for item in result['history']:
print(item['dt'], item['pnl'])Example Response
{
'summary': {
'pnl': 691.18,
'pnl_percentage': 0.0,
'annualized_return': 0.0,
'over_user_percentage': 0.0
},
'history': [
{
'date': 1638334800000,
'dt': '2021-12-01',
'pnl': 0.0,
'pnl_percentage': 0.0,
'asset': 48827609.65,
'cash_balance': 48811698.59,
'gross_position_value': 15911.06,
'deposit': 0.0,
'withdrawal': 0.0
},
{
'date': 1638421200000,
'dt': '2021-12-02',
'pnl': 78.04,
'pnl_percentage': 0.0,
'asset': 48827687.69,
'cash_balance': 48811698.59,
'gross_position_value': 15989.1,
'deposit': 0.0,
'withdrawal': 0.0
}
]
}Get Available Transfer Funds
TradeClient.get_segment_fund_available(from_segment=None, currency=None)
Description
Gets funds available to transfer from a segment of a prime or paper trading account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| from_segment | str or SegmentType | Yes | Source segment: SEC or FUT |
| currency | str or Currency | No | Transfer currency: USD or HKD |
Returns
list[SegmentFundAvailableItem], where each item contains:
| Field | Type | Description |
|---|---|---|
| from_segment | str | Source segment, SEC or FUT |
| currency | str | Transfer currency, USD or HKD |
| amount | float | Available amount in the specified currency |
available = trade_client.get_segment_fund_available(from_segment='SEC', currency='HKD')
print(available[0].amount)Example Response
[SegmentFundAvailableItem({'from_segment': 'SEC', 'currency': 'HKD', 'amount': 718859.79})]Internal Account Fund Transfer
TradeClient.transfer_segment_fund(from_segment=None, to_segment=None, amount=None, currency=None)
Description
Transfers funds between segments of a prime or paper trading account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| from_segment | str or SegmentType | Yes | Source segment: SEC or FUT |
| to_segment | str or SegmentType | Yes | Destination segment: SEC or FUT; must differ from from_segment |
| amount | float | Yes | Amount to transfer |
| currency | str or Currency | Yes | Transfer currency: USD or HKD |
Returns
A SegmentFundItem. See SegmentFundItem fields and statuses.
result = trade_client.transfer_segment_fund(from_segment='SEC', to_segment='FUT', amount=100, currency='USD')
print(result)Example Response
SegmentFundItem({'id': 30322815980011520, 'from_segment': 'SEC', 'to_segment': 'FUT',
'currency': 'USD', 'amount': 100.0, 'status': 'NEW', 'status_desc': 'Submitted',
'message': None, 'settled_at': None, 'updated_at': 1680243926131,
'created_at': 1680243926131})Cancel Internal Account Fund Transfer
TradeClient.cancel_segment_fund(id=None)
Description
Cancels a submitted transfer for a prime or paper trading account. A completed transfer cannot be canceled; reverse it with a new transfer in the opposite direction.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | int | Yes | Transfer record ID |
Returns
A SegmentFundItem. See SegmentFundItem fields and statuses.
result = trade_client.cancel_segment_fund(id=30322815980011520)
print(result)Example Response
SegmentFundItem({'id': 30322815980011520, 'from_segment': 'SEC', 'to_segment': 'FUT',
'currency': 'USD', 'amount': 100.0, 'status': 'CANC', 'status_desc': 'Cancelled',
'message': None, 'settled_at': None, 'updated_at': 1680243926131,
'created_at': 1680243926131})Internal Account Fund Transfer History
TradeClient.get_segment_fund_history(limit=None)
Description
Retrieves historical transfer records between different Segments of the account. Sorted by time in descending order (applicable to prime or paper trading accounts).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| limit | int | No | Number of recent transfer records to return. Defaults to 100; maximum 500 |
Returns
List[tigeropen.trade.domain.account.SegmentFundItem]
SegmentFundItem Description:
| Name | Type | Description |
|---|---|---|
| id | int | Transfer record ID |
| from_segment | str | Transfer from segment, FUT or SEC |
| to_segment | str | Transfer to segment, FUT or SEC |
| currency | str | Transfer currency, USD or HKD |
| amount | float | Transfer amount, unit: corresponding currency |
| status | str | Status (NEW/PROC/SUCC/FAIL/CANC) |
| status_desc | str | Status description (Submitted/Processing/Completed/Transfer Failed/Cancelled) |
| message | str | Failure message |
| settled_at | int | Settlement timestamp |
| updated_at | int | Update timestamp |
| created_at | int | Creation timestamp |
Status values:
| Status | Meaning |
|---|---|
NEW | Submitted |
PROC | Processing |
SUCC | Completed |
FAIL | Transfer failed; inspect message for details |
CANC | Canceled |
Example
from tigeropen.common.consts import SecurityType, Currency, Market
history = trade_client.get_segment_fund_history()
print(history)
Example Response
[SegmentFundItem({'id': 16256385456537600, 'from_segment': 'SEC', 'to_segment': 'FUT', 'currency': 'USD',
'amount': 100000.0, 'status': 'SUCC', 'status_desc': 'Completed', 'message': None,
'settled_at': 1572925581000, 'updated_at': 1572925578000, 'created_at': 1572925578000}),
SegmentFundItem({'id': 16256377863667712, 'from_segment': 'SEC', 'to_segment': 'FUT', 'currency': 'USD',
'amount': 100000.0, 'status': 'SUCC', 'status_desc': 'Completed', 'message': None,
'settled_at': 1572925525000, 'updated_at': 1572925520000, 'created_at': 1572925520000}),
SegmentFundItem({'id': 15554843128627200, 'from_segment': 'SEC', 'to_segment': 'FUT', 'currency': 'USD',
'amount': 100000.0, 'status': 'SUCC', 'status_desc': 'Completed', 'message': None, 'settled_at': 1567573240000,
'updated_at': 1567573235000, 'created_at': 1567573235000}),
SegmentFundItem({'id': 14039478715026432, 'from_segment': 'SEC', 'to_segment': 'FUT', 'currency': 'USD', 'amount': 10000.0, 'status': 'SUCC', 'status_desc': 'Completed', 'message': None, 'settled_at': 1556011922000, 'updated_at': 1556011922000, 'created_at': 1556011922000})]
Get Maximum Tradable Quantity
TradeClient.get_estimate_tradable_quantity(order, seg_type=None)
Description
Retrieves the maximum buyable/sellable quantity for a specific instrument in the account. Supports stocks and options, does not currently support futures.
Parameters
Order object (tigeropen.trade.domain.order.Order)
You can use utility functions from tigeropen.common.util.order_utils, such as limit_order(), market_order(), to generate order objects locally based on your specific order type and parameters. For creation methods, see Order Object - Construction Methods section
Supports only limit and stop orders.
Returns
tigeropen.trade.domain.position.TradableQuantityItem object with the following attributes:
| Field | Type | Description |
|---|---|---|
| tradable_quantity | float | Cash buyable/sellable quantity (if action is buy, returns buyable quantity, otherwise sellable quantity) |
| financing_quantity | float | Margin buyable/sellable quantity (not applicable to cash accounts) |
| position_quantity | float | Position quantity |
| tradable_position_quantity | float | Tradable position quantity |
Example
from tigeropen.common.consts import SecurityType, Currency, Market
from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import limit_order
contract = stock_contract(symbol='MSFT', currency='USD')
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=50, quantity=1)
res = trade_client.get_estimate_tradable_quantity(order)
print(res)Example Response
TradableQuantityItem<{'tradable_quantity': 28921.0, 'financing_quantity': 52657.0, 'position_quantity': 0.0, 'tradable_position_quantity': 0}>
Get Funding History
TradeClient.get_funding_history(seg_type=None)
Description
Retrieves the account's funding history.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| seg_type | SegmentType | No | Segment type |
Returns
pandas.DataFrame with the following fields:
| Field | Type | Description |
|---|---|---|
| id | long | ID |
| refId | string | Related business ID |
| type | int | Fund type (1: Deposit; 3: Withdrawal; 20: Withdrawal fee; 21: Withdrawal refund; 22: Withdrawal failure-refund; 23: Withdrawal fee-refund) |
| type_desc | string | Fund type description |
| currency | string | Currency |
| amount | double | Amount |
| business_date | string | Business date |
| completed_status | bool | Whether the transfer is complete |
| created_at | long | Creation timestamp |
| updated_at | long | Update timestamp |
Example
from tigeropen.common.consts import SecurityType, Currency, Market
res = trade_client.get_funding_history()
print(res)Example Response
id ref_id type type_desc currency amount business_date completed_status updated_at created_at
0 3000000 26 1 Deposit USD 484.88 2017/08/24 True 1503574430000 1503574430000
1 3000001 123 1 Deposit USD 2000.00 2017/12/15 True 1513308908000 1513308908000Get Fund Details
TradeClient.get_fund_details(self, seg_types, account=None, fund_type=None, currency=None, start=0, limit=None, start_date=None, end_date=None, secret_key=None, lang=None):
Description
Retrieves fund details.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| seg_types | list[str] | Yes | Account segment types, options: SegmentType.SEC for securities; SegmentType.FUT for futures, can be imported from tigeropen.common.consts.SegmentType. Available values: 'SEC', 'FUT', 'FUND' |
| account | str | No | Account ID. Defaults to the configured account. Supports only prime accounts |
| fund_type | int | No | Fund type, including: ALL (all), DEPOSIT_WITHDRAW (deposits/withdrawals), TRADE (trading), FEE (fees), FUNDS_TRANSFER (fund transfers), FOREX (currency exchange), CORPORATE_ACTION (corporate actions), ACTIVITY_AWARD (activities), OTHER (others). Default ALL |
| currency | Currency | No | Currency, including USD/HKD/CNH etc., can be imported from tigeropen.common.consts.Currency |
| start | int | No | Starting sequence number, starts from 0. For example, if each page has limit 50, and the first two pages returned 100 records, then for the 3rd page, start should be 100, continuing from the 101st record |
| limit | int | No | Maximum number of records to return, default 50, maximum 100 |
| start_date | str | No | Start date, format 'yyyy-MM-dd' |
| end_date | str | No | End date, format 'yyyy-MM-dd' |
| secret_key | str | No | Institutional secret key (individual developers don't need to fill this) |
| lang | Language | No | Supported language, use enum constants provided in tigeropen.common.consts.Language, such as Language.zh_CN, defaults to Language.en_US, see enumeration parameter section |
Returns
pandas.DataFrame with the following fields:
| Field | Type | Description |
|---|---|---|
| id | int | Record ID |
| desc | str | Description |
| currency | str | Currency |
| seg_type | str | SegmentType |
| type | str | Fund type |
| amount | float | Amount |
| business_date | str | Tiger-defined business date, all fund changes for the same trading day across all markets will be recorded under the same business date |
| updated_at | int | Transaction update timestamp |
| page | int | Current page number |
| limit | int | Records per page |
| item_count | int | Total record count |
| page_count | int | Total page count |
| timestamp | int | Timestamp |
| contract_name | str | Contract name |
Example
from tigeropen.common.consts import SecurityType, Currency, Market
result = trade_client.get_fund_details(
seg_types=[SegmentType.SEC, SegmentType.FUT],
start= 0,
limit = 50,
start_date='2025-03-28',
end_date='2025-04-04',
fund_type='ALL',
# currency = Currency.USD,
# lang = Language.en_US,
)
print(result)
# Paginated retrieval of all data
start = 0
limit = 50
final_result = pd.DataFrame()
while True:
res = trade_client.get_fund_details(seg_types=[SegmentType.SEC, SegmentType.FUT], start=start, limit=limit,start_date='2025-01-01', end_date='2025-05-01')
if res.empty:
break
start += limit
final_result = pd.concat([final_result, res], ignore_index=True)
print(final_result)
Example Response
id currency type desc contract_name seg_type amount business_date updated_at page limit item_count page_count timestamp
0 24924145889681231 USD Corporate Action Fee VFS-DIVIDEND SEC -0.10 2025-04-04 1743762173000 1 50 8 1 1745581047814
1 24924145889681229 USD Dividend VFS-DIVIDEND SEC 0.10 2025-04-04 1743762173000 1 50 8 1 1745581047814
2 24924145889681217 USD Corporate Action Fee VFS-DIVIDEND SEC 0.09 2025-04-04 1743762171000 1 50 8 1 1745581047814
3 24924145889681215 USD Dividend Tax VFS-DIVIDEND SEC 0.01 2025-04-04 1743762171000 1 50 8 1 1745581047814
4 24924145889681213 USD Dividend VFS-DIVIDEND SEC -0.10 2025-04-04 1743762171000 1 50 8 1 1745581047814
5 24924145889678880 USD Corporate Action Fee VFS-DIVIDEND SEC -0.09 2025-03-28 1743392460000 1 50 8 1 1745581047814
6 24924145889678878 USD Dividend Tax VFS-DIVIDEND SEC -0.01 2025-03-28 1743392460000 1 50 8 1 1745581047814
7 24924145889678876 USD Dividend VFS-DIVIDEND SEC 0.10 2025-03-28 1743392460000 1 50 8 1 1745581047814Updated 7 days ago
