Get Account Information
Account List
Request:TigerRequest(TradeApiService.ACCOUNTS)
Description
Fetch a list of managed accounts of the current user, along with account information.
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | No | Account id. Optional,Default value is to return all managed accounts |
ResponseTigerOpenAPI.Trade.Response.AccountsResponse
source
Use AccountsResponse.Data
to access returned data. This method will return a dictionary which include AccountItem
object, whereTigerOpenAPI.Trade.Response.AccountItem
has the following attributes:
Attribute | Example | Description |
---|---|---|
account | 50129912 | Account id |
capability | MRGN | Account Types (CASH: cash account, RegTMargin: Reg T Margin Account, PMGRN: Portfolio Margin) |
status | Funded | Status (New, Funded, Open, Pending, Abandoned, Rejected, Closed, Unknown) |
accountType | STANDARD | Account Type. GLOBAL or STANDARD (Prime), PAPER Account |
Example
static async Task<AccountsResponse?> GetAccountsAsync(TradeClient tradeClient)
{
TigerRequest<AccountsResponse> request = new TigerRequest<AccountsResponse>()
{
ApiMethodName = TradeApiService.ACCOUNTS,
ModelValue = new ApiModel() {}
};
return await tradeClient.ExecuteAsync(request);
}
Return Example
{
"data":{
"items":[
{
"account":"U10010705",
"capability":"CASH",
"accountType":"GLOBAL",
"status":"Funded"
},
{
"account":"572386",
"capability":"CASH",
"accountType":"STANDARD",
"status":"Funded"
},
{
"account":"20200821144442583",
"capability":"RegTMargin",
"accountType":"PAPER",
"status":"Funded"
}
]
},
"message":"success",
"timestamp":1678256819942,
"sign":"GRqdliGzHYXU/LbLk5+S5HxHQ10hv2ERmMPGPrVGzPiIsT69TS4XkTE6I9PfxUtsnYDWfxlMgfHLZslT8PtYITfw9E6GjSrk5u7fokMsxpi6DD+EyTlvXoAuchppkc55uMPBMrFD4zkJBT+tn79sp/OiudLPnISKuUa69b08Qm0="
}
Get Account Positions
Request:TigerRequest(TradeApiService.POSITIONS)
Description
Get the position information of the account
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id. Example :13810712 |
sec_type | string | No | Security Type. Possible values are STK-Stocks/OPT-Options/FUT-Futures/FUND-Funds, default value is STK. |
currency | string | No | Currency. Possible values areALL/USD/HKD/CNH, etc., default value is ALL |
market | string | No | Market, including: ALL/US/HK/C. Default value isALL |
symbol | string | No | Ticker symbol, for example: 600884 / SNAP (stocks), CL1901 (futures),'AAPL 190111C00095000' (Options). For option contracts,fill in identifier instead. A option contract identifier is a 21 digit string, where symbol of the underlying assets has 6 digits (fill with space if less than 6). |
secret_key | string | No | Institutional trader key. Only applicable to institutional users. It needs to be configured in client_config. Ignore if you are a individual developer |
expiry | string | No | Options/warrant/CBBC expiration date, format: 'yyyyMMdd', example: '20230818' |
strike | double | No | Options/warrant/CBBC strike price, example: 100.5 |
right | string | No | 'PUT' / 'CALL' for options/warrant/CBBC |
Response
TigerOpenAPI.Trade.Response.PositionsResponse
source
Use PositionsResponse.Data
to access returned data. This method will return a dictionary which include PositionsItem
object, whereTigerOpenAPI.Trade.Response.PositionDetail
has the following attributes:
Argument | Type | Description |
---|---|---|
account | string | Account id |
positionQty | double | Position quantity |
salableQty | double | Saleable quantity |
position | long | Position quantity(deprecated, please use 'positionQty') |
positionScale | int | Position quantity scale(deprecated, please use 'positionQty''), For example, the position value is 11123, the positionScale is 2, and the actual number of positions is 11123*10^(-2)=111.23 |
averageCost | double | Average holding cost |
averageCostByAverage | double | Average holding cost under the average price mode |
averageCostOfCarry | double | Cumulative average holding cost |
latestPrice | double | Latest market price |
isLevel0Price | boolean | is lv0(delay) quote |
marketValue | double | Market Value |
realizedPnl | double | Realized profit and loss |
realizedPnlByAverage | double | Realized profit and loss under the average price mode |
unrealizedPnl | double | unrealized profit and loss |
unrealizedPnlByAverage | double | unrealized profit and loss under the average price cost mode |
unrealizedPnlPercent | double | unrealized rate of return |
unrealizedPnlPercentByAverage | double | Unrealized rate of return under average price cost |
unrealizedPnlByCostOfCarry | double | unrealized profit and loss |
unrealizedPnlPercentByCostOfCarry | double | unrealized rate of return |
multiplier | double | multiplier or lotsize |
market | string | market |
currency | string | Currency |
secType | string | Security type, STK/OPT/FUT |
identifier | string | asset identifier |
symbol | string | Ticker symbol/identifier of the asset |
strike | double | Strike price of the option |
expiry | string | Option expiration date |
right | string | Whether an option contract is put or call |
updateTimestamp | long | update timestamp |
mmPercent | double | maintenance margin percent |
mmValue | double | maintenance margin value |
todayPnl | double | today's profit and loss |
todayPnlPercent | double | today's profit and loss |
yesterdayPnl | double | yesterday's profit and loss, Fund only |
lastClosePrice | double | The closing price on the last trading day (pre-adjusted for stock rights) |
categories | List<string> | contract categories |
Example
static async Task<PositionsResponse?> GetPositionsAsync(TradeClient tradeClient)
{
TigerRequest<PositionsResponse> request = new TigerRequest<PositionsResponse>()
{
ApiMethodName = TradeApiService.POSITIONS,
ModelValue = new PositionsModel() {
SecType = SecType.STK,
Market = Market.US }
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"code": 0,
"message": "success",
"timestamp": 1720700158597,
"data": {
"items": [
{
"symbol": "AAPL",
"market": "US",
"contractId": 14,
"secType": "STK",
"account": "13810712",
"position": -1,
"positionScale": 0,
"positionQty": -1,
"salableQty": -1,
"averageCost": 295.8904,
"averageCostByAverage": 295.8904,
"unrealizedPnl": 63.8904,
"unrealizedPnlByAverage": 63.8904,
"unrealizedPnlPercent": 0.2159,
"unrealizedPnlPercentByAverage": 0.2159,
"unrealizedPnlByCostOfCarry": 359.7807,
"unrealizedPnlPercentByCostOfCarry": 0.608,
"realizedPnl": 0,
"realizedPnlByAverage": 0,
"averageCostOfCarry": 591.7807,
"marketValue": -232,
"currency": "USD",
"multiplier": 1,
"status": 0,
"identifier": "AAPL",
"latestPrice": 232,
"isLevel0Price": false,
"updateTimestamp": 1720700169189,
"comboTypeMap": {
},
"mmPercent": 0,
"mmValue": 92.8,
"todayPnl": 0.98,
"todayPnlPercent": 0.0042064,
"categories": [
],
"lastClosePrice": 232.98
},
{
"symbol": "BABA",
"market": "US",
"contractId": 592,
"secType": "STK",
"account": "13810712",
"position": 3725,
"positionScale": 3,
"positionQty": 3.725,
"salableQty": 3.725,
"averageCost": 65.3544,
"averageCostByAverage": 65,
"unrealizedPnl": 43.827,
"unrealizedPnlByAverage": 45.147,
"unrealizedPnlPercent": 0.18,
"unrealizedPnlPercentByAverage": 0.1865,
"unrealizedPnlByCostOfCarry": 43.827,
"unrealizedPnlPercentByCostOfCarry": 0.18,
"realizedPnl": 0,
"realizedPnlByAverage": -1.32,
"averageCostOfCarry": 65.3544,
"marketValue": 287.272,
"currency": "USD",
"multiplier": 1,
"status": 0,
"identifier": "BABA",
"latestPrice": 77.12,
"isLevel0Price": false,
"updateTimestamp": 1720700169189,
"comboTypeMap": {
},
"mmPercent": 0,
"mmValue": 172.3632,
"todayPnl": 4.13475,
"todayPnlPercent": 0.0146033,
"categories": [
],
"lastClosePrice": 76.01
}
]
},
"sign": "k5iFwEi79vYme05OiHfn8q8yqpf634QhPvOa+xLOyIE1L4+/oBwf9zSA2dgWqYg8KwX7GAWVp/Nus/aVNaRT4dbE7tk6tJDbZEDBRM4o/6CqsoZUHIr0YnDYarMcGEw3Nyvhc8+EmbifNmvcTo4v5o3I+lHen+qPC3rWBcj+W1Q="
}
Get Account Summary
Request:TigerRequest(TradeApiService.ASSETS)
Description
Get account summary,this method is only recommended for Global Account. You can also get the account summary of your standard, or paper trading account using this method. However, because different account types have different account structures, Please use PrimeAssetRequest to get assets for prime and paper acount.
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id: DU575569 |
segment | boolean | No | hether to return data grouped by segments (securities, futures). Default value is False. When set to True, a dict will be returned, where 'C' means futures, 'S' means stocks |
market_value | boolean | No | Whether to return data grouped by currency (USD, HKD, RMB). Default is False |
secret_key | string | No | Institutional trader key. Only applicable to institutional users. Configured in client_config |
ResponseTigerOpenAPI.Model.TigerDictResponse
source
Use TigerDictResponse.Data
to access returned data. This method will return a dictionary which has the following attributes:
Name | Example | Description |
---|---|---|
account | U10010705 | account id |
capability | RegTMargin | Account type. Margin account:RegTMargin,cash account:Cash |
netLiquidation | 1233662.93 | Net liquidation, equivalent to total asset in the TigerTrade APP |
equityWithLoan | 1233078.69 | Equity with loan value (including loan value assets). Securities Segment: Cash value + stock value, Futures Segment: Cash value - maintenance margin |
initMarginReq | 292046.91 | Initial margin requirement |
maintMarginReq | 273170.84 | Maintenance margin requirement |
availableFunds | 941031.78 | Available_funds for trading, equals to equity_with_loan - initial_margin_requirement |
dayTradesRemaining | -1 | amount of trade you can make today, -1 stands for unlimited |
excessLiquidity | 960492.09 | 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 |
buyingPower | 6273545.18 | 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 |
cashValue | 469140.39 | cash value in stock account+ cash value in futures account |
accruedCash | -763.2 | The accumulated interest payable in the current month, updated daily. |
accruedDividend | 0.0 | Cumulative dividends. Refers to the cumulative value of all dividends that have been executed but not paid |
grossPositionValue | 865644.18 | Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values. |
SMA | 0.0 | For security segments only. Overnight risk control value, the overnight risk of account positions is checked about 10 minutes before the close of each trading day. The overnight risk control value needs to be greater than 0, otherwise some positions in the account will be forced to close before the market closes. If the overnight risk control value is lower than 0 during the trading day, and the time is not 10 minutes before the closing time, the account will not be liquidated. |
regTEquity | 0.0 | float |
regTMargin | 0.0 | For security segments only, i.e. initial margin requirements calculated under Regulation T |
cushion | 0.778569 | The ratio of remaining liquidity to total assets, calculated as: excess_liquidity/net_liquidation |
currency | USD | Currency |
realizedPnl | -248.72 | Realized PNL |
unrealizedPnl | -17039.09 | Unrealized PNL |
updateTime | 0 | Update at |
segments | Account information grouped by different asset types. It is a Map with two keys: 'S' stands for stocks, 'C' stands for futures. The corresponding values are Account objects | |
marketValues | Market Values. It is a Map with currency names as keys: for example: 'USD' or 'HKD'; corresponding values are MarketValue objects. |
segments
Description:
Name | Example | Description |
---|---|---|
account | U10010705 | Account id |
category | S | Segment category C (Futures) or S (Securities) |
title | US Securities | tile |
netLiquidation | 1233662.93 | Net Liquidation Value |
cashValue | 469140.39 | cash value in stock account+ cash value in futures account |
availableFunds | 941031.78 | Amount of cash that can be traded in the current account |
equityWithLoan | 1233078.69 | Equity with loan value (including loan value assets). Securities Segment: cash value + stock value, futures Segment: cash value - maintenance margin |
excessLiquidity | 960492.09 | 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 |
accruedCash | -763.2 | The accumulated interest payable in the current month, updated according to the daily |
accruedDividend | 0.0 | Accumulated dividends. Refers to the accumulated value of all dividends that have been executed but not paid |
initMarginReq | 292046.91 | Initial Margin |
maintMarginReq | 273170.84 | Maintenance Margin |
regTEquity | 0.0 | Only for the securities segment, that is, the equity with loan (including the loan equity value) calculated according to the Regulation T Act |
regTMargin | 0.0 | For security segments only, i.e. initial margin requirements calculated under Regulation T |
SMA | 0.0 | For security segments only. Overnight risk control value, the overnight risk of account positions is checked about 10 minutes before the close of each trading day. The overnight risk control value needs to be greater than 0, otherwise some positions in the account will be forced to close before the market closes. If the overnight risk control value is lower than 0 during the trading day, and the time is not 10 minutes before the closing time, the account will not be liquidated. |
grossPositionValue | 865644.18 | Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values. |
leverage | 1 | leverage |
updateTime | 1526368181000 | last update at |
marketValues
Descirption:
Name | Type | Description |
---|---|---|
account | U10010705 | Account |
currency | USD | Currency |
netLiquidation | 1233662.93 | Net Liquidation(Equivalent to Total Asset in TigerTrade APP) |
cashBalance | 469140.39 | Cash |
exchangeRate | 0.1273896 | Exchange rate to USD (or primary currency of your account) |
netDividend | 0.0 | Net dividend |
futuresPnl | 0.0 | Futures profit and loss |
realizedPnl | -248.72 | Realized profit and loss |
unrealizedPnl | -17039.09 | Unrealized profit and loss |
updateTime | 1526368181000 | Updated at |
stockMarketValue | 943588.78 | market value of stock positions |
optionMarketValue | 0.0 | market value of option postions |
futureOptionValue | 0.0 | total market value of futures positions |
warrantValue | 10958.0 | total market value of warrant positions |
Example
static async Task<TigerDictResponse?> GetGlobalAssetsAsync(TradeClient tradeClient)
{
TigerRequest<TigerDictResponse> request = new TigerRequest<TigerDictResponse>()
{
ApiMethodName = TradeApiService.ASSETS,
ModelValue = new GlobalAssetsModel() {
Account = "U10010705",
Segment = true, MarketValue = true
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":{
"items":[
{
"account":"U10010705",
"capability":"Reg T Margin",
"accruedCash":0,
"accruedDividend":0,
"buyingPower":38988.82,
"equityWithLoan":10220.44,
"grossPositionValue":1302.78,
"regTEquity":10220.53,
"initMarginReq":473.24,
"maintMarginReq":390.35,
"availableFunds":9747.2,
"excessLiquidity":9830.17,
"cushion":0.9618,
"dayTradesRemaining":-1,
"realizedPnL":0,
"unrealizedPnL":-597.19,
"netLiquidation":10220.53,
"cashValue":8917.75,
"currency":"USD",
"updateTime":1678258433,
"segments":[
{
"account":"U10010705",
"category":"S",
"title":"US Securities",
"netLiquidation":10220.53,
"cashValue":8917.75,
"availableFunds":9747.2,
"equityWithLoan":10220.44,
"excessLiquidity":9830.17,
"accruedDividend":0,
"initMarginReq":473.24,
"maintMarginReq":390.35,
"grossPositionValue":1302.78,
"leverage":0.13,
"updateTime":1678258433,
"regTEquity":10220.53,
"regTMargin":651.39,
"sma":12098.83
},
{
"account":"U10010705",
"category":"C",
"title":"US Commodities",
"netLiquidation":0,
"cashValue":0,
"availableFunds":0,
"equityWithLoan":0,
"excessLiquidity":0,
"accruedDividend":0,
"initMarginReq":0,
"maintMarginReq":0,
"grossPositionValue":0,
"leverage":0,
"updateTime":1662226983
}
],
"marketValues":[
{
"account":"U10010705",
"currency":"HKD",
"netLiquidation":896.32,
"cashBalance":-1890.41,
"accruedCash":0,
"stockMarketValue":2786.73,
"optionMarketValue":0,
"futureOptionValue":0,
"warrantValue":0,
"netDividend":0,
"futuresPnl":0,
"realizedPnl":0,
"unrealizedPnl":-815.88,
"exchangeRate":0.12738895,
"updateTime":1678258160
},
{
"account":"U10010705",
"currency":"JPY",
"netLiquidation":827.81,
"cashBalance":828,
"accruedCash":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futureOptionValue":0,
"warrantValue":0,
"netDividend":0,
"futuresPnl":0,
"realizedPnl":0,
"unrealizedPnl":0,
"exchangeRate":0.00713265,
"updateTime":1662226983
},
{
"account":"U10010705",
"currency":"GBP",
"netLiquidation":66.68,
"cashBalance":66.69,
"accruedCash":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futureOptionValue":0,
"warrantValue":0,
"netDividend":0,
"futuresPnl":0,
"realizedPnl":0,
"unrealizedPnl":0,
"exchangeRate":1.15129995,
"updateTime":1662226983
},
{
"account":"U10010705",
"currency":"USD",
"netLiquidation":270.58,
"cashBalance":-0.78,
"accruedCash":0,
"stockMarketValue":271.36,
"optionMarketValue":0,
"futureOptionValue":0,
"warrantValue":0,
"netDividend":0,
"futuresPnl":0,
"realizedPnl":0,
"unrealizedPnl":-639,
"exchangeRate":1,
"updateTime":1678237280
},
{
"account":"U10010705",
"currency":"CNH",
"netLiquidation":68031.13,
"cashBalance":63312.18,
"accruedCash":0,
"stockMarketValue":4719.29,
"optionMarketValue":0,
"futureOptionValue":0,
"warrantValue":0,
"netDividend":0,
"futuresPnl":0,
"realizedPnl":0,
"unrealizedPnl":1016.82,
"exchangeRate":0.1433296,
"updateTime":1678258433
}
],
"sma":12098.83
}
]
},
"message":"success",
"timestamp":1678258561486,
"sign":"VcI8Hvzkzr5wJ3DKfamj+/S5QeRt5jI1ifeulqX4OigRAvLrbUy135wG0tT2PVHoGtfjATDEwXk3cmrsSwQnVOgPuJaq69G7Odox036PUt01ZUj9NPK1g1qCHPxs4YthHKHnpQ5Yt7qGmZfvlucL5T8EvjqWpM/JL3xYt5YyMjE="
}
Get Asset for Prime Account
Request:TigerRequest(TradeApiService.PRIME_ASSETS)
Description
Get asset information for prime and paper trading account
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id, example: 123123 |
base_currency | string | No | Currency, HKD/USD |
secret_key | string | No | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
consolidated | boolean | No | Whether to display consolidated segment indicators, only SEC and FUND category assets will be aggregated. Default value is true |
ResponseTigerOpenAPI.Trade.Response.PrimeAssetResponse
source
Use PrimeAssetResponse.Data
to access returned data. This method will return a PrimeAssetItem
object, whereTigerOpenAPI.Trade.Response.Segment
has the following attributes:
PrimeAssetItem.Segment
Description:
Name | Type | Example | Description |
---|---|---|---|
account | String | 123123 | Account id |
currency | String | USD | Currency |
category | String | S | Securities Category C: (Commodities Futures), S: (Securities Stocks), F: (Funds) |
capability | String | RegTMargin | Account Type, Margin: RegTMargin, Cash: Cash RegTMargin, |
buyingPower | Double | 6273545.18 | 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 |
cashAvailableForTrade | Double | 1233662.1 | Amount of cash and margin that can be traded in the current account |
cashAvailableForWithdrawal | Double | 1233662.1 | Amount of cash that can be withdrawn in the current account |
cashBalance | Double | 469140.39 | 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) |
grossPositionValue | Double | 865644.18 | Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values |
initMargin | Double | 292046.91 | initial margin requirement. |
maintainMargin | Double | 273170.84 | Maintenance margin requirement |
overnightMargin | Double | 273170.84 | Overnight margin requirement |
excessLiquidation | Double | 960492.09 | 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 |
overnightLiquidation | Double | 1233662.93 | 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 |
netLiquidation | Double | 1233662.93 | Total Assets (Net Liquidation Value) - Securities Segment: Cash Value + Stock Value + Stock Option Value - Futures Segment: Cash Value + Mark-to-Market Profit and Loss |
equityWithLoan | Double | 1233078.69 | Equity with loan value (asset with loan value) - Securities Segment: Cash Value + Stock Value - Futures Segment: Cash Value - Maintenance Margin |
realizedPL | Double | -248.72 | Today's Realized P&L |
unrealizedPL | Double | -17039.09 | Unrealized profit and loss |
leverage | Double | 0.5 | leverage |
currencyAssets | CurrencyAssets | show asset information according to different currencies | |
consolidatedSegTypes | string | consolidated Segment. The following are the fields of consolidated Segment:cashAvailableForTrade、initMargin、maintainMargin、overnightMargin、excessLiquidation、overnightLiquidation、buyingPower、lockedFunds、leverage |
PrimeAssetItem.CurrencyAssets
:
Name | Example | Description |
---|---|---|
currency | USD | Current currency, commonly used currencies include: USD-US dollar, HKD-Hong Kong dollar, SGD-Singapore dollar, CNH-RMB |
cashBalance | 469140.39 | 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) |
cashAvailableForTrade | 0.1273896 | The amount of cash that can be traded in the current account |
realizedPL | -248.72 | realizd profit and loss of the account |
unrealizedPL | -17039.09 | Unrealizd profit and loss of the account |
stockMarketValue | 943588.78 | Market value of the stocks in this account |
optionMarketValue | 0.0 | Market value of the options in this account |
futuresMarketValue | 0.0 | Market value of futures in this account, 0 when category='S'(stocks) |
Example
static async Task<PrimeAssetResponse?> GetPrimeAssetsAsync(TradeClient tradeClient)
{
TigerRequest<PrimeAssetResponse> request = new TigerRequest<PrimeAssetResponse>()
{
ApiMethodName = TradeApiService.PRIME_ASSETS,
ModelValue = new PrimeAssetsModel()
{
Account = "572386",
BaseCurrency = Currency.USD.ToString(),
Consolidated = true
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":{
"accountId":"572386",
"updateTimestamp":1704356640023,
"segments":[
{
"capability":"CASH",
"category":"S",
"currency":"USD",
"cashBalance":6850.83,
"cashAvailableForTrade":878.56,
"cashAvailableForWithdrawal":0,
"grossPositionValue":438.99,
"equityWithLoan":8892,
"netLiquidation":7289.82,
"initMargin":2041.17,
"maintainMargin":2041.17,
"overnightMargin":2041.17,
"unrealizedPL":73.49,
"realizedPL":0,
"excessLiquidation":6850.83,
"overnightLiquidation":6850.83,
"buyingPower":878.56,
"leverage":0.23,
"totalTodayPL":-1.35,
"lockedFunds":5972.27,
"currencyAssets":[
{
"currency":"USD",
"cashBalance":6008.16,
"cashAvailableForTrade":35.89,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
},
{
"currency":"HKD",
"cashBalance":5351.53,
"cashAvailableForTrade":5351.53,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
},
{
"currency":"CNH",
"cashBalance":1123.95,
"cashAvailableForTrade":1123.95,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
},
{
"currency":"EUR",
"cashBalance":0.12,
"cashAvailableForTrade":0.12,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
}
],
"consolidatedSegTypes":[
"SEC",
"FUND"
]
},
{
"capability":"CASH",
"category":"F",
"currency":"USD",
"cashBalance":0,
"cashAvailableForTrade":878.56,
"cashAvailableForWithdrawal":0,
"grossPositionValue":1602.18,
"equityWithLoan":8892,
"netLiquidation":1602.18,
"initMargin":2041.17,
"maintainMargin":2041.17,
"overnightMargin":2041.17,
"unrealizedPL":89.35,
"realizedPL":1.25,
"excessLiquidation":6850.83,
"overnightLiquidation":6850.83,
"buyingPower":878.56,
"leverage":0.23,
"totalTodayPL":-11.78,
"lockedFunds":5972.27,
"currencyAssets":[
{
"currency":"USD",
"cashBalance":0,
"cashAvailableForTrade":0,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
},
{
"currency":"HKD",
"cashBalance":0,
"cashAvailableForTrade":0,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
},
{
"currency":"CNH",
"cashBalance":0,
"cashAvailableForTrade":0,
"grossPositionValue":0,
"stockMarketValue":0,
"optionMarketValue":0,
"futuresMarketValue":0,
"unrealizedPL":0,
"realizedPL":0
}
],
"consolidatedSegTypes":[
"SEC",
"FUND"
]
}
]
},
"code":0,
"message":"success",
"timestamp":1704356640023,
"sign":"jNmgtsOWiLu35nEV922Jsyx9OfHYBtAXNG/Fo5U2yk/KTOwVb9+IMJRDY7Z1sSEpHGQ1rN7VqBRutb9xV3HrrTk4CaAkApVyl/JglvW6dnstMWcdq1chr0eZWXQbo520ZTFlZzef9oBu6pBMYJgNKMhUFK/QeBKDlq44hWylRog="
}
Get Asset Analytics for Prime Account
Request:TigerRequest(TradeApiService.ANALYTICS_ASSET)
Description Get historical asset analysis data for prime and paper trading account.
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id |
start_date | string | No | start date, format yyyy-MM-dd, like '2022-01-01', end_date |
end_date | string | No | end date, format yyyy-MM-dd, like '2022-02-01', if missing, use current date |
seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities |
currency | Currency | No | currency,include ALL/USD/HKD/CNH |
sub_account | str | No | Sub-account (for institutional accounts only), if this field is setted, the assets of the sub-account will be returned |
secret_key | string | No | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
Response TigerOpenAPI.Trade.Response.PrimeAssetResponse`source
Use PrimeAnalyticsAssetResponse.Data
to access returned data. This method will return a PrimeAnalyticsAssetItem
object, whereTigerOpenAPI.Trade.Response.Summary
and TigerOpenAPI.Trade.Response.HistoryItem
has the following attributes:
PrimeAnalyticsAssetItem.Summary
Description:
Field | Type | Description |
---|---|---|
pnl | double | profit and loss |
pnlPercentage | double | profit and loss's percentage |
annualizedReturn | double | annualized return |
overUserPercentage | double | over user's percentage |
PrimeAnalyticsAssetItem.HistoryItem
Description:
Field | Type | Description |
---|---|---|
date | long | Date timestamp in milliseconds |
pnl | double | Amount of profit or loss compared to the previous day |
pnlPercentage | double | Yield compared to the previous day |
asset | double | Total assets amount |
cashBalance | double | Cash balance |
grossPositionValue | double | position market value |
deposit | double | deposit amount |
withdrawal | double | withdrawal amount |
Example
static async Task<PrimeAnalyticsAssetResponse?> GetAssetsAnalyticsAsync(TradeClient tradeClient)
{
TigerRequest<PrimeAnalyticsAssetResponse> request = new TigerRequest<PrimeAnalyticsAssetResponse>()
{
ApiMethodName = TradeApiService.ANALYTICS_ASSET,
ModelValue = new PrimeAnalyticsAssetModel()
{
Account = "572386",
StartDate = "2023-02-26"
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":{
"summary":{
"pnl":11.95,
"pnlPercentage":0.14,
"annualizedReturn":6.39,
"overUserPercentage":80
},
"history":[
{
"date":1677387600000,
"asset":8496.26,
"pnl":"NaN",
"cashBalance":8236.66,
"grossPositionValue":259.59
},
{
"date":1677474000000,
"asset":8498.54,
"pnl":2.28,
"pnlPercentage":0.03,
"cashBalance":8237.04,
"grossPositionValue":261.5
},
{
"date":1677560400000,
"asset":8495.41,
"pnl":-0.85,
"pnlPercentage":-0.01,
"cashBalance":8236.94,
"grossPositionValue":258.47
},
{
"date":1677646800000,
"asset":8500.93,
"pnl":4.67,
"pnlPercentage":0.05,
"cashBalance":8238.07,
"grossPositionValue":262.86
},
{
"date":1677733200000,
"asset":8499.22,
"pnl":2.96,
"pnlPercentage":0.03,
"cashBalance":8237.44,
"grossPositionValue":261.78
},
{
"date":1677819600000,
"asset":8506.96,
"pnl":10.7,
"pnlPercentage":0.13,
"cashBalance":8237.78,
"grossPositionValue":269.18
},
{
"date":1677906000000,
"asset":8507.04,
"pnl":10.78,
"pnlPercentage":0.13,
"cashBalance":8237.83,
"grossPositionValue":269.2
},
{
"date":1677992400000,
"asset":8506.77,
"pnl":10.51,
"pnlPercentage":0.12,
"cashBalance":8237.58,
"grossPositionValue":269.18
},
{
"date":1678078800000,
"asset":8508.21,
"pnl":11.95,
"pnlPercentage":0.14,
"cashBalance":8236.98,
"grossPositionValue":271.23
}
]
},
"message":"success",
"timestamp":1678260763093,
"sign":"ReuiDxqXjA0gAk523tOn9kAi/cr+naPzC4O9WA6xpXqUBHL1AbbZ04IgTpy2HcRcZEoSA9KNlokbdJekAWvtyYxtoSAd6Bsc4a2+b+RoNHDNaaVPOQv97AQXTWgNOKbcQF7dYN2N2GlJiRuRFBEkpvWe2XjhhGyGaYl+d1WokHE="
}
Get Available Fund for Prime Account
Request:TigerRequest(TradeApiService.SEGMENT_FUND_AVAILABLE)
Description
Get available fund for prime and paper trading account
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id |
from_segment | string | No | from segment, FUT/SEC |
currency | string | No | currency,USD/HKD |
Response
TigerOpenAPI.Trade.Response.SegmentFundAvailableResponse
Use SegmentFundAvailableResponse.Data
to get a list of the amount of funds that can be transferred out of each segment. See examples below
SegmentFundAvailableItem
Description:
Name | Type | Description |
---|---|---|
fromSegmentl | string | from segment, FUT/SEC |
currency | string | currency,USD/HKD |
amount | double | transferable funds |
Example
static async Task<SegmentFundAvailableResponse?> QueryAvailableSegmentFundAsync(TradeClient tradeClient)
{
TigerRequest<SegmentFundAvailableResponse> request = new TigerRequest<SegmentFundAvailableResponse>()
{
ApiMethodName = TradeApiService.SEGMENT_FUND_AVAILABLE,
ModelValue = new SegmentFundModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
FromSegment = SegmentType.SEC,
Currency = Currency.HKD,
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":[
{
"fromSegment":"SEC",
"currency":"HKD",
"amount":17595363.61
}
],
"message":"success",
"timestamp":1680526884978,
"sign":"TNfWuz1DjasvBUuDBabmmZZ2yXpUWsSbwkjFuKamdouqO7KnW0Yaa9YYOq9nR03t0cCirVYAjS1KHMJNh6WMxI+BTo1eOXz6ZmuCtRaI5uAk71JW6Ft3MQb/fgYGro7DmqntuabUZXQzVU2JeeHPjZwjdqTFiFUT14HU+51VTXk="
}
Transfer Fund for Prime Account
Request:TigerRequest(TradeApiService.TRANSFER_SEGMENT_FUND)
Description
Transfer funds under different segments of the account
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id |
from_segment | string | Yes | from segment, FUT/SEC |
to_segment | string | Yes | target segment, FUT/SEC,must be different from 'from_segment' |
currency | string | Yes | currency,USD/HKD |
amount | double | Yes | amount |
Response
TigerOpenAPI.Trade.Response.SegmentFundResponse
Use SegmentFundResponse.Data
to get transfer result. See examples below
SegmentFundItem
Description:
Name | Type | Description |
---|---|---|
id | long | Transfer record ID |
fromSegmentl | string | from segment, FUT/SEC |
toSegmentl | string | target segment, FUT/SEC |
currency | string | currency, USD/HKD |
amount | double | transfer amount |
status | string | status(NEW/PROC/SUCC/FAIL/CANC) |
statusDesc | string | status description |
message | string | fail message |
settledAt | long | settled timestamp |
updatedAt | long | updated timestamp |
createdAt | long | created timestamp |
Example
static async Task<SegmentFundResponse?> TransferSegmentFundAsync(TradeClient tradeClient)
{
TigerRequest<SegmentFundResponse> request = new TigerRequest<SegmentFundResponse>()
{
ApiMethodName = TradeApiService.TRANSFER_SEGMENT_FUND,
ModelValue = new SegmentFundModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
FromSegment = SegmentType.SEC,
ToSegment = SegmentType.FUT,
Currency = Currency.HKD,
Amount = 1000D,
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":{
"id":30359957871001600,
"fromSegment":"SEC",
"toSegment":"FUT",
"currency":"HKD",
"amount":1000,
"status":"NEW",
"statusDesc":"NEW",
"updatedAt":1680527296445,
"createdAt":1680527296445
},
"message":"success",
"timestamp":1680527201025,
"sign":"CCKYzvfew5GoF8XeNhfd/CzOZH6iCTnHcGGxSF8QgNkupHeMMAxQfmL0oeJ15T1HYL/m4cPciTQFtcXHezDjAf+vfV2kaPnlwXmAZCoCXD5pir4ppObFEBYISRqJls271zbJJ5PnZPCCtdm/osDWxEYgf6yp3LCQdjoT958gm2A="
}
Cancel Funds Transfer for Prime Account
Request:TigerRequest(TradeApiService.CANCEL_SEGMENT_FUND)
Description
Cancel the submitted fund transfer. If the transfer has been successful and cannot be cancelled, can swap 'from_segment' and 'to_segment', transfer again.
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id |
id | long | Yes | Transfer record ID |
Response
TigerOpenAPI.Trade.Response.SegmentFundResponse
Use SegmentFundResponse.Data
to get transfer result. See examples below
SegmentFundItem
Description:
Name | Type | Description |
---|---|---|
id | long | Transfer record ID |
fromSegmentl | string | from segment, FUT/SEC |
toSegmentl | string | target segment, FUT/SEC |
currency | string | currency, USD/HKD |
amount | double | transfer amount |
status | string | status(NEW/PROC/SUCC/FAIL/CANC) |
statusDesc | string | status description |
message | string | fail message |
settledAt | long | settled timestamp |
updatedAt | long | updated timestamp |
createdAt | long | created timestamp |
Example
static async Task<SegmentFundResponse?> CancelSegmentFundAsync(TradeClient tradeClient, Int64 id)
{
TigerRequest<SegmentFundResponse> request = new TigerRequest<SegmentFundResponse>()
{
ApiMethodName = TradeApiService.CANCEL_SEGMENT_FUND,
ModelValue = new SegmentFundModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
Id = id,
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"code":1200,
"message":"standard account response error(fail:The transfer cannot be cancelled now)",
"timestamp":1680527502129
}
Query Historical Funds Transfer for Prime Account
Request:TigerRequest(TradeApiService.SEGMENT_FUND_HISTORY)
Description
Query historical transfer records between account segments.in reverse chronological order
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | string | Yes | Account id |
limit | Integer | No | Returns the number of records. The default is 100, the maximum is 500 |
Response
TigerOpenAPI.Trade.Response.SegmentFundsResponse
Use SegmentFundsResponse.Data
to get a list of the historical transfer records between account segments. See examples below
SegmentFundItem
Description:
Name | Type | Description |
---|---|---|
id | long | Transfer record ID |
fromSegmentl | string | from segment, FUT/SEC |
toSegmentl | string | target segment, FUT/SEC |
currency | string | currency, USD/HKD |
amount | double | transfer amount |
status | string | status(NEW/PROC/SUCC/FAIL/CANC) |
statusDesc | string | status description |
message | string | fail message |
settledAt | long | settled timestamp |
updatedAt | long | updated timestamp |
createdAt | long | created timestamp |
Example
static async Task<SegmentFundsResponse?> QueryTransferFundsAsync(TradeClient tradeClient)
{
TigerRequest<SegmentFundsResponse> request = new TigerRequest<SegmentFundsResponse>()
{
ApiMethodName = TradeApiService.SEGMENT_FUND_HISTORY,
ModelValue = new SegmentFundModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
Limit = 50,
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":[
{
"id":30359957871001600,
"fromSegment":"SEC",
"toSegment":"FUT",
"currency":"HKD",
"amount":1000,
"status":"SUCC",
"statusDesc":"SUCCESS",
"settledAt":1680527297000,
"updatedAt":1680527296000,
"createdAt":1680527296000
},
{
"id":30300805635506176,
"fromSegment":"SEC",
"toSegment":"FUT",
"currency":"HKD",
"amount":1000,
"status":"SUCC",
"statusDesc":"SUCCESS",
"settledAt":1680076001000,
"updatedAt":1680076001000,
"createdAt":1680076001000
},
{
"id":30200015261794304,
"fromSegment":"SEC",
"toSegment":"FUT",
"currency":"HKD",
"amount":1000,
"status":"SUCC",
"statusDesc":"SUCCESS",
"settledAt":1679307032000,
"updatedAt":1679307031000,
"createdAt":1679307031000
}
],
"message":"success",
"timestamp":1680527722804,
"sign":"WmjP2HKxmuK+s9yHi2NwEhKlNJX9f+643R3UsJuSkiFb8RkHnTiYabsXzAIuWYzHm1y9bM9l0mdv827zS6/ZjAludr1fmpKmgILnUIxm/6n4ljZvYm+8pu576Jjl1zNV6I8yXI7EO7vQk1agpNdw/4v4xXj1efTG5MujmHJWPHk="
}
Get Max Tradable Quantity
Request:TigerRequest(TradeApiService.ESTIMATE_TRADABLE_QUANTITY)
Description
Get the maximum quantity that can be bought or sold. Support stocks, options, excluding futures.
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | String | Yes | Account id, prime account only |
symbol | String | Yes | ticker symbol |
expiry | String | No, required when sec_type is OPT/WAR/IOPT | Expiration Date,yyyyMMdd |
right | String | No, required when sec_type is OPT/WAR/IOPT | CALL/PUT |
strike | String | No, required when sec_type is OPT/WAR/IOPT | Strike price |
seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for Securities |
sec_type | SecType | No | STK/WAR/IOPT/OPT |
action | ActionType | Yes | Order direction: BUY/SELL |
order_type | OrderType | Yes | Order Types,'MKT'-Market Order / 'LMT'-Limit Order / 'STP'-Stop Order / 'STP_LMT'-Stop-Limit Order |
limit_price | double | No | Limit price, required if order_type is LMT or STP_LMT |
stop_price | double | No | Stop price, required if order_type is STP or STP_LMT |
secretKey | String | No | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
Response
TigerOpenAPI.Trade.Response.EstimateTradableQuantityResponse
Use EstimateTradableQuantityResponse.Data
to get TradableQuantityItem
object. See examples below
TradableQuantityItem
Description:
Name | Example | Description |
---|---|---|
tradableQuantity | Double | tradable quantity for cash |
financingQuantity | Double | tradable quantity for margin |
positionQuantity | Double | position quantity |
tradablePositionQuantity | Double | tradable quantity in the position |
Example
static async Task<EstimateTradableQuantityResponse?> GetMaxTradableQuantityAsync(TradeClient tradeClient)
{
TigerRequest<EstimateTradableQuantityResponse> request = new TigerRequest<EstimateTradableQuantityResponse>()
{
ApiMethodName = TradeApiService.ESTIMATE_TRADABLE_QUANTITY,
ModelValue = new EstimateTradableQuantityModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
SecType = SecType.STK,
Symbol = "AAPL",
Action = ActionType.BUY,
OrderType = OrderType.LMT,
LimitPrice = 150,
}
};
return await tradeClient.ExecuteAsync(request);
}
Response Example
{
"data":{
"tradableQuantity":45,
"financingQuantity":"NaN",
"positionQuantity":1,
"tradablePositionQuantity":1
},
"code":0,
"message":"success",
"timestamp":1681798582434,
"sign":"nAQLlyEZqhbOF+/4QxGZgXEsbhaHX6lv4XmytES+ytqxrCpg7yG3Sjgnu3vglSYWtsKYRO23XCgVQIGzQnQSykqxyamC8abPi2HtqGAE1Pbn1B/1JDxZ9rGm0J4t7B2aj7WSnGUDr1cIPctjM8yaEAnUC1m+6Jq7v2DhBgTD4xc="
}