Assets and Positions
Positions
PositionsPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
Currency | string | No | Omitted if empty | Allowed values: ALL, USD, HKD, CNH, SGD |
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
Right | string | No | Omitted if empty | Allowed values: PUT, CALL (option side); br, nr when used as quote adjustment |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Position, error). Key fields from model.Position:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| Symbol | string | Symbol code |
| SecType | string | Security type |
| Market | string | Market |
| Currency | string | Currency |
| Position | int64 | Position quantity |
| PositionScale | int | Position scale |
| PositionQty | float64 | Position quantity (with scale) |
| SalableQty | float64 | Salable quantity |
| AverageCost | float64 | Average cost |
| AverageCostByAverage | float64 | Average cost (average method) |
| AverageCostOfCarry | float64 | Cost of carry |
| MarketValue | float64 | Market value |
| RealizedPnl | float64 | Realized P&L |
Invocation example
result, err := tc.Positions(model.PositionsRequest{
Account: "U123456",
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"
}
]Assets
AssetsPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Asset, error). Key fields from model.Asset:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| Capability | string | Account type |
| Currency | string | Currency |
| BuyingPower | float64 | Buying power |
| CashValue | float64 | Cash balance |
| NetLiquidation | float64 | Net liquidation value |
| RealizedPnL | float64 | Realized P&L |
| UnrealizedPnL | float64 | Unrealized P&L |
| Segments | []AssetSegment | Segment asset list |
Invocation example
result, err := tc.Assets(model.AssetsRequest{
Account: "U123456",
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
}PrimeAssets
PrimeAssetsPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
(*model.PrimeAsset, error). Key fields from model.PrimeAsset:
| Field | Type | Description |
|---|---|---|
| AccountID | string | Account ID |
| UpdateTimestamp | int64 | Update timestamp |
| Segments | []PrimeAssetSegment | Segment asset list |
Invocation example
result, err := tc.PrimeAssets(model.AssetsRequest{
Account: "U123456",
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
}AnalyticsAsset
AnalyticsAssetPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
Currency | string | No | Omitted if empty | Allowed values: ALL, USD, HKD, CNH, SGD |
StartDate | string | No | Omitted if empty | None; yyyy-MM-dd |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.AnalyticsAsset, error). Key fields from model.AnalyticsAsset:
| Field | Type | Description |
|---|---|---|
| Date | string | Date |
| HoldingValue | float64 | Holding value |
| CashBalance | float64 | Cash balance |
| Pnl | float64 | P&L |
| PnlRate | float64 | P&L rate |
| NetValueIndex | float64 | Net value index |
| Currency | string | Currency |
| SegType | string | Segment 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
AggregateAssetsPurpose
Aggregates account assets in a requested base currency. 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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
(*model.AggregateAssets, error). Key fields from model.AggregateAssets:
| Field | Type | Description |
|---|---|---|
| AccountID | string | Account ID |
| NetLiquidation | float64 | Net liquidation value |
| GrossPositionValue | float64 | Gross position value |
| CashBalance | float64 | Cash balance |
| BaseCurrency | string | Base currency |
| CurrencyAssets | []CurrencyAsset | Per-currency asset list |
Invocation example
result, err := tc.AggregateAssets(model.AggregateAssetsRequest{
Account: "U123456",
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"
}
]Updated about 17 hours ago
