账户与资金
获取管理的账户
功能说明
查询机构子账户列表。 方法签名
func (c *TradeClient) ManagedAccounts(req model.ManagedAccountsRequest) ([]model.ManagedAccount, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.ManagedAccountsRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.ManagedAccount, error)。关键字段来自 model.ManagedAccount:
| 字段 | 类型 | 说明 |
|---|---|---|
| Account | string | 账户 ID |
| AccountType | string | 账户类型(STANDARD/PAPER) |
| Capability | string | 账户能力(如 RegTMargin) |
| Status | string | 账户状态 |
示例
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"
}
]
}外汇下单
功能说明
外汇下单(子账户 base_currency 互换)。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) PlaceForexOrder(req model.ForexOrderRequest) (*model.ForexOrderResult, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.ForexOrderRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
SegType | string | 否 | 空值省略 | 无;可选值:ALL, SEC, FUT, FUND |
TimeInForce | string | 否 | 空值省略 | 无;可选值:DAY, GTC, OPG |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
(*model.ForexOrderResult, error)。关键字段来自 model.ForexOrderResult:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | string | 换汇订单 ID |
| Status | string | 订单状态 |
| SourceCurrency | string | 源币种 |
| TargetCurrency | string | 目标币种 |
| SourceAmount | float64 | 源金额 |
| TargetAmount | float64 | 目标金额 |
| Rate | float64 | 汇率 |
| SubmitTime | int64 | 提交时间 |
示例
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"
}获取可划转资金
功能说明
查询可用于调拨的金额。 服务端返回数组(按 SegmentType 分项)。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) SegmentFundAvailable(req model.SegmentFundRequest) ([]model.SegmentFundAvailableItem, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.SegmentFundRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
FromSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
ToSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
Currency | string | 否 | 空值省略 | 无;可选值:ALL, USD, HKD, CNH, SGD |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.SegmentFundAvailableItem, error)。关键字段来自 model.SegmentFundAvailableItem:
| 字段 | 类型 | 说明 |
|---|---|---|
| FromSegment | string | 源账户分类 |
| Currency | string | 币种 |
| Amount | float64 | 可调拨金额 |
示例
result, err := tc.SegmentFundAvailable(model.SegmentFundRequest{
ID: "transfer-id",
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}
]
}获取划转记录
功能说明
查询子账户调拨历史。 服务端直接返回数组(不带 items 包装)。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) SegmentFundHistory(req model.SegmentFundRequest) ([]model.SegmentFundHistoryItem, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.SegmentFundRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
FromSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
ToSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
Currency | string | 否 | 空值省略 | 无;可选值:ALL, USD, HKD, CNH, SGD |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.SegmentFundHistoryItem, error)。关键字段来自 model.SegmentFundHistoryItem:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | int64 | 调拨记录 ID |
| FromSegment | string | 源账户分类 |
| ToSegment | string | 目标账户分类 |
| Currency | string | 币种 |
| Amount | float64 | 调拨金额 |
| Status | string | 状态 |
| StatusDesc | string | 状态描述 |
| SettledAt | int64 | 结算时间 |
| CreatedAt | int64 | 创建时间 |
| UpdatedAt | int64 | 更新时间 |
示例
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
}
]划转分部资金
功能说明
子账户间资金调拨。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) TransferSegmentFund(req model.SegmentFundRequest) (*model.SegmentFund, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.SegmentFundRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
FromSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
ToSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
Currency | string | 否 | 空值省略 | 无;可选值:ALL, USD, HKD, CNH, SGD |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
(*model.SegmentFund, error)。关键字段来自 model.SegmentFund:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | interface | 调拨 ID |
| FromSegment | string | 源账户分类 |
| ToSegment | string | 目标账户分类 |
| Currency | string | 币种 |
| Amount | float64 | 调拨金额 |
| Status | string | 状态 |
| StatusDesc | string | 状态描述 |
| Message | string | 消息 |
| SettledAt | int64 | 结算时间 |
| CreatedAt | int64 | 创建时间 |
| UpdatedAt | int64 | 更新时间 |
示例
result, err := tc.TransferSegmentFund(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": "Pending"
}取消划转
功能说明
撤销一笔子账户调拨申请。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) CancelSegmentFund(req model.SegmentFundRequest) (*model.SegmentFund, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.SegmentFundRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
FromSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
ToSegment | string | 否 | 空值省略 | 无;可选值:SEC or FUT where supported |
Currency | string | 否 | 空值省略 | 无;可选值:ALL, USD, HKD, CNH, SGD |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
(*model.SegmentFund, error)。关键字段来自 model.SegmentFund:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | interface | 调拨 ID |
| FromSegment | string | 源账户分类 |
| ToSegment | string | 目标账户分类 |
| Currency | string | 币种 |
| Amount | float64 | 调拨金额 |
| Status | string | 状态 |
| StatusDesc | string | 状态描述 |
| Message | string | 消息 |
| SettledAt | int64 | 结算时间 |
| CreatedAt | int64 | 创建时间 |
| UpdatedAt | int64 | 更新时间 |
示例
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"
}获取资金明细
功能说明
资金流水明细(按子账户/币种/业务类型过滤)。 方法签名
func (c *TradeClient) FundDetails(req model.FundDetailsRequest) ([]model.FundDetails, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.FundDetailsRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Currency | string | 否 | 空值省略 | 无;可选值:ALL, USD, HKD, CNH, SGD |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.FundDetails, error)。关键字段来自 model.FundDetails:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | FlexInt64 | 流水 ID |
| Account | string | 账户 ID |
| SegType | string | 品种类型 |
| FundType | string | 资金类型 |
| Currency | string | 币种 |
| Amount | float64 | 金额 |
| Balance | float64 | 余额 |
| OccurTime | int64 | 发生时间 |
| Remark | string | 备注 |
| ExternalID | string | 外部 ID |
示例
result, err := tc.FundDetails(model.FundDetailsRequest{
Account: "U123456",
Currency: "USD",
StartDate: 1,
EndDate: 1,
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}
]
}获取资金历史
功能说明
资金调拨记录(API method: transfer_fund)。 服务端直接返回裸 list(不带 items 包装)。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) FundingHistory(req model.FundingHistoryRequest) ([]model.FundingHistoryItem, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.FundingHistoryRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
SegType | string | 否 | 空值省略 | 无;可选值:ALL, SEC, FUT, FUND |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.FundingHistoryItem, error)。关键字段来自 model.FundingHistoryItem:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | int64 | 记录 ID |
| RefID | string | 引用 ID |
| Type | int | 类型代码 |
| TypeDesc | string | 类型描述 |
| Currency | string | 币种 |
| Amount | float64 | 金额 |
| BusinessDate | string | 业务日期 |
| Status | string | 状态 |
| StatusDesc | string | 状态描述 |
| CompletedStatus | bool | 是否已完成 |
| CreatedAt | int64 | 创建时间 |
| UpdatedAt | int64 | 更新时间 |
示例
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
}
]Updated 9 days ago
