Get Account Information
Account List TigerHttpRequest(MethodName.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 |
Response
com.tigerbrokers.stock.openapi.client.https.response.TigerHttpResponse
The data is formatted in json. See the following example for how to decode the data.
Attribute | Example | Description |
---|---|---|
account | DU575569 | 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
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);
TigerHttpRequest request = new TigerHttpRequest(MethodName.ACCOUNTS);
String bizContent = AccountParamBuilder.instance()
.account("123456")
.buildJsonWithoutDefaultAccount();
# query account infomation by defaultAccount in ClientConfig.DEFAULT_CONFIG
# String bizContent = AccountParamBuilder.instance().buildJson();
# query all account infomation
# String bizContent = AccountParamBuilder.instance().buildJsonWithoutDefaultAccount();
request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);
//Decode Data
JSONArray accounts = JSON.parseObject(response.getData()).getJSONArray("items");
JSONObject account1 = accounts.getJSONObject(0);
String capability = account1.getString("capability");
String accountType = account1.getString("accountType");
String account = account1.getString("account");
String status = account1.getString("status");
Return Example
{
"code": 0,
"message": "success",
"data":{
"items":[{
"account": "123456",
"capability": "RegTMargin",
"status": "Funded",
"accountType": "STANDARD",
}]
}
}
Get Account Positions PositionsRequest
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
com.tigerbrokers.stock.openapi.client.https.response.trade.PositionsResponse
Use List<PositionDetail> items = response.getItem().getPositions()
to get positions result. See examples below
PositionDetail
Description:
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
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);
PositionsRequest request = new PositionsRequest();
String bizContent = AccountParamBuilder.instance()
.account("13810712")
.secType(SecType.STK)
.buildJson();
request.setBizContent(bizContent);
PositionsResponse response = client.execute(request);
//get data
if (response.isSuccess()) {
System.out.println(JSONObject.toJSONString(response));
for (PositionDetail detail : response.getItem().getPositions()) {
String account = detail.getAccount();
String symbol = detail.getSymbol();
long position = detail.getPosition();
// ...
}
} else {
System.out.println(response.getMessage());
}
Response
{
"code": 0,
"data": {
"items": [
{
"account": "13810712",
"averageCost": 295.8904,
"averageCostByAverage": 295.8904,
"averageCostOfCarry": 591.7807,
"categories": [
],
"currency": "USD",
"identifier": "AAPL",
"lastClosePrice": 232.98,
"latestPrice": 232.44,
"level0Price": false,
"market": "US",
"marketValue": -232.44,
"mmPercent": 0,
"mmValue": 92.976,
"multiplier": 1,
"position": -1,
"positionQty": -1,
"positionScale": 0,
"realizedPnl": 0,
"realizedPnlByAverage": 0,
"salableQty": -1,
"secType": "STK",
"symbol": "AAPL",
"todayPnl": 0.54,
"todayPnlPercent": 0.0023178,
"unrealizedPnl": 63.4504,
"unrealizedPnlByAverage": 63.4504,
"unrealizedPnlByCostOfCarry": 359.3407,
"unrealizedPnlPercent": 0.2144,
"unrealizedPnlPercentByAverage": 0.2144,
"unrealizedPnlPercentByCostOfCarry": 0.6072,
"updateTimestamp": 1720685551097
},
{
"account": "13810712",
"averageCost": 65.3544,
"averageCostByAverage": 65,
"averageCostOfCarry": 65.3544,
"categories": [
],
"currency": "USD",
"identifier": "BABA",
"lastClosePrice": 76.01,
"latestPrice": 77.36,
"level0Price": false,
"market": "US",
"marketValue": 288.166,
"mmPercent": 0,
"mmValue": 172.8996,
"multiplier": 1,
"position": 3725,
"positionQty": 3.725,
"positionScale": 3,
"realizedPnl": 0,
"realizedPnlByAverage": -1.32,
"salableQty": 3.725,
"secType": "STK",
"symbol": "BABA",
"todayPnl": 5.02875,
"todayPnlPercent": 0.0177608,
"unrealizedPnl": 44.721,
"unrealizedPnlByAverage": 46.041,
"unrealizedPnlByCostOfCarry": 44.721,
"unrealizedPnlPercent": 0.1837,
"unrealizedPnlPercentByAverage": 0.1902,
"unrealizedPnlPercentByCostOfCarry": 0.1837,
"updateTimestamp": 1720685551097
}
]
},
"message": "success",
"sign": "Wjndi3ZrsxQYWWdkrNKSPMASGfkG5trdHbVujTKrcGoVE5cN0QZBInJggnVL2rMgKd5TS00mnGcOov96iR5K5gZKRA0iQmZHUjJHTmK9JY/rEP9A18xDaljFNHMqmJ8vydFjMQXLebXTVzafbkZoI9LS1LIdoiSCD+6VocogpB0=",
"success": true,
"timestamp": 1720685551132
}
Get Account Summary TigerHttpRequest(MethodName.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 |
Response
com.tigerbrokers.stock.openapi.client.https.response.TigerHttpResponse
The data is formatted in json. See the following example for how to decode the data.
Name | Example | Description |
---|---|---|
account | DU575569 | 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 | DU575569 | 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 | DU575569 | 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
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);
TigerHttpRequest request = new TigerHttpRequest(MethodName.ASSETS);
String bizContent = AccountParamBuilder.instance()
.account("DU575569")
.buildJson();
request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);
# Parsing specific fields
JSONArray assets = JSON.parseObject(response.getData()).getJSONArray("items");
JSONObject asset1 = assets.getJSONObject(0);
String account = asset1.getString("account");
Double cashBalance = asset1.getDouble("cashBalance");
JSONArray segments = asset1.getJSONArray("segments");
JSONObject segment = segments.getJSONObject(0);
String category = segment.getString("category"); // "S" stocks, "C" futures
Response Example
{
"code": 0,
"message": "success",
"data": {
"items": [{
"account": "DU575569",
"accruedCash": -763.2,
"accruedDividend": 0.0,
"availableFunds": 941031.78,
"buyingPower": 6273545.18,
"capability": "Reg T Margin",
"cashBalance": 469140.39,
"cashValue": 469140.39,
"currency": "USD",
"cushion": 0.778569,
"dayTradesRemaining": -1,
"equityWithLoan": 1233078.69,
"excessLiquidity": 960492.09,
"grossPositionValue": 865644.18,
"initMarginReq": 292046.91,
"maintMarginReq": 273170.84,
"netLiquidation": 1233662.93,
"netLiquidationUncertainty": 583.55,
"previousEquityWithLoanValue": 1216291.68,
"previousNetLiquidation": 1233648.34,
"realizedPnl": -31.68,
"unrealizedPnl": 1814.01,
"regTEquity": 0.0,
"regTMargin": 0.0,
"SMA": 0.0,
"segments": [{
"account": "DU575569",
"accruedDividend": 0.0,
"availableFunds": 65.55,
"cashValue": 65.55,
"category": "S",
"equityWithLoan": 958.59,
"excessLiquidity": 65.55,
"grossPositionValue": 893.04,
"initMarginReq": 893.04,
"leverage": 0.93,
"maintMarginReq": 893.04,
"netLiquidation": 958.59,
"previousDayEquityWithLoan": 969.15,
"regTEquity": 958.59,
"regTMargin": 446.52,
"sMA": 2172.47,
"title": "US Securities",
"tradingType": "STKMRGN",
"updateTime": 1541124813
}],
"marketValues": [{
"account": "DU575569",
"accruedCash": 0.0,
"cashBalance": -943206.03,
"currency": "HKD",
"exchangeRate": 0.1273896,
"futureOptionValue": 0.0,
"futuresPnl": 0.0,
"netDividend": 0.0,
"netLiquidation": 11223.29,
"optionMarketValue": 0.0,
"realizedPnl": -248.72,
"stockMarketValue": 943588.78,
"unrealizedPnl": -17039.09,
"updateTime": 1526368181000,
"warrantValue": 10958.0
},{
"account": "DU575569",
"accruedCash": 0.0,
"cashBalance": -1635.23,
"currency": "GBP",
"exchangeRate": 1.35566495,
"futureOptionValue": 0.0,
"futuresPnl": 0.0,
"netDividend": 0.0,
"netLiquidation": 170.39,
"optionMarketValue": 0.0,
"realizedPnl": 0.0,
"stockMarketValue": 1805.62,
"unrealizedPnl": 177.58,
"updateTime": 1526368181000,
"warrantValue": 0.0
},{
"account": "DU575569",
"accruedCash": 0.0,
"cashBalance": 703542.12,
"currency": "USD",
"exchangeRate": 1.0,
"futureOptionValue": 0.0,
"futuresPnl": 0.0,
"netDividend": 0.0,
"netLiquidation": 1208880.15,
"optionMarketValue": -64.18,
"realizedPnl": 0.0,
"stockMarketValue": 505780.03,
"unrealizedPnl": 19886.87,
"updateTime": 1526359227000,
"warrantValue": 0.0
}, {
"account": "DU575569",
"accruedCash": 0.0,
"cashBalance": -714823.64,
"currency": "CNH",
"exchangeRate": 0.1576904,
"futureOptionValue": 0.0,
"futuresPnl": 0.0,
"netDividend": 0.0,
"netLiquidation": 142250.72,
"optionMarketValue": 0.0,
"realizedPnl": 0.0,
"stockMarketValue": 859152.75,
"unrealizedPnl": -102371.43,
"updateTime": 1526368181000,
"warrantValue": 0.0
}]
},
"timestamp": 1527830042620
}
Get Asset for Prime/Paper Account
PrimeAssetRequest
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 |
Response
com.tigerbrokers.stock.openapi.client.https.response.trade.PrimeAssetResponse
Use PrimeAssetItem.Segment segment = primeAssetResponse.getSegment(Category.S)
for asset informations categorized by segments For each asset segment,use PrimeAssetItem.CurrencyAssets assetByCurrency = segment.getAssetByCurrency(Currency.USD)
to get asset categorized by currencies. See examples below
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
PrimeAssetRequest assetRequest = PrimeAssetRequest.buildPrimeAssetRequest("572386", Currency.USD);
assetRequest.setConsolidated(Boolean.TRUE);
PrimeAssetResponse primeAssetResponse = client.execute(assetRequest);
//Get asset list in your stock segment
PrimeAssetItem.Segment segment = primeAssetResponse.getSegment(Category.S);
System.out.println("segment: " + JSONObject.toJSONString(segment));
//get your USD asset list
if (segment != null) {
PrimeAssetItem.CurrencyAssets assetByCurrency = segment.getAssetByCurrency(Currency.USD);
System.out.println("assetByCurrency: " + JSONObject.toJSONString(assetByCurrency));
}
>>> segment: {"buyingPower":482651.8815597,"capability":"RegTMargin","cashAvailableForTrade":120662.9703899,"cashAvailableForWithdrawal":120662.9703899,"cashBalance":109829.460975,"category":"S","currency":"USD","currencyAssets":[{"cashAvailableForTrade":96353.34,"cashBalance":97008.79,"currency":"USD","grossPositionValue":8933.81,"optionMarketValue":0.0,"realizedPL":-3256.0,"stockMarketValue":8933.81,"unrealizedPL":3656.5633333},{"cashAvailableForTrade":98889.91,"cashBalance":99999.99,"currency":"HKD","grossPositionValue":95510.8,"optionMarketValue":0.0,"realizedPL":0.0,"stockMarketValue":95510.8,"unrealizedPL":-44555.184536},{"cashAvailableForTrade":0.0,"cashBalance":0.0,"currency":"CNH"}],"equityWithLoan":131008.3976131,"excessLiquidation":122581.4537219,"grossPositionValue":21178.9366381,"initMargin":9547.8475046,"leverage":0.1614001,"maintainMargin":8426.9438913,"netLiquidation":132373.3965882,"overnightLiquidation":121191.7607219,"overnightMargin":9816.6368913,"realizedPL":-3256.0,"unrealizedPL":-2055.7108496}
>>> assetByCurrency: {"cashAvailableForTrade":96353.34,"cashBalance":97008.79,"currency":"USD","grossPositionValue":8933.81,"optionMarketValue":0.0,"realizedPL":-3256.0,"stockMarketValue":8933.81,"unrealizedPL":3656.5633333}
Response Example
{
"code":0,
"data":{
"accountId":"572386",
"segments":[
{
"buyingPower":878.52,
"capability":"CASH",
"cashAvailableForTrade":878.52,
"cashBalance":6850.79,
"category":"S",
"consolidatedSegTypes":[
"SEC",
"FUND"
],
"currency":"USD",
"currencyAssets":[
{
"cashAvailableForTrade":35.89,
"cashBalance":6008.16,
"currency":"USD"
},
{
"cashAvailableForTrade":5351.53,
"cashBalance":5351.53,
"currency":"HKD"
},
{
"cashAvailableForTrade":1123.95,
"cashBalance":1123.95,
"currency":"CNH"
},
{
"cashAvailableForTrade":0.12,
"cashBalance":0.12,
"currency":"EUR"
}
],
"equityWithLoan":8891.76,
"excessLiquidation":6850.79,
"grossPositionValue":438.78,
"initMargin":2040.96,
"leverage":0.23,
"maintainMargin":2040.96,
"netLiquidation":7289.57,
"overnightLiquidation":6850.79,
"overnightMargin":2040.96,
"realizedPL":0,
"unrealizedPL":73.29
},
{
"buyingPower":878.52,
"capability":"CASH",
"cashAvailableForTrade":878.52,
"cashBalance":0,
"category":"F",
"consolidatedSegTypes":[
"SEC",
"FUND"
],
"currency":"USD",
"currencyAssets":[
{
"cashAvailableForTrade":0,
"cashBalance":0,
"currency":"USD"
},
{
"cashAvailableForTrade":0,
"cashBalance":0,
"currency":"HKD"
},
{
"cashAvailableForTrade":0,
"cashBalance":0,
"currency":"CNH"
}
],
"equityWithLoan":8891.76,
"excessLiquidation":6850.79,
"grossPositionValue":1602.18,
"initMargin":2040.96,
"leverage":0.23,
"maintainMargin":2040.96,
"netLiquidation":1602.18,
"overnightLiquidation":6850.79,
"overnightMargin":2040.96,
"realizedPL":1.25,
"unrealizedPL":89.35
}
],
"updateTimestamp":1704355652720
},
"message":"success",
"sign":"ZBp+e3IAcPbujB/BIijAh9F1PXQaIiqn5pxldBTPdz88W/hz6rezJsnmuvG+kLbieBWmRiVCt5Ah3eTM9ynLK4BZjRixo2OGJ0XcKotZf0qGDAF3E34acQSbH1te6xCEZMeDunptXNGUcveTgNW2dscLt121MtsLwoXh8T5bUS0=",
"success":true,
"timestamp":1704355652720
}
Get Asset Analytics for Prime Account PrimeAnalyticsAssetRequest
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
com.tigerbrokers.stock.openapi.client.https.response.trade.PrimeAnalyticsAssetResponse
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
PrimeAnalyticsAssetRequest assetRequest = PrimeAnalyticsAssetRequest.buildPrimeAnalyticsAssetRequest(
"402901").segType(SegmentType.SEC).startDate("2021-12-01").endDate("2021-12-07");
PrimeAnalyticsAssetResponse primeAssetResponse = client.execute(assetRequest);
if (primeAssetResponse.isSuccess()) {
JSONObject.toJSONString(primeAssetResponse.getSummary());
JSONObject.toJSONString(primeAssetResponse.getHistory());
}
Response Example
{
"code":0,
"message":"success",
"timestamp":1657616435212,
"data":{
"summary":{
"pnl":691.18,
"pnlPercentage":0,
"annualizedReturn":0,
"overUserPercentage":0
},
"history":[
{
"date":1638334800000,
"asset":48827609.65,
"pnl":0,
"pnlPercentage":0,
"cashBalance":48811698.59,
"grossPositionValue":15911.06,
"deposit":0,
"withdrawal":0
},
{
"date":1638421200000,
"asset":48827687.69,
"pnl":78.04,
"pnlPercentage":0,
"cashBalance":48811698.59,
"grossPositionValue":15989.1,
"deposit":0,
"withdrawal":0
},
{
"date":1638507600000,
"asset":48827583.18,
"pnl":-26.47,
"pnlPercentage":0,
"cashBalance":48811698.59,
"grossPositionValue":15884.58,
"deposit":0,
"withdrawal":0
},
{
"date":1638766800000,
"asset":48827804.28,
"pnl":194.63,
"pnlPercentage":0,
"cashBalance":48811698.59,
"grossPositionValue":16105.68,
"deposit":0,
"withdrawal":0
},
{
"date":1638853200000,
"asset":48828300.83,
"pnl":691.18,
"pnlPercentage":0,
"cashBalance":48811723,
"grossPositionValue":16577.82,
"deposit":0,
"withdrawal":0
}
]
},
"sign":"BFcQVHP4Rh0WAoQMAkVErZq1LKLlhPHx5X+77xNjpsIJF62Zr3T8UXDNvT3fSRA/Pt8cV8Ju3scYq/ollZU169ckh7rVpmeXSxJBaJ8Wfq5tOex7K1BkyHVEcH8i1c6aSph00Nm1yUqcTss/jVvN8uAXYoIBFCELV9nu7r1T4wA="
}
Get Available Fund for Prime Account
Request:SegmentFundAvailableRequest
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
com.tigerbrokers.stock.openapi.client.https.response.trade.SegmentFundAvailableResponse
Use List<SegmentFundAvailableItem> items = response.getSegmentFundAvailableItems()
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 |
---|---|---|
fromSegment | string | from segment, FUT/SEC |
currency | string | currency,USD/HKD |
amount | double | transferable funds |
Example
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
ClientConfig.DEFAULT_CONFIG);
SegmentFundAvailableRequest request = SegmentFundAvailableRequest.buildRequest(
SegmentType.SEC, Currency.HKD);
SegmentFundAvailableResponse response = client.execute(request);
System.out.println(JSONObject.toJSONString(response));
// get transferable funds data
for (SegmentFundAvailableItem item : response.getSegmentFundAvailableItems()) {
System.out.println(JSONObject.toJSONString(item));
}
Response Example
{
"code":0,
"data":[
{
"amount":17607412.84,
"currency":"HKD",
"fromSegment":"SEC"
}
],
"message":"success",
"sign":"jbxGKQiv5staJJOsN9CnMz25TxWk9jq6iZLksLg09aeP60QfFoSkNIGrnwdv3x0cgYc+SHj6vWdJGQ8FRo/DubxR6pyb6N6iiLl+TANQkvct0MERk7nygEhvQiYXD2q5gj2jPuDAfS6fVzkrYLWEaXQp3RrfqBDNJj+TRVhLRiw=",
"success":true,
"timestamp":1679902705608
}
Transfer Fund for Prime Account
Request:SegmentFundTransferRequest
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
com.tigerbrokers.stock.openapi.client.https.response.trade.SegmentFundResponse
Use SegmentFundItem item = response.getSegmentFundItem()
to get transfer result. See examples below
SegmentFundItem
Description:
Name | Type | Description |
---|---|---|
id | long | Transfer record ID |
fromSegment | string | from segment, FUT/SEC |
toSegment | 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
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
ClientConfig.DEFAULT_CONFIG);
SegmentFundTransferRequest request = SegmentFundTransferRequest.buildRequest(
SegmentType.SEC, SegmentType.FUT, Currency.HKD, 1000D);
SegmentFundResponse response = client.execute(request);
System.out.println(JSONObject.toJSONString(response));
Response Example
{
"code":0,
"data":{
"amount":1000,
"createdAt":1680076000672,
"currency":"HKD",
"fromSegment":"SEC",
"id":30300805635506176,
"status":"NEW",
"statusDesc":"NEW",
"toSegment":"FUT",
"updatedAt":1680076000672
},
"message":"success",
"sign":"eBhM+F2Kmc1QA0LX5R5yAoz/Ugi1kizUFjjaY378zsXPj69XkMunOOmmOcUR0evo/toHIG1Scd4AlVameVDE7SWQsVt6B+L7UBjI1iU9top79ewxbXkGTc/e4ketQgHfqqF9aR/eHIdZRZjKOvNEdfWfjzKTmQJiAaHhXNVfFJ0=",
"success":true,
"timestamp":1680076000819
}
Cancel Funds Transfer for Prime Account
Request:SegmentFundCancelRequest
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
com.tigerbrokers.stock.openapi.client.https.response.trade.SegmentFundResponse
Use SegmentFundItem item = response.getSegmentFundItem()
to get transfer result. See examples below
SegmentFundItem
Description:
Name | Type | Description |
---|---|---|
id | long | Transfer record ID |
fromSegment | string | from segment, FUT/SEC |
toSegment | 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
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
ClientConfig.DEFAULT_CONFIG);
SegmentFundCancelRequest request = SegmentFundCancelRequest.buildRequest(30300805635506176L);
SegmentFundResponse response = client.execute(request);
if (response.isSuccess()) {
System.out.println(JSONObject.toJSONString(response));
} else {
System.out.println("cancel fail." + JSONObject.toJSONString(response));
}
Response Example
{
"code":1200,
"message":"standard account response error(fail:The transfer cannot be cancelled now)",
"timestamp":1680077452633
}
Query Historical Funds Transfer for Prime Account
Request:SegmentFundHistoryRequest
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
com.tigerbrokers.stock.openapi.client.https.response.trade.SegmentFundsResponse
Use List<SegmentFundItem> items = response.getSegmentFundItems()
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 |
fromSegment | string | from segment, FUT/SEC |
toSegment | 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
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
ClientConfig.DEFAULT_CONFIG);
SegmentFundHistoryRequest request = SegmentFundHistoryRequest.buildRequest(30);
SegmentFundsResponse response = client.execute(request);
if (response.isSuccess()) {
System.out.println(JSONObject.toJSONString(response));
} else {
System.out.println("cancel fail." + JSONObject.toJSONString(response));
}
Response Example
{
"code":0,
"data":[
{
"amount":1000,
"createdAt":1680076001000,
"currency":"HKD",
"fromSegment":"SEC",
"id":30300805635506176,
"settledAt":1680076001000,
"status":"SUCC",
"statusDesc":"SUCCESS",
"toSegment":"FUT",
"updatedAt":1680076001000
},
{
"amount":1000,
"createdAt":1679307031000,
"currency":"HKD",
"fromSegment":"SEC",
"id":30200015261794304,
"settledAt":1679307032000,
"status":"SUCC",
"statusDesc":"SUCCESS",
"toSegment":"FUT",
"updatedAt":1679307031000
}
],
"message":"success",
"sign":"g9B9Q20F56qoUVs1ULaWZMC5h1DYp7E7GeQnkd2TR5tw2R85TnO7xVb79sqB4EFZEEtI+So8gqh71hABiz31VrQy32zGmYGSgFA94jI6sFh4//BJA0IG9vGx1PmO/rv9aomK+17XGJ4PDrqxHBuGczaX4i65Wvoyt5wHdAx2qoU=",
"success":true,
"timestamp":1680085312913
}
Get Max 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
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
EstimateTradableQuantityRequest request = EstimateTradableQuantityRequest.buildRequest(
SecType.STK, "AAPL", ActionType.BUY, OrderType.LMT, 150D, null);
EstimateTradableQuantityResponse response = client.execute(request);
if (response.isSuccess()) {
System.out.println(JSONObject.toJSONString(response));
} else {
System.out.println("fail." + JSONObject.toJSONString(response));
}
Response Example
{
"code":0,
"data":{
"positionQuantity":1,
"tradablePositionQuantity":1,
"tradableQuantity":45
},
"message":"success",
"sign":"mBmBqdIum+F8PE9yHis8v64My2P9rBorsYwtLNAr/Hei6oRedvl5YyfBV2H9zHUHOYcJJDukrD74IfnUsJW1PS6YUQdt+MirNc3Bm51gMrjiVFed8JTto4wRqXvuX57wcA3gMCLVDJkbqjU5VD64cCl28A38N8vdgRo7HgcS8pM=",
"success":true,
"timestamp":1681789228649
}