Order Operations
PlaceOrder
PlaceOrderPurpose
Submits an order to the configured trading account.
Signature
func (c *TradeClient) PlaceOrder(order model.OrderRequest) (*model.PlaceOrderResult, error)Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.
Parameters
model.OrderRequest
| SDK field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Action | string | No | Omitted if empty | Allowed values: BUY, SELL |
OrderType | string | No | Omitted if empty | Allowed values: MKT, LMT, STP, STP_LMT, TRAIL, AM, AL, TWAP, VWAP, OCA, ICEBERG |
TimeInForce | string | No | Omitted if empty | Allowed values: DAY, GTC, OPG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
Currency | string | No | Omitted if empty | Allowed values: ALL, USD, HKD, CNH, SGD |
Right | string | No | Omitted if empty | Allowed values: PUT, CALL (option side); br, nr when used as quote adjustment |
MinDisplaySize | int64 | No | Omitted if empty | None; 冰山单缺省等于 DisplaySize |
CheckIntervals | int64 | No | Omitted if empty | None; 冰山单默认 30 秒 |
PriceType | string | No | Omitted if empty | Allowed values: LIMIT_PRICE, ASK_PRICE, BID_PRICE, LATEST_PRICE; 冰山单默认 LIMIT_PRICE |
Returns
(*model.PlaceOrderResult, error). Key fields from model.PlaceOrderResult:
| Field | Type | Description |
|---|---|---|
| ID | int64 | Order ID |
| OrderID | int64 | Order number |
| SubIDs | []int64 | Sub-order ID list |
| Orders | []Order | Order list |
Invocation example
result, err := tc.PlaceOrder(model.OrderRequest{
Account: "U123456",
ID: 1,
Action: "BUY",
OrderType: "LMT",
TotalQuantity: 1,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", result){
"id": 123456789,
"orderId": 123456789,
"symbol": "AAPL",
"action": "BUY",
"orderType": "LMT",
"limitPrice": 310.00,
"totalQuantity": 100,
"filledQuantity": 0,
"status": "Initial",
"account": "12345678"
}PreviewOrder
PreviewOrderPurpose
Validates an order and estimates commission and margin without placing it.
Signature
func (c *TradeClient) PreviewOrder(order model.OrderRequest) (*model.PreviewResult, error)Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.
Parameters
model.OrderRequest
| SDK field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Action | string | No | Omitted if empty | Allowed values: BUY, SELL |
OrderType | string | No | Omitted if empty | Allowed values: MKT, LMT, STP, STP_LMT, TRAIL, AM, AL, TWAP, VWAP, OCA, ICEBERG |
TimeInForce | string | No | Omitted if empty | Allowed values: DAY, GTC, OPG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
Currency | string | No | Omitted if empty | Allowed values: ALL, USD, HKD, CNH, SGD |
Right | string | No | Omitted if empty | Allowed values: PUT, CALL (option side); br, nr when used as quote adjustment |
MinDisplaySize | int64 | No | Omitted if empty | None; 冰山单缺省等于 DisplaySize |
CheckIntervals | int64 | No | Omitted if empty | None; 冰山单默认 30 秒 |
PriceType | string | No | Omitted if empty | Allowed values: LIMIT_PRICE, ASK_PRICE, BID_PRICE, LATEST_PRICE; 冰山单默认 LIMIT_PRICE |
Returns
(*model.PreviewResult, error). Key fields from model.PreviewResult:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| IsPass | bool | Whether risk check passed |
| Commission | float64 | Estimated commission |
| CommissionCurrency | string | Commission currency |
| MarginCurrency | string | Margin currency |
| InitMargin | float64 | Initial margin (after order) |
| InitMarginBefore | float64 | Initial margin (before order) |
| MaintMargin | float64 | Maintenance margin (after order) |
| MaintMarginBefore | float64 | Maintenance margin (before order) |
| EquityWithLoan | float64 | Equity with loan (after order) |
| EquityWithLoanBefore | float64 | Equity with loan (before order) |
| AvailableEE | float64 | Available excess equity |
| ExcessLiquidity | float64 | Excess liquidity |
| OvernightLiquidation | float64 | Overnight liquidation value |
Invocation example
result, err := tc.PreviewOrder(model.OrderRequest{
Account: "U123456",
ID: 1,
Action: "BUY",
OrderType: "LMT",
TotalQuantity: 1,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", result){
"commission": 0.99,
"margin": 31000.00,
"buyingPower": 94000.00,
"estimatedPrice": 310.00,
"message": "",
"warning": ""
}ModifyOrder
ModifyOrderPurpose
Changes an existing order identified by its global ID.
Signature
func (c *TradeClient) ModifyOrder(id int64, order model.OrderRequest) (*model.OrderIDResult, error)Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.
Parameters
model.OrderRequest
| SDK field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Action | string | No | Omitted if empty | Allowed values: BUY, SELL |
OrderType | string | No | Omitted if empty | Allowed values: MKT, LMT, STP, STP_LMT, TRAIL, AM, AL, TWAP, VWAP, OCA, ICEBERG |
TimeInForce | string | No | Omitted if empty | Allowed values: DAY, GTC, OPG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
Currency | string | No | Omitted if empty | Allowed values: ALL, USD, HKD, CNH, SGD |
Right | string | No | Omitted if empty | Allowed values: PUT, CALL (option side); br, nr when used as quote adjustment |
MinDisplaySize | int64 | No | Omitted if empty | None; 冰山单缺省等于 DisplaySize |
CheckIntervals | int64 | No | Omitted if empty | None; 冰山单默认 30 秒 |
PriceType | string | No | Omitted if empty | Allowed values: LIMIT_PRICE, ASK_PRICE, BID_PRICE, LATEST_PRICE; 冰山单默认 LIMIT_PRICE |
Returns
(*model.OrderIDResult, error). Key fields from model.OrderIDResult:
| Field | Type | Description |
|---|---|---|
| ID | int64 | Order ID |
Invocation example
result, err := tc.ModifyOrder(123456789, model.OrderRequest{
Account: "U123456",
ID: 1,
Action: "BUY",
OrderType: "LMT",
TotalQuantity: 1,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", result){
"id": 123456789,
"orderId": 123456789,
"symbol": "AAPL",
"action": "BUY",
"orderType": "LMT",
"limitPrice": 308.00,
"totalQuantity": 100,
"filledQuantity": 0,
"status": "Initial",
"account": "12345678"
}CancelOrder
CancelOrderPurpose
Cancels an existing order identified by its global ID.
Signature
func (c *TradeClient) CancelOrder(id int64) (*model.OrderIDResult, error)Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.
Parameters
| Parameter | Type | Required | SDK default | Constraints |
|---|---|---|---|---|
id | int64 | Yes | None | Global order ID |
Returns
(*model.OrderIDResult, error). Key fields from model.OrderIDResult:
| Field | Type | Description |
|---|---|---|
| ID | int64 | Order ID |
Invocation example
result, err := tc.CancelOrder(123456789)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", result){
"id": 123456789,
"orderId": 123456789,
"symbol": "AAPL",
"action": "BUY",
"orderType": "LMT",
"limitPrice": 310.00,
"totalQuantity": 100,
"filledQuantity": 0,
"status": "Cancelled",
"account": "12345678"
}EstimateTradableQuantity
EstimateTradableQuantityPurpose
Estimates cash-buy, margin-buy, short-sell, and position-sell quantities. The client fills an empty account field from the client default.
Signature
func (c *TradeClient) EstimateTradableQuantity(req model.EstimateTradableQuantityRequest) (*model.EstimateTradableQuantity, error)Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.
Parameters
model.EstimateTradableQuantityRequest
| SDK field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Right | string | No | Omitted if empty | Allowed values: PUT, CALL (option side); br, nr when used as quote adjustment |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
Action | string | No | Omitted if empty | Allowed values: BUY, SELL |
OrderType | string | No | Omitted if empty | Allowed values: MKT, LMT, STP, STP_LMT, TRAIL, AM, AL, TWAP, VWAP, OCA, ICEBERG |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
(*model.EstimateTradableQuantity, error). Key fields from model.EstimateTradableQuantity:
| Field | Type | Description |
|---|---|---|
| TradableQuantity | float64 | Tradable quantity |
| MaxCashBuyQuantity | float64 | Max cash buy quantity |
| MaxMarginBuyQuantity | float64 | Max margin buy quantity |
| MaxShortSellQuantity | float64 | Max short sell quantity |
| MaxPositionSellQuantity | float64 | Max position sell quantity |
| CashBuyingPower | float64 | Cash buying power |
| Currency | string | Currency |
Invocation example
result, err := tc.EstimateTradableQuantity(model.EstimateTradableQuantityRequest{
Account: "U123456",
Symbol: "AAPL",
Expiry: "20260619",
Strike: "200",
Right: "CALL",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", result){
"tradableQuantity": 320,
"financingAmount": 99200.00,
"positionAmount": 0.0
}Updated about 17 hours ago
