Assets and Positions

Asset and Position Valuation

The new parameter examples below require Go SDK v0.5.5 or later.

The examples assume an initialized tc (*trade.TradeClient), with request models from the github.com/tigerfintech/openapi-go-sdk/model package.

For prime and paper trading accounts, the optional AssetQuoteType field (API field asset_quote_type) selects the quotes used to value assets and positions.

ValueValuation quotes
ETHPre-market, regular-session, and after-hours quotes. During the overnight session, uses the previous day's after-hours closing price.
RTHRegular-session quotes only. Outside regular hours, uses the regular-session closing price.
OVERNIGHTIncludes pre-market, regular-session, after-hours, and overnight quotes; during the overnight session, uses overnight quotes.

An empty field is omitted and preserves the existing valuation behavior. This field controls asset and position valuation.

This setting does not freeze assets or positions. Even with RTH, cash movements, exchange rates, or activity in other markets can change net liquidation value. It does not enable overnight order execution.

Positions

Purpose

Lists account positions with instrument, market, currency, and sub-account filters. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) Positions(req model.PositionsRequest) ([]model.Position, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.PositionsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
AccountstringNoUses the client default when emptyTrading account ID
SecretKeystringNoOmitted if emptyInstitutional-account authentication key
SymbolstringNoOmitted if emptyInstrument symbol
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
MarketstringNoOmitted if emptyAllowed values: ALL, US, HK, CN, SG
SubAccounts[]stringNoOmitted if emptySub-account list
ExpirystringNoOmitted if emptyExpiry date
StrikestringNoOmitted if emptyStrike price
RightstringNoOmitted if emptyAllowed values: PUT, CALL (option side); br, nr when used as quote adjustment
AssetQuoteTypestringNoOmitted if emptyETH, RTH, or OVERNIGHT; see Asset and Position Valuation
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Position, error). Key fields from model.Position:

FieldTypeDescription
AccountstringAccount ID
SymbolstringSymbol code
SecTypestringSecurity type
MarketstringMarket
CurrencystringCurrency
Positionint64Position quantity
PositionScaleintPosition scale
PositionQtyfloat64Position quantity (with scale)
SalableQtyfloat64Salable quantity
AverageCostfloat64Average cost
AverageCostByAveragefloat64Average cost (average method)
AverageCostOfCarryfloat64Cost of carry
MarketValuefloat64Market value
RealizedPnlfloat64Realized P&L
RealizedPnlByAveragefloat64Realized P&L by average cost
UnrealizedPnlfloat64Unrealized P&L
UnrealizedPnlByAveragefloat64Unrealized P&L by average cost
UnrealizedPnlByCostOfCarryfloat64Unrealized P&L by cost of carry
UnrealizedPnlPercentfloat64Unrealized P&L percentage
UnrealizedPnlPercentByAveragefloat64Unrealized P&L percentage by average cost
UnrealizedPnlPercentByCostOfCarryfloat64Unrealized P&L percentage by cost of carry
ContractIdint64Contract ID
IdentifierstringContract identifier
NamestringContract name
LatestPricefloat64Latest price
LastClosePricefloat64Previous close
Multiplierfloat64Contract multiplier
StatusintStatus
UpdateTimestampint64Update time in milliseconds
MmPercentfloat64Maintenance-margin percentage
MmValuefloat64Maintenance-margin value
TodayPnlfloat64Today's P&L
TodayPnlPercentfloat64Today's P&L percentage
ComboTypes[]stringCombo types
Categories[]stringCategories

Invocation example

result, err := tc.Positions(model.PositionsRequest{
	Account: "your_prime_or_paper_account",
	AssetQuoteType: "OVERNIGHT",
	Symbol: "AAPL",
	SecType: "STK",
	Currency: "USD",
	Market: "US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "symbol": "AAPL",
    "secType": "STK",
    "market": "US",
    "currency": "USD",
    "position": 100,
    "averageCost": 150.25,
    "latestPrice": 308.91,
    "marketValue": 30891.00,
    "unrealizedPnl": 15866.00,
    "realizedPnl": 0.0,
    "account": "12345678"
  },
  {
    "symbol": "MSFT",
    "secType": "STK",
    "market": "US",
    "currency": "USD",
    "position": 50,
    "averageCost": 380.50,
    "latestPrice": 425.30,
    "marketValue": 21265.00,
    "unrealizedPnl": 2240.00,
    "realizedPnl": 0.0,
    "account": "12345678"
  }
]

Rate limit

The base rate limit is 60 requests/min.


Assets

Purpose

Returns account assets with optional segment and market-value details. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) Assets(req model.AssetsRequest) ([]model.Asset, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.AssetsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
AccountstringNoUses the client default when emptyTrading account ID
SecretKeystringNoOmitted if emptyInstitutional-account authentication key
SegmentboolNoOmitted when falseWhether to return segmented assets
MarketValueboolNoOmitted when falseWhether to return market values
SubAccounts[]stringNoOmitted if emptySub-account list
BaseCurrencystringNoOmitted if emptyBase currency
Consolidated*boolNoOmitted when nilWhether to consolidate assets; a pointer distinguishes explicit false from omission
AssetQuoteTypestringNoOmitted if emptyETH, RTH, or OVERNIGHT; see Asset and Position Valuation
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Asset, error). Key fields from model.Asset:

FieldTypeDescription
AccountstringAccount ID
CapabilitystringAccount type
CurrencystringCurrency
BuyingPowerfloat64Buying power
CashValuefloat64Cash balance
NetLiquidationfloat64Net liquidation value
RealizedPnLfloat64Realized P&L
UnrealizedPnLfloat64Unrealized P&L
Segments[]AssetSegmentSegment asset list
AssetSegment fieldTypeDescription
AccountstringAccount ID
CategorystringSegment category
TitlestringSegment title
NetLiquidationfloat64Net liquidation value
CashValuefloat64Cash balance
AvailableFundsfloat64Available funds
EquityWithLoanfloat64Equity with loan
ExcessLiquidityfloat64Excess liquidity
AccruedCashfloat64Accrued cash
AccruedDividendfloat64Accrued dividend
InitMarginReqfloat64Initial margin requirement
MaintMarginReqfloat64Maintenance margin requirement
GrossPositionValuefloat64Gross position value
Leveragefloat64Leverage

Invocation example

result, err := tc.Assets(model.AssetsRequest{
	Account: "your_prime_or_paper_account",
	AssetQuoteType: "OVERNIGHT",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "account": "12345678",
  "netLiquidation": 125000.00,
  "equityWithLoan": 125000.00,
  "initMarginReq": 35000.00,
  "maintMarginReq": 28000.00,
  "availableFunds": 90000.00,
  "excessLiquidity": 97000.00,
  "buyingPower": 270000.00,
  "cashValue": 50000.00,
  "grossPositionValue": 75000.00,
  "unrealizedPnl": 18106.00,
  "realizedPnl": 3250.00
}

Rate limit

The base rate limit is 60 requests/min.


PrimeAssets

Purpose

Returns the detailed segmented asset model for a prime account. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) PrimeAssets(req model.AssetsRequest) (*model.PrimeAsset, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.AssetsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
AccountstringNoUses the client default when emptyTrading account ID
SecretKeystringNoUses the client configuration when emptyInstitutional-account authentication key
SegmentboolNoOmitted when falseAssetsRequest compatibility field; PrimeAssets is already segmented, so this is normally unnecessary
MarketValueboolNoOmitted when falseAssetsRequest compatibility field; whether the prime-assets API applies it depends on the API response
SubAccounts[]stringNoOmitted if emptySub-account list; applicable to institutional-account queries
BaseCurrencystringNoOmitted if emptyBase currency; whether the prime-assets API applies it depends on the API response
Consolidated*boolNoOmitted when nilWhether to consolidate assets; a pointer distinguishes explicit false from omission and applies to prime accounts
AssetQuoteTypestringNoOmitted if emptyETH, RTH, or OVERNIGHT; see Asset and Position Valuation
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

(*model.PrimeAsset, error). Key fields from model.PrimeAsset:

FieldTypeDescription
AccountIDstringAccount ID
UpdateTimestampint64Update timestamp
Segments[]PrimeAssetSegmentSegment asset list
PrimeAssetSegment fieldTypeDescription
CapabilitystringAccount capability
CategorystringSegment category
CurrencystringCurrency
CashBalancefloat64Cash balance
CashAvailableForTradefloat64Cash available for trading
GrossPositionValuefloat64Gross position value
EquityWithLoanfloat64Equity with loan
NetLiquidationfloat64Net liquidation value
InitMarginfloat64Initial margin
MaintainMarginfloat64Maintenance margin
OvernightMarginfloat64Overnight margin
UnrealizedPLfloat64Unrealized P&L
UnrealizedPLByCostOfCarryfloat64Unrealized P&L by cost of carry
RealizedPLfloat64Realized P&L
TotalTodayPLfloat64Total P&L today
ExcessLiquidationfloat64Excess liquidity
OvernightLiquidationfloat64Overnight liquidity
BuyingPowerfloat64Buying power
LockedFundsfloat64Locked funds
Leveragefloat64Leverage
Uncollectedfloat64Uncollected funds
CurrencyAssets[]CurrencyAssetPer-currency assets
ConsolidatedSegTypes[]stringConsolidated segment types
CurrencyAsset fieldTypeDescription
CurrencystringCurrency
CashBalancefloat64Cash balance
CashAvailableForTradefloat64Cash available for trading
ForexRatefloat64Exchange rate

Invocation example

result, err := tc.PrimeAssets(model.AssetsRequest{
	Account: "your_prime_or_paper_account",
	AssetQuoteType: "OVERNIGHT",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "account": "12345678",
  "totalAssets": 125000.00,
  "netLiquidation": 125000.00,
  "totalCashValue": 50000.00,
  "stockMarketValue": 75000.00,
  "optionMarketValue": 0.0,
  "futureMarketValue": 0.0,
  "unrealizedPnl": 18106.00,
  "realizedPnl": 3250.00
}

Rate limit

The base rate limit is 60 requests/min.


AnalyticsAsset

Purpose

Returns daily holding value, cash, P&L, and net-value analytics. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) AnalyticsAsset(req model.AnalyticsAssetRequest) ([]model.AnalyticsAsset, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.AnalyticsAssetRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
AccountstringNoUses the client default when emptyTrading account ID
SubAccountstringNoOmitted if emptyOne sub-account
SecretKeystringNoOmitted if emptyInstitutional-account authentication key
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
SubAccounts[]stringNoOmitted if emptySub-account list
StartDatestringNoOmitted if emptyNone; yyyy-MM-dd
EndDatestringNoOmitted if emptyNone; yyyy-MM-dd
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.AnalyticsAsset, error). Key fields from model.AnalyticsAsset:

FieldTypeDescription
DatestringDate
HoldingValuefloat64Holding value
CashBalancefloat64Cash balance
Pnlfloat64P&L
PnlRatefloat64P&L rate
NetValueIndexfloat64Net value index
CurrencystringCurrency
SegTypestringSegment type

Invocation example

result, err := tc.AnalyticsAsset(model.AnalyticsAssetRequest{
	Account: "U123456",
	Currency: "USD",
	StartDate: "2025-01-01",
	EndDate: "2025-01-31",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "account": "12345678",
  "summary": {
    "netLiquidation": 125000.00,
    "totalCashValue": 50000.00,
    "grossPositionValue": 75000.00,
    "unrealizedPnl": 18106.00,
    "realizedPnl": 3250.00
  },
  "segments": [
    {"secType": "STK", "marketValue": 75000.00, "unrealizedPnl": 18106.00}
  ]
}

AggregateAssets

Purpose

Aggregates assets for institutional accounts with aggregation enabled, such as accounts with shared purchasing power across sub-accounts. An institutional trader key and a segment (SEC, FUT, or FUND) are required. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) AggregateAssets(req model.AggregateAssetsRequest) (*model.AggregateAssets, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.AggregateAssetsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
AccountstringNoUses the client default when emptyTrading account ID
SecretKeystringYes, in request or configurationUses the client configuration when emptyRequired institutional trader key
SegTypestringYesOmitted if emptyAPI requires SEC, FUT, or FUND
BaseCurrencystringNoOmitted if emptyBase currency
AssetQuoteTypestringNoOmitted if emptyETH, RTH, or OVERNIGHT; see Asset and Position Valuation
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

(*model.AggregateAssets, error). Key fields from model.AggregateAssets:

FieldTypeDescription
AccountIDstringAccount ID
NetLiquidationfloat64Net liquidation value
GrossPositionValuefloat64Gross position value
CashBalancefloat64Cash balance
BaseCurrencystringBase currency
CurrencyAssets[]CurrencyAssetPer-currency asset list

CurrencyAsset fields:

FieldTypeDescription
CurrencystringCurrency
CashBalancefloat64Cash balance
CashAvailableForTradefloat64Cash available for trading
ForexRatefloat64Exchange rate

Invocation example

result, err := tc.AggregateAssets(model.AggregateAssetsRequest{
	Account: "your_institutional_account",
	SecretKey: "your_institutional_secret_key",
	SegType: "SEC",
	AssetQuoteType: "OVERNIGHT",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "account": "12345678",
    "accountType": "STANDARD",
    "netLiquidation": 125000.00,
    "totalCashValue": 50000.00,
    "currency": "USD"
  }
]

Rate limit

The base rate limit is 60 requests/min.



Did this page help you?