Accounts and Funds

ManagedAccounts

Purpose

Lists sub-accounts managed by the configured institutional account. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) ManagedAccounts(req model.ManagedAccountsRequest) ([]model.ManagedAccount, error)

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

Parameters

model.ManagedAccountsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
AccountstringAccount ID
AccountTypestringAccount type (STANDARD/PAPER)
CapabilitystringAccount capability (e.g. RegTMargin)
StatusstringAccount status

Invocation example

result, err := tc.ManagedAccounts(model.ManagedAccountsRequest{
	Account: "U123456",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "items": [
    {
      "account": "12345678",
      "capability": "RegTMargin",
      "accountType": "STANDARD",
      "status": "Funded"
    },
    {
      "account": "21145462914775637",
      "capability": "RegTMargin",
      "accountType": "PAPER",
      "status": "Funded"
    }
  ]
}

PlaceForexOrder

Purpose

Submits a currency-conversion order between source and target currencies. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) PlaceForexOrder(req model.ForexOrderRequest) (*model.ForexOrderResult, error)

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

Parameters

model.ForexOrderRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
TimeInForcestringNoOmitted if emptyAllowed values: DAY, GTC, OPG
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
IDstringForex order ID
StatusstringOrder status
SourceCurrencystringSource currency
TargetCurrencystringTarget currency
SourceAmountfloat64Source amount
TargetAmountfloat64Target amount
Ratefloat64Exchange rate
SubmitTimeint64Submit time

Invocation example

result, err := tc.PlaceForexOrder(model.ForexOrderRequest{
	Account: "U123456",
	SourceCurrency: "USD",
	SourceAmount: 1000,
	TargetCurrency: "HKD",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "id": 987654321,
  "orderId": 987654321,
  "symbol": "USD.HKD",
  "secType": "CASH",
  "action": "BUY",
  "orderType": "MKT",
  "totalQuantity": 10000,
  "filledQuantity": 0,
  "status": "Initial",
  "account": "12345678"
}

SegmentFundAvailable

Purpose

Returns amounts available for transfer between account segments. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) SegmentFundAvailable(req model.SegmentFundRequest) ([]model.SegmentFundAvailableItem, error)

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

Parameters

model.SegmentFundRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
FromSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
ToSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
FromSegmentstringSource segment
CurrencystringCurrency
Amountfloat64Available amount for transfer

Invocation example

result, err := tc.SegmentFundAvailable(model.SegmentFundRequest{
	Account: "U123456",
	FromSegment: "SEC",
	ToSegment: "FUT",
	Currency: "USD",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "account": "12345678",
  "segments": [
    {"category": "S", "currency": "USD", "availableFunds": 50000.00},
    {"category": "C", "currency": "USD", "availableFunds": 25000.00}
  ]
}

SegmentFundHistory

Purpose

Returns account-segment transfer history. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) SegmentFundHistory(req model.SegmentFundRequest) ([]model.SegmentFundHistoryItem, error)

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

Parameters

model.SegmentFundRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
FromSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
ToSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
IDint64Transfer record ID
FromSegmentstringSource segment
ToSegmentstringTarget segment
CurrencystringCurrency
Amountfloat64Transfer amount
StatusstringStatus
StatusDescstringStatus description
SettledAtint64Settlement time
CreatedAtint64Creation time
UpdatedAtint64Update time

Invocation example

result, err := tc.SegmentFundHistory(model.SegmentFundRequest{
	ID: "transfer-id",
	Account: "U123456",
	FromSegment: "SEC",
	ToSegment: "FUT",
	Currency: "USD",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 111222333,
    "account": "12345678",
    "fromSegment": "S",
    "toSegment": "C",
    "currency": "USD",
    "amount": 5000.00,
    "status": "Completed",
    "createTime": 1785384000000
  }
]

TransferSegmentFund

Purpose

Submits a transfer between account segments. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) TransferSegmentFund(req model.SegmentFundRequest) (*model.SegmentFund, error)

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

Parameters

model.SegmentFundRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
FromSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
ToSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
IDinterfaceTransfer ID
FromSegmentstringSource segment
ToSegmentstringTarget segment
CurrencystringCurrency
Amountfloat64Transfer amount
StatusstringStatus
StatusDescstringStatus description
MessagestringMessage
SettledAtint64Settlement time
CreatedAtint64Creation time
UpdatedAtint64Update time

Invocation example

result, err := tc.TransferSegmentFund(model.SegmentFundRequest{
	ID: "transfer-id",
	Account: "U123456",
	FromSegment: "SEC",
	ToSegment: "FUT",
	Currency: "USD",
	Amount: 10000,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "id": 111222334,
  "account": "12345678",
  "fromSegment": "S",
  "toSegment": "C",
  "currency": "USD",
  "amount": 5000.00,
  "status": "Pending"
}

CancelSegmentFund

Purpose

Cancels a pending account-segment transfer. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) CancelSegmentFund(req model.SegmentFundRequest) (*model.SegmentFund, error)

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

Parameters

model.SegmentFundRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
FromSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
ToSegmentstringNoOmitted if emptyAllowed values: SEC or FUT where supported
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
IDinterfaceTransfer ID
FromSegmentstringSource segment
ToSegmentstringTarget segment
CurrencystringCurrency
Amountfloat64Transfer amount
StatusstringStatus
StatusDescstringStatus description
MessagestringMessage
SettledAtint64Settlement time
CreatedAtint64Creation time
UpdatedAtint64Update time

Invocation example

result, err := tc.CancelSegmentFund(model.SegmentFundRequest{
	ID: "transfer-id",
	Account: "U123456",
	FromSegment: "SEC",
	ToSegment: "FUT",
	Currency: "USD",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "id": 111222334,
  "account": "12345678",
  "fromSegment": "S",
  "toSegment": "C",
  "currency": "USD",
  "amount": 5000.00,
  "status": "Cancelled"
}

FundDetails

Purpose

Lists cash-ledger entries using segment, type, currency, time, and offset filters. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) FundDetails(req model.FundDetailsRequest) ([]model.FundDetails, error)

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

Parameters

model.FundDetailsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
CurrencystringNoOmitted if emptyAllowed values: ALL, USD, HKD, CNH, SGD
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
IDFlexInt64Ledger entry ID
AccountstringAccount ID
SegTypestringSegment type
FundTypestringFund type
CurrencystringCurrency
Amountfloat64Amount
Balancefloat64Balance
OccurTimeint64Occurrence time
RemarkstringRemark
ExternalIDstringExternal ID

Invocation example

result, err := tc.FundDetails(model.FundDetailsRequest{
	Account: "U123456",
	Currency: "USD",
	StartDate: 1704067200000, // 2024-01-01 UTC
	EndDate: 1706745600000, // 2024-02-01 UTC
	Limit: 20,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
  "account": "12345678",
  "currency": "USD",
  "items": [
    {"currency": "USD", "cashBalance": 50000.00, "exchangeRate": 1.0},
    {"currency": "HKD", "cashBalance": 15600.00, "exchangeRate": 7.80}
  ]
}

FundingHistory

Purpose

Lists deposit and withdrawal transfer records. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) FundingHistory(req model.FundingHistoryRequest) ([]model.FundingHistoryItem, error)

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

Parameters

model.FundingHistoryRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

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

FieldTypeDescription
IDint64Record ID
RefIDstringReference ID
TypeintType code
TypeDescstringType description
CurrencystringCurrency
Amountfloat64Amount
BusinessDatestringBusiness date
StatusstringStatus
StatusDescstringStatus description
CompletedStatusboolWhether completed
CreatedAtint64Creation time
UpdatedAtint64Update time

Invocation example

result, err := tc.FundingHistory(model.FundingHistoryRequest{
	Account: "U123456",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 555666777,
    "account": "12345678",
    "currency": "USD",
    "amount": 10000.00,
    "type": "Deposit",
    "status": "Completed",
    "updateTime": 1785384000000
  }
]


Did this page help you?