Get Account Information

About 14 min

Account List TigerHttpRequest(MethodName.ACCOUNTS)

Description

Fetch a list of managed accounts of the current user, along with account information.

Argument

ArgumentTypeRequiredDescription
accountstringNoAccount 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.

AttributeExampleDescription
accountDU575569Account id
capabilityMRGNAccount Types (CASH: cash account, RegTMargin: Reg T Margin Account, PMGRN: Portfolio Margin)
statusFundedStatus (New, Funded, Open, Pending, Abandoned, Rejected, Closed, Unknown)
accountTypeSTANDARDAccount 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

ArgumentTypeRequiredDescription
accountstringYesAccount id. Example :13810712
sec_typestringNoSecurity Type. Possible values are STK-Stocks/OPT-Options/FUT-Futures/FUND-Funds, default value is STK.
currencystringNoCurrency. Possible values areALL/USD/HKD/CNH, etc., default value is ALL
marketstringNoMarket, including: ALL/US/HK/C. Default value isALL
symbolstringNoTicker 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_keystringNoInstitutional trader key. Only applicable to institutional users. It needs to be configured in client_config. Ignore if you are a individual developer
expirystringNoOptions/warrant/CBBC expiration date, format: 'yyyyMMdd', example: '20230818'
strikedoubleNoOptions/warrant/CBBC strike price, example: 100.5
rightstringNo'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

PositionDetailDescription:

ArgumentTypeDescription
accountstringAccount id
positionQtydoublePosition quantity
salableQtydoubleSaleable quantity
positionlongPosition quantity(deprecated, please use 'positionQty')
positionScaleintPosition 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
averageCostdoubleAverage holding cost
averageCostByAveragedoubleAverage holding cost under the average price mode
averageCostOfCarrydoubleCumulative average holding cost
latestPricedoubleLatest market price
isLevel0Pricebooleanis lv0(delay) quote
marketValuedoubleMarket Value
realizedPnldoubleRealized profit and loss
realizedPnlByAveragedoubleRealized profit and loss under the average price mode
unrealizedPnldoubleunrealized profit and loss
unrealizedPnlByAveragedoubleunrealized profit and loss under the average price cost mode
unrealizedPnlPercentdoubleunrealized rate of return
unrealizedPnlPercentByAveragedoubleUnrealized rate of return under average price cost
unrealizedPnlByCostOfCarrydoubleunrealized profit and loss
unrealizedPnlPercentByCostOfCarrydoubleunrealized rate of return
multiplierdoublemultiplier or lotsize
marketstringmarket
currencystringCurrency
secTypestringSecurity type, STK/OPT/FUT
identifierstringasset identifier
symbolstringTicker symbol/identifier of the asset
strikedoubleStrike price of the option
expirystringOption expiration date
rightstringWhether an option contract is put or call
updateTimestamplongupdate timestamp
mmPercentdoublemaintenance margin percent
mmValuedoublemaintenance margin value
todayPnldoubletoday's profit and loss
todayPnlPercentdoubletoday's profit and loss
yesterdayPnldoubleyesterday's profit and loss, Fund only
lastClosePricedoubleThe closing price on the last trading day (pre-adjusted for stock rights)
categoriesList<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

ArgumentTypeRequiredDescription
accountstringYesAccount id: DU575569
segmentbooleanNohether 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_valuebooleanNoWhether to return data grouped by currency (USD, HKD, RMB). Default is False
secret_keystringNoInstitutional 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.

NameExampleDescription
accountDU575569account id
capabilityRegTMarginAccount type. Margin account:RegTMargin,cash account:Cash
netLiquidation1233662.93Net liquidation, equivalent to total asset in the TigerTrade APP
equityWithLoan1233078.69Equity with loan value (including loan value assets). Securities Segment: Cash value + stock value, Futures Segment: Cash value - maintenance margin
initMarginReq292046.91Initial margin requirement
maintMarginReq273170.84Maintenance margin requirement
availableFunds941031.78Available_funds for trading, equals to equity_with_loan - initial_margin_requirement
dayTradesRemaining-1amount of trade you can make today, -1 stands for unlimited
excessLiquidity960492.09Excess 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
buyingPower6273545.18buying 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
cashValue469140.39cash value in stock account+ cash value in futures account
accruedCash-763.2The accumulated interest payable in the current month, updated daily.
accruedDividend0.0Cumulative dividends. Refers to the cumulative value of all dividends that have been executed but not paid
grossPositionValue865644.18Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values.
SMA0.0For 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.
regTEquity0.0float
regTMargin0.0For security segments only, i.e. initial margin requirements calculated under Regulation T
cushion0.778569The ratio of remaining liquidity to total assets, calculated as: excess_liquidity/net_liquidation
currencyUSDCurrency
realizedPnl-248.72Realized PNL
unrealizedPnl-17039.09Unrealized PNL
updateTime0Update at
segmentsAccount 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
marketValuesMarket Values. It is a Map with currency names as keys: for example: 'USD' or 'HKD'; corresponding values are MarketValue objects.

segmentsDescription:

NameExampleDescription
accountDU575569Account id
categorySSegment category C (Futures) or S (Securities)
titleUS Securitiestile
netLiquidation1233662.93Net Liquidation Value
cashValue469140.39cash value in stock account+ cash value in futures account
availableFunds941031.78Amount of cash that can be traded in the current account
equityWithLoan1233078.69Equity with loan value (including loan value assets). Securities Segment: cash value + stock value, futures Segment: cash value - maintenance margin
excessLiquidity960492.09Excess 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.2The accumulated interest payable in the current month, updated according to the daily
accruedDividend0.0Accumulated dividends. Refers to the accumulated value of all dividends that have been executed but not paid
initMarginReq292046.91Initial Margin
maintMarginReq273170.84Maintenance Margin
regTEquity0.0Only for the securities segment, that is, the equity with loan (including the loan equity value) calculated according to the Regulation T Act
regTMargin0.0For security segments only, i.e. initial margin requirements calculated under Regulation T
SMA0.0For 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.
grossPositionValue865644.18Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values.
leverage1leverage
updateTime1526368181000last update at

marketValues Descirption:

NameTypeDescription
accountDU575569Account
currencyUSDCurrency
netLiquidation1233662.93Net Liquidation(Equivalent to Total Asset in TigerTrade APP)
cashBalance469140.39Cash
exchangeRate0.1273896Exchange rate to USD (or primary currency of your account)
netDividend0.0Net dividend
futuresPnl0.0Futures profit and loss
realizedPnl-248.72Realized profit and loss
unrealizedPnl-17039.09Unrealized profit and loss
updateTime1526368181000Updated at
stockMarketValue943588.78market value of stock positions
optionMarketValue0.0market value of option postions
futureOptionValue0.0total market value of futures positions
warrantValue10958.0total 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

ArgumentTypeRequiredDescription
accountstringYesAccount id, example: 123123
base_currencystringNoCurrency, HKD/USD
secret_keystringNoSecret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user
consolidatedbooleanNoWhether 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:

NameTypeExampleDescription
accountString123123Account id
currencyStringUSDCurrency
categoryStringSSecurities Category C: (Commodities Futures), S: (Securities Stocks), F: (Funds)
capabilityStringRegTMarginAccount Type, Margin: RegTMargin, Cash: Cash RegTMargin,
buyingPowerDouble6273545.18buying 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
cashAvailableForTradeDouble1233662.1Amount of cash and margin that can be traded in the current account
cashAvailableForWithdrawalDouble1233662.1Amount of cash that can be withdrawn in the current account
cashBalanceDouble469140.39The 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)
grossPositionValueDouble865644.18Total value of securities: long stock value + short stock value + long option value + short option value. The above items are calculated as absolute values
initMarginDouble292046.91initial margin requirement.
maintainMarginDouble273170.84Maintenance margin requirement
overnightMarginDouble273170.84Overnight margin requirement
excessLiquidationDouble960492.09Excess 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
overnightLiquidationDouble1233662.93Overnight risk control value, when it is less than 0, account positions will be forced to liquidate, you need to pay attention to the risks
netLiquidationDouble1233662.93Total Assets (Net Liquidation Value) - Securities Segment: Cash Value + Stock Value + Stock Option Value - Futures Segment: Cash Value + Mark-to-Market Profit and Loss
equityWithLoanDouble1233078.69Equity with loan value (asset with loan value) - Securities Segment: Cash Value + Stock Value - Futures Segment: Cash Value - Maintenance Margin
realizedPLDouble-248.72Today's Realized P&L
unrealizedPLDouble-17039.09Unrealized profit and loss
leverageDouble0.5leverage
currencyAssetsCurrencyAssetsshow asset information according to different currencies
consolidatedSegTypesstringconsolidated Segment. The following are the fields of consolidated Segment:cashAvailableForTrade、initMargin、maintainMargin、overnightMargin、excessLiquidation、overnightLiquidation、buyingPower、lockedFunds、leverage

PrimeAssetItem.CurrencyAssets

NameExampleDescription
currencyUSDCurrent currency, commonly used currencies include: USD-US dollar, HKD-Hong Kong dollar, SGD-Singapore dollar, CNH-RMB
cashBalance469140.39Cash 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)
cashAvailableForTrade0.1273896The amount of cash that can be traded in the current account
realizedPL-248.72realizd profit and loss of the account
unrealizedPL-17039.09Unrealizd profit and loss of the account
stockMarketValue943588.78Market value of the stocks in this account
optionMarketValue0.0Market value of the options in this account
futuresMarketValue0.0Market 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

ArgumentTypeRequiredDescription
accountstringYesAccount id
start_datestringNostart date, format yyyy-MM-dd, like '2022-01-01', end_date
end_datestringNoend date, format yyyy-MM-dd, like '2022-02-01', if missing, use current date
seg_typeSegmentTypeNoAccount segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities
currencyCurrencyNocurrency,include ALL/USD/HKD/CNH
sub_accountstrNoSub-account (for institutional accounts only), if this field is setted, the assets of the sub-account will be returned
secret_keystringNoSecret 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.SummaryDescription:

FieldTypeDescription
pnldoubleprofit and loss
pnlPercentagedoubleprofit and loss's percentage
annualizedReturndoubleannualized return
overUserPercentagedoubleover user's percentage

PrimeAnalyticsAssetItem.HistoryItemDescription:

FieldTypeDescription
datelongDate timestamp in milliseconds
pnldoubleAmount of profit or loss compared to the previous day
pnlPercentagedoubleYield compared to the previous day
assetdoubleTotal assets amount
cashBalancedoubleCash balance
grossPositionValuedoubleposition market value
depositdoubledeposit amount
withdrawaldoublewithdrawal 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

ArgumentTypeRequiredDescription
accountstringYesAccount id
from_segmentstringNofrom segment, FUT/SEC
currencystringNocurrency,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

SegmentFundAvailableItemDescription:

NameTypeDescription
fromSegmentstringfrom segment, FUT/SEC
currencystringcurrency,USD/HKD
amountdoubletransferable 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

ArgumentTypeRequiredDescription
accountstringYesAccount id
from_segmentstringYesfrom segment, FUT/SEC
to_segmentstringYestarget segment, FUT/SEC,must be different from 'from_segment'
currencystringYescurrency,USD/HKD
amountdoubleYesamount

Response

com.tigerbrokers.stock.openapi.client.https.response.trade.SegmentFundResponse

Use SegmentFundItem item = response.getSegmentFundItem() to get transfer result. See examples below

SegmentFundItemDescription:

NameTypeDescription
idlongTransfer record ID
fromSegmentstringfrom segment, FUT/SEC
toSegmentstringtarget segment, FUT/SEC
currencystringcurrency, USD/HKD
amountdoubletransfer amount
statusstringstatus(NEW/PROC/SUCC/FAIL/CANC)
statusDescstringstatus description
messagestringfail message
settledAtlongsettled timestamp
updatedAtlongupdated timestamp
createdAtlongcreated 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

ArgumentTypeRequiredDescription
accountstringYesAccount id
idlongYesTransfer record ID

Response

com.tigerbrokers.stock.openapi.client.https.response.trade.SegmentFundResponse

Use SegmentFundItem item = response.getSegmentFundItem() to get transfer result. See examples below

SegmentFundItemDescription:

NameTypeDescription
idlongTransfer record ID
fromSegmentstringfrom segment, FUT/SEC
toSegmentstringtarget segment, FUT/SEC
currencystringcurrency, USD/HKD
amountdoubletransfer amount
statusstringstatus(NEW/PROC/SUCC/FAIL/CANC)
statusDescstringstatus description
messagestringfail message
settledAtlongsettled timestamp
updatedAtlongupdated timestamp
createdAtlongcreated 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

ArgumentTypeRequiredDescription
accountstringYesAccount id
limitIntegerNoReturns 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

SegmentFundItemDescription:

NameTypeDescription
idlongTransfer record ID
fromSegmentstringfrom segment, FUT/SEC
toSegmentstringtarget segment, FUT/SEC
currencystringcurrency, USD/HKD
amountdoubletransfer amount
statusstringstatus(NEW/PROC/SUCC/FAIL/CANC)
statusDescstringstatus description
messagestringfail message
settledAtlongsettled timestamp
updatedAtlongupdated timestamp
createdAtlongcreated 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

ArgumentTypeRequiredDescription
accountStringYesAccount id, prime account only
symbolStringYesticker symbol
expiryStringNo, required when sec_type is OPT/WAR/IOPTExpiration Date,yyyyMMdd
rightStringNo, required when sec_type is OPT/WAR/IOPTCALL/PUT
strikeStringNo, required when sec_type is OPT/WAR/IOPTStrike price
seg_typeSegmentTypeNoAccount segment. Available: SegmentType.SEC for Securities
sec_typeSecTypeNoSTK/WAR/IOPT/OPT
actionActionTypeYesOrder direction: BUY/SELL
order_typeOrderTypeYesOrder Types,'MKT'-Market Order / 'LMT'-Limit Order / 'STP'-Stop Order / 'STP_LMT'-Stop-Limit Order
limit_pricedoubleNoLimit price, required if order_type is LMT or STP_LMT
stop_pricedoubleNoStop price, required if order_type is STP or STP_LMT
secretKeyStringNoSecret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user

Response

NameExampleDescription
tradableQuantityDoubletradable quantity for cash
financingQuantityDoubletradable quantity for margin
positionQuantityDoubleposition quantity
tradablePositionQuantityDoubletradable 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
}
Last update: