# Place Combo Order
- Python
- Proto
- C#
- Java
- C++
- JavaScript
place_combo_order(combo_leg_list, price, qty, order_type=OrderType.NORMAL, trd_env=TrdEnv.REAL, acc_id=0, acc_index=0, remark="", time_in_force=TimeInForce.DAY, expire_time=None)
Description
Submit combo option/combo strategy orders.
Tips
The Python API is synchronous, but the network transport is asynchronous. When the receiving time interval is very short between the response packet of place_combo_order and Order Fill Push Callback or Order Push Callback, it may happen that the response packet of place_combo_order returns first, but the callback function is called first.
Parameters
Parameter Type Description combo_leg_list list Combo leg list - Each element is a ComboLeg object describing a security and trading direction in the combo
- See the table below for ComboLeg fields
price float Order price - When the order is a market order or auction order type, you still need to pass price; any value is acceptable
- Precision rules are the same as the price parameter in place_order
qty float Order quantity Combo order quantity; the actual quantity of each leg is qty × that leg's qty_ratioorder_type OrderType Order type trd_env TrdEnv Trading environment acc_id int Trading account ID - Either acc_id or acc_index can be used to specify the trading account; acc_id is recommended
- When acc_id is 0, the account specified by acc_index is used
- When acc_id is a non-zero ID, the account specified by acc_id is used
acc_index int Account index in the trading account list - Either acc_id or acc_index can be used to specify the trading account; acc_id is recommended
- acc_index defaults to 0, meaning the first trading account
remark str Remark - The order carries this remark field to help you identify the order
- Maximum length after converting to UTF-8 is 64 bytes
time_in_force TimeInForce Valid period expire_time str Order expiry time Valid when time_in_force is GTD; format: yyyy-MM-dd- ComboLeg object fields:
Field Type Description code str Security code, e.g. US.AAPL、US.AAPL260529C302500 trd_side TrdSide Trading direction of this leg qty_ratio float Quantity ratio Actual quantity of this leg = order qty × qty_ratioposition_id int Position ID Required when closing a position. Use the position_id from the option strategy view returned by Get Position List with show_option_strategy_view=True.
Return
Field Type Description ret RET_CODE Interface result. data pd.DataFrame If ret == RET_OK, order list is returned. str If ret != RET_OK, error description is returned. - Order list format as follows:
Field Type Description order_id str Order ID code str Combo strategy code strategy_type OptionStrategyType Combo strategy type trd_side TrdSide Trading direction order_type OrderType Order type order_status OrderStatus Order status qty float Order quantity price float Order price amount float Order amount time_in_force TimeInForce Valid period expire_time str Expiry time dealt_qty float Deal quantity dealt_avg_price float Average deal price create_time str Create time updated_time str Last update time last_err_msg str Last error description remark str Remark combo_legs list Combo leg list Elements are ComboLeg objects
- Order list format as follows:
Example
from futu import *
trd_ctx = OpenSecTradeContext(filter_trdmarket=TrdMarket.US, host='127.0.0.1', port=11111, security_firm=SecurityFirm.FUTUSECURITIES)
leg1 = ComboLeg()
leg1.code = 'US.AAPL260529C302500'
leg1.trd_side = TrdSide.BUY
leg1.qty_ratio = 1
leg2 = ComboLeg()
leg2.code = 'US.AAPL'
leg2.trd_side = TrdSide.SELL
leg2.qty_ratio = 100
combo_legs = [leg1, leg2]
ret, data = trd_ctx.place_combo_order(combo_legs, price=9.9, qty=1, order_type=OrderType.NORMAL, trd_env=TrdEnv.SIMULATE)
if ret == RET_OK:
print(data)
print(data['order_id'][0])
else:
print('place_combo_order error: ', data)
trd_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- Output
order_id code strategy_type trd_side order_type order_status qty price ...
0 FH1C79E90941477000 ... ... ... NORMAL SUBMITTING 1.0 9.9 ...
FH1C79E90941477000
2
3
# Trd_PlaceComboOrder.proto
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1; //Packet ID, used to prevent replay attack for trade write operations
required Trd_Common.TrdHeader header = 2; //Transaction common header
repeated Qot_Common.ComboLeg comboLegs = 3; //Combo leg information
required double qty = 4; //Quantity; actual quantity is qty * leg qty_ratio
optional double price = 5; //Price
required int32 orderType = 6; //Order type; see Trd_Common.OrderType enumeration definition
optional int32 timeInForce = 7; //Time in force; see TrdCommon_TimeInForce enumeration definition
optional string expireTime = 8; //Order expiry time; valid when timeInForce is GTD
optional string remark = 9; //User remark string; up to 64 bytes
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- For request packet ID, refer to PacketID
- For protocol header, refer to TrdHeader
- For combo leg structure, refer to ComboLeg
- For order type, refer to OrderType
- For time in force, refer to TimeInForce
- Return
message S2C
{
required Trd_Common.TrdHeader header = 1; //Transaction common header
optional string orderIDEx = 2; //Server order ID
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
Protocol ID
2227
uint PlaceComboOrder(TrdPlaceComboOrder.Request req);
virtual void OnReply_PlaceComboOrder(FTAPI_Conn client, uint nSerialNo, TrdPlaceComboOrder.Response rsp);
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Callback
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
- Example
public class Program : FTSPI_Trd, FTSPI_Conn {
FTAPI_Trd trd = new FTAPI_Trd();
public Program() {
trd.SetClientInfo("csharp", 1); //Set client info
trd.SetConnCallback(this); //Set connection callback
trd.SetTrdCallback(this); //Set trade callback
}
public void Start() {
trd.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(FTAPI_Conn client, long errCode, String desc)
{
Console.Write("Trd onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
TrdCommon.TrdHeader header = TrdCommon.TrdHeader.CreateBuilder()
.SetAccID(281756457888247915L)
.SetTrdEnv((int)TrdCommon.TrdEnv.TrdEnv_Simulate)
.SetTrdMarket((int)TrdCommon.TrdMarket.TrdMarket_US)
.Build();
QotCommon.ComboLeg leg1 = QotCommon.ComboLeg.CreateBuilder()
.SetSecurity(QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_US_Security)
.SetCode("AAPL260529C302500")
.Build())
.SetSide((int)TrdCommon.TrdSide.TrdSide_Buy)
.SetQtyRatio(1)
.Build();
QotCommon.ComboLeg leg2 = QotCommon.ComboLeg.CreateBuilder()
.SetSecurity(QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_US_Security)
.SetCode("AAPL")
.Build())
.SetSide((int)TrdCommon.TrdSide.TrdSide_Sell)
.SetQtyRatio(100)
.Build();
TrdPlaceComboOrder.C2S c2s = TrdPlaceComboOrder.C2S.CreateBuilder()
.SetPacketID(trd.NextPacketID())
.SetHeader(header)
.AddComboLegs(leg1)
.AddComboLegs(leg2)
.SetQty(1)
.SetPrice(9.9)
.SetOrderType((int)TrdCommon.OrderType.OrderType_Normal)
.SetTimeInForce((int)TrdCommon.TimeInForce.TimeInForce_DAY)
.SetRemark("combo-demo")
.Build();
TrdPlaceComboOrder.Request req = TrdPlaceComboOrder.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = trd.PlaceComboOrder(req);
Console.Write("Send TrdPlaceComboOrder: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Trd onDisConnect: {0}\n", errCode);
}
public void OnReply_PlaceComboOrder(FTAPI_Conn client, uint nSerialNo, TrdPlaceComboOrder.Response rsp)
{
Console.Write("Reply: TrdPlaceComboOrder: {0}\n", nSerialNo);
Console.Write("orderIDEx: {0}\n", rsp.S2C.OrderIDEx);
}
public static void Main(String[] args) {
FTAPI.Init();
Program trd = new Program();
trd.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
- Output
Trd onInitConnect: ret=0 desc= connID=6827788355222092042
Send TrdPlaceComboOrder: 3
Reply: TrdPlaceComboOrder: 3
orderIDEx: FH1C79E90941477000
2
3
4
int placeComboOrder(TrdPlaceComboOrder.Request req);
void onReply_PlaceComboOrder(FTAPI_Conn client, int nSerialNo, TrdPlaceComboOrder.Response rsp);
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Callback
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
- Example
public class TrdDemo implements FTSPI_Trd, FTSPI_Conn {
FTAPI_Conn_Trd trd = new FTAPI_Conn_Trd();
public TrdDemo() {
trd.setClientInfo("javaclient", 1); //Set client info
trd.setConnSpi(this); //Set connection callback
trd.setTrdSpi(this); //Set trade callback
}
public void start() {
trd.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc)
{
System.out.printf("Trd onInitConnect: ret=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
TrdCommon.TrdHeader header = TrdCommon.TrdHeader.newBuilder()
.setAccID(281756457888247915L)
.setTrdEnv(TrdCommon.TrdEnv.TrdEnv_Simulate_VALUE)
.setTrdMarket(TrdCommon.TrdMarket.TrdMarket_US_VALUE)
.build();
QotCommon.ComboLeg leg1 = QotCommon.ComboLeg.newBuilder()
.setSecurity(QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_US_Security_VALUE)
.setCode("AAPL260529C302500")
.build())
.setSide(TrdCommon.TrdSide.TrdSide_Buy_VALUE)
.setQtyRatio(1)
.build();
QotCommon.ComboLeg leg2 = QotCommon.ComboLeg.newBuilder()
.setSecurity(QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_US_Security_VALUE)
.setCode("AAPL")
.build())
.setSide(TrdCommon.TrdSide.TrdSide_Sell_VALUE)
.setQtyRatio(100)
.build();
TrdPlaceComboOrder.C2S c2s = TrdPlaceComboOrder.C2S.newBuilder()
.setPacketID(trd.nextPacketID())
.setHeader(header)
.addComboLegs(leg1)
.addComboLegs(leg2)
.setQty(1)
.setPrice(9.9)
.setOrderType(TrdCommon.OrderType.OrderType_Normal_VALUE)
.setTimeInForce(TrdCommon.TimeInForce.TimeInForce_DAY_VALUE)
.setRemark("combo-demo")
.build();
TrdPlaceComboOrder.Request req = TrdPlaceComboOrder.Request.newBuilder().setC2S(c2s).build();
int seqNo = trd.placeComboOrder(req);
System.out.printf("Send TrdPlaceComboOrder: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Trd onDisConnect: %d\n", errCode);
}
@Override
public void onReply_PlaceComboOrder(FTAPI_Conn client, int nSerialNo, TrdPlaceComboOrder.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("TrdPlaceComboOrder failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive TrdPlaceComboOrder: %s\n", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
FTAPI.init();
TrdDemo trd = new TrdDemo();
trd.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- Output
Send TrdPlaceComboOrder: 2
Receive TrdPlaceComboOrder: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"header": {
"trdEnv": 0,
"accID": "281756457888247915",
"trdMarket": 2
},
"orderIDEx": "FH1C79E90941477000"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
Futu::u32_t PlaceComboOrder(const Trd_PlaceComboOrder::Request &stReq);
virtual void OnReply_PlaceComboOrder(Futu::u32_t nSerialNo, const Trd_PlaceComboOrder::Response &stRsp) = 0;
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
2
3
4
5
6
7
8
9
10
11
12
- Callback
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
2
3
4
5
- Example
class Program : public FTSPI_Qot, public FTSPI_Trd, public FTSPI_Conn
{
public:
Program() {
m_pTrdApi = FTAPI::CreateTrdApi();
m_pTrdApi->RegisterTrdSpi(this);
m_pTrdApi->RegisterConnSpi(this);
}
~Program() {
if (m_pTrdApi != nullptr)
{
m_pTrdApi->UnregisterTrdSpi();
m_pTrdApi->UnregisterConnSpi();
FTAPI::ReleaseTrdApi(m_pTrdApi);
m_pTrdApi = nullptr;
}
}
void Start() {
m_pTrdApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(FTAPI_Conn* pConn, Futu::i64_t nErrCode, const char* strDesc) {
cout << "connect" << endl;
// Pack request
Trd_PlaceComboOrder::Request req;
Trd_PlaceComboOrder::C2S *c2s = req.mutable_c2s();
Trd_Common::TrdHeader *header = c2s->mutable_header();
header->set_accid(3637840);
header->set_trdenv(0);
header->set_trdmarket(2);
Qot_Common::ComboLeg *leg1 = c2s->add_combolegs();
leg1->mutable_security()->set_market(Qot_Common::QotMarket_US_Security);
leg1->mutable_security()->set_code("AAPL260529C302500");
leg1->set_side(Trd_Common::TrdSide_Buy);
leg1->set_qtyratio(1);
Qot_Common::ComboLeg *leg2 = c2s->add_combolegs();
leg2->mutable_security()->set_market(Qot_Common::QotMarket_US_Security);
leg2->mutable_security()->set_code("AAPL");
leg2->set_side(Trd_Common::TrdSide_Sell);
leg2->set_qtyratio(100);
c2s->set_qty(1);
c2s->set_price(9.9);
c2s->set_ordertype(Trd_Common::OrderType_Normal);
m_PlaceComboOrderSerialNo = m_pTrdApi->PlaceComboOrder(req);
cout << "Request PlaceComboOrder SerialNo: " << m_PlaceComboOrderSerialNo << endl;
}
virtual void OnReply_PlaceComboOrder(Futu::u32_t nSerialNo, const Trd_PlaceComboOrder::Response &stRsp){
if(nSerialNo == m_PlaceComboOrderSerialNo)
{
cout << "OnReply_PlaceComboOrder SerialNo: " << nSerialNo << endl;
// Parse and print internal structure
// See tool.h in Sample for ProtoBufToBodyData and UTF8ToLocal definitions
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
FTAPI_Trd *m_pTrdApi;
Futu::u32_t m_PlaceComboOrderSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
FTAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
FTAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
- Output
connect
Request PlaceComboOrder SerialNo: 4
OnReply_PlaceComboOrder SerialNo: 4
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"header": {
"trdEnv": 0,
"accID": "3637840",
"trdMarket": 2
},
"orderIDEx": "FH1C79E90941477000"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PlaceComboOrder(req);
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
2
3
4
5
6
7
8
9
10
11
12
- Return
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
2
3
4
5
- Example
import ftWebsocket from "futu-api";
import { ftCmdID } from "futu-api";
import { Common, Qot_Common, Trd_Common } from "futu-api/proto";
import beautify from "js-beautify";
function TrdPlaceComboOrder(){
const { RetType, PacketID } = Common
const { TrdEnv, TrdSide, OrderType, SecurityFirm, TrdMarket, TimeInForce } = Trd_Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new ftWebsocket();
let tradeSerialNo = 0;
websocket.onlogin = async ()=>{
try{
let { errCode, retMsg, retType } = await websocket.UnlockTrade({
c2s: {
unlock: true,
securityFirm: SecurityFirm.SecurityFirm_FutuSecurities,
pwdMD5: "d0970714757783e6cf17b26fb8e2298f", // Set to your account trading password MD5
},
});
if(retType == RetType.RetType_Succeed && errCode == 0) { // Unlock trade succeeded
let { errCode, retMsg, retType, s2c: { accList } } = await websocket.GetAccList({
c2s: {
userID: 0,
},
});
if(retType == RetType.RetType_Succeed && errCode == 0) { // Get account list succeeded
let acc = accList.filter((item)=>{
return item.trdEnv == TrdEnv.TrdEnv_Simulate && item.trdMarketAuthList.some((auth)=>{ return auth == TrdMarket.TrdMarket_US})
})[0]; // Example: first US paper trading account
const req = {
c2s: {
packetID:{
connID: websocket.getConnID(),
serialNo: tradeSerialNo++,
},
header: {
trdEnv: acc.trdEnv,
accID: acc.accID,
trdMarket: TrdMarket.TrdMarket_US,
},
comboLegs: [
{
security: {
market: QotMarket.QotMarket_US_Security,
code: "AAPL260529C302500",
},
side: TrdSide.TrdSide_Buy,
qtyRatio: 1,
},
{
security: {
market: QotMarket.QotMarket_US_Security,
code: "AAPL",
},
side: TrdSide.TrdSide_Sell,
qtyRatio: 100,
},
],
qty: 1,
price: 9.9,
orderType: OrderType.OrderType_Normal,
timeInForce: TimeInForce.TimeInForce_DAY,
remark: "combo-demo",
},
};
let { errCode, retMsg, retType, s2c } = await websocket.PlaceComboOrder(req);
console.log("PlaceComboOrder: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(data);
}
}
}
}
catch(err){
console.log(err)
}
};
websocket.start(addr, port, enable_ssl, key);
//Close the connection when no longer needed to avoid wasting resources
//OpenD also limits a maximum of 128 connections
//You can maintain one connection per page or project; this example creates one connection per request
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // Disconnect after 5 seconds
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
- Output
PlaceComboOrder: errCode 0, retMsg , retType 0
{
"header": {
"trdEnv": 0,
"accID": "6684972",
"trdMarket": 2
},
"orderIDEx": "FH1C79E90941477000"
}
stop
2
3
4
5
6
7
8
9
10
Interface Limitations
- A maximum of 15 requests per 30 seconds under a single account ID (acc_id), and the interval between two consecutive requests cannot be less than 0.02 seconds. Shared frequency limit with Place Order.
- When using live trading accounts, you need to unlock trade before calling the order placement interface; paper trading accounts do not require unlocking.
Tips
- Securities in combo_leg_list must belong to the same trading market; the system determines trd_market based on the first leg's market.
- Each leg's qty_ratio and qty together determine the actual order quantity of each leg.
- Python
- Proto
- C#
- Java
- C++
- JavaScript
place_combo_order(combo_leg_list, price, qty, order_type=OrderType.NORMAL, trd_env=TrdEnv.REAL, acc_id=0, acc_index=0, remark="", time_in_force=TimeInForce.DAY, expire_time=None)
Description
Submit combo option/combo strategy orders.
Tips
The Python API is synchronous, but the network transport is asynchronous. When the receiving time interval is very short between the response packet of place_combo_order and Order Fill Push Callback or Order Push Callback, it may happen that the response packet of place_combo_order returns first, but the callback function is called first.
Parameters
Parameter Type Description combo_leg_list list Combo leg list - Each element is a ComboLeg object describing a security and trading direction in the combo
- See the table below for ComboLeg fields
price float Order price - When the order is a market order or auction order type, you still need to pass price; any value is acceptable
- Precision rules are the same as the price parameter in place_order
qty float Order quantity Combo order quantity; the actual quantity of each leg is qty × that leg's qty_ratioorder_type OrderType Order type trd_env TrdEnv Trading environment acc_id int Trading account ID - Either acc_id or acc_index can be used to specify the trading account; acc_id is recommended
- When acc_id is 0, the account specified by acc_index is used
- When acc_id is a non-zero ID, the account specified by acc_id is used
acc_index int Account index in the trading account list - Either acc_id or acc_index can be used to specify the trading account; acc_id is recommended
- acc_index defaults to 0, meaning the first trading account
remark str Remark - The order carries this remark field to help you identify the order
- Maximum length after converting to UTF-8 is 64 bytes
time_in_force TimeInForce Valid period expire_time str Order expiry time Valid when time_in_force is GTD; format: yyyy-MM-dd- ComboLeg object fields:
Field Type Description code str Security code, e.g. US.AAPL、US.AAPL260529C302500 trd_side TrdSide Trading direction of this leg qty_ratio float Quantity ratio Actual quantity of this leg = order qty × qty_ratioposition_id int Position ID Required when closing a position. Use the position_id from the option strategy view returned by Get Position List with show_option_strategy_view=True.
Return
Field Type Description ret RET_CODE Interface result. data pd.DataFrame If ret == RET_OK, order list is returned. str If ret != RET_OK, error description is returned. - Order list format as follows:
Field Type Description order_id str Order ID code str Combo strategy code strategy_type OptionStrategyType Combo strategy type trd_side TrdSide Trading direction order_type OrderType Order type order_status OrderStatus Order status qty float Order quantity price float Order price amount float Order amount time_in_force TimeInForce Valid period expire_time str Expiry time dealt_qty float Deal quantity dealt_avg_price float Average deal price create_time str Create time updated_time str Last update time last_err_msg str Last error description remark str Remark combo_legs list Combo leg list Elements are ComboLeg objects
- Order list format as follows:
Example
from moomoo import *
trd_ctx = OpenSecTradeContext(filter_trdmarket=TrdMarket.US, host='127.0.0.1', port=11111, security_firm=SecurityFirm.FUTUINC)
leg1 = ComboLeg()
leg1.code = 'US.AAPL260529C302500'
leg1.trd_side = TrdSide.BUY
leg1.qty_ratio = 1
leg2 = ComboLeg()
leg2.code = 'US.AAPL'
leg2.trd_side = TrdSide.SELL
leg2.qty_ratio = 100
combo_legs = [leg1, leg2]
ret, data = trd_ctx.place_combo_order(combo_legs, price=9.9, qty=1, order_type=OrderType.NORMAL, trd_env=TrdEnv.SIMULATE)
if ret == RET_OK:
print(data)
print(data['order_id'][0])
else:
print('place_combo_order error: ', data)
trd_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- Output
order_id code strategy_type trd_side order_type order_status qty price ...
0 FH1C79E90941477000 ... ... ... NORMAL SUBMITTING 1.0 9.9 ...
FH1C79E90941477000
2
3
# Trd_PlaceComboOrder.proto
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1; //Packet ID, used to prevent replay attack for trade write operations
required Trd_Common.TrdHeader header = 2; //Transaction common header
repeated Qot_Common.ComboLeg comboLegs = 3; //Combo leg information
required double qty = 4; //Quantity; actual quantity is qty * leg qty_ratio
optional double price = 5; //Price
required int32 orderType = 6; //Order type; see Trd_Common.OrderType enumeration definition
optional int32 timeInForce = 7; //Time in force; see TrdCommon_TimeInForce enumeration definition
optional string expireTime = 8; //Order expiry time; valid when timeInForce is GTD
optional string remark = 9; //User remark string; up to 64 bytes
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- For request packet ID, refer to PacketID
- For protocol header, refer to TrdHeader
- For combo leg structure, refer to ComboLeg
- For order type, refer to OrderType
- For time in force, refer to TimeInForce
- Return
message S2C
{
required Trd_Common.TrdHeader header = 1; //Transaction common header
optional string orderIDEx = 2; //Server order ID
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
Protocol ID
2227
uint PlaceComboOrder(TrdPlaceComboOrder.Request req);
virtual void OnReply_PlaceComboOrder(MMAPI_Conn client, uint nSerialNo, TrdPlaceComboOrder.Response rsp);
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Callback
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
- Example
public class Program : MMSPI_Trd, MMSPI_Conn {
MMAPI_Trd trd = new MMAPI_Trd();
public Program() {
trd.SetClientInfo("csharp", 1); //Set client info
trd.SetConnCallback(this); //Set connection callback
trd.SetTrdCallback(this); //Set trade callback
}
public void Start() {
trd.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(MMAPI_Conn client, long errCode, String desc)
{
Console.Write("Trd onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
TrdCommon.TrdHeader header = TrdCommon.TrdHeader.CreateBuilder()
.SetAccID(281756457888247915L)
.SetTrdEnv((int)TrdCommon.TrdEnv.TrdEnv_Simulate)
.SetTrdMarket((int)TrdCommon.TrdMarket.TrdMarket_US)
.Build();
QotCommon.ComboLeg leg1 = QotCommon.ComboLeg.CreateBuilder()
.SetSecurity(QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_US_Security)
.SetCode("AAPL260529C302500")
.Build())
.SetSide((int)TrdCommon.TrdSide.TrdSide_Buy)
.SetQtyRatio(1)
.Build();
QotCommon.ComboLeg leg2 = QotCommon.ComboLeg.CreateBuilder()
.SetSecurity(QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_US_Security)
.SetCode("AAPL")
.Build())
.SetSide((int)TrdCommon.TrdSide.TrdSide_Sell)
.SetQtyRatio(100)
.Build();
TrdPlaceComboOrder.C2S c2s = TrdPlaceComboOrder.C2S.CreateBuilder()
.SetPacketID(trd.NextPacketID())
.SetHeader(header)
.AddComboLegs(leg1)
.AddComboLegs(leg2)
.SetQty(1)
.SetPrice(9.9)
.SetOrderType((int)TrdCommon.OrderType.OrderType_Normal)
.SetTimeInForce((int)TrdCommon.TimeInForce.TimeInForce_DAY)
.SetRemark("combo-demo")
.Build();
TrdPlaceComboOrder.Request req = TrdPlaceComboOrder.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = trd.PlaceComboOrder(req);
Console.Write("Send TrdPlaceComboOrder: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Trd onDisConnect: {0}\n", errCode);
}
public void OnReply_PlaceComboOrder(MMAPI_Conn client, uint nSerialNo, TrdPlaceComboOrder.Response rsp)
{
Console.Write("Reply: TrdPlaceComboOrder: {0}\n", nSerialNo);
Console.Write("orderIDEx: {0}\n", rsp.S2C.OrderIDEx);
}
public static void Main(String[] args) {
MMAPI.Init();
Program trd = new Program();
trd.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
- Output
Trd onInitConnect: ret=0 desc= connID=6827788355222092042
Send TrdPlaceComboOrder: 3
Reply: TrdPlaceComboOrder: 3
orderIDEx: FH1C79E90941477000
2
3
4
int placeComboOrder(TrdPlaceComboOrder.Request req);
void onReply_PlaceComboOrder(MMAPI_Conn client, int nSerialNo, TrdPlaceComboOrder.Response rsp);
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Callback
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
- Example
public class TrdDemo implements MMSPI_Trd, MMSPI_Conn {
MMAPI_Conn_Trd trd = new MMAPI_Conn_Trd();
public TrdDemo() {
trd.setClientInfo("javaclient", 1); //Set client info
trd.setConnSpi(this); //Set connection callback
trd.setTrdSpi(this); //Set trade callback
}
public void start() {
trd.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc)
{
System.out.printf("Trd onInitConnect: ret=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
TrdCommon.TrdHeader header = TrdCommon.TrdHeader.newBuilder()
.setAccID(281756457888247915L)
.setTrdEnv(TrdCommon.TrdEnv.TrdEnv_Simulate_VALUE)
.setTrdMarket(TrdCommon.TrdMarket.TrdMarket_US_VALUE)
.build();
QotCommon.ComboLeg leg1 = QotCommon.ComboLeg.newBuilder()
.setSecurity(QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_US_Security_VALUE)
.setCode("AAPL260529C302500")
.build())
.setSide(TrdCommon.TrdSide.TrdSide_Buy_VALUE)
.setQtyRatio(1)
.build();
QotCommon.ComboLeg leg2 = QotCommon.ComboLeg.newBuilder()
.setSecurity(QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_US_Security_VALUE)
.setCode("AAPL")
.build())
.setSide(TrdCommon.TrdSide.TrdSide_Sell_VALUE)
.setQtyRatio(100)
.build();
TrdPlaceComboOrder.C2S c2s = TrdPlaceComboOrder.C2S.newBuilder()
.setPacketID(trd.nextPacketID())
.setHeader(header)
.addComboLegs(leg1)
.addComboLegs(leg2)
.setQty(1)
.setPrice(9.9)
.setOrderType(TrdCommon.OrderType.OrderType_Normal_VALUE)
.setTimeInForce(TrdCommon.TimeInForce.TimeInForce_DAY_VALUE)
.setRemark("combo-demo")
.build();
TrdPlaceComboOrder.Request req = TrdPlaceComboOrder.Request.newBuilder().setC2S(c2s).build();
int seqNo = trd.placeComboOrder(req);
System.out.printf("Send TrdPlaceComboOrder: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Trd onDisConnect: %d\n", errCode);
}
@Override
public void onReply_PlaceComboOrder(MMAPI_Conn client, int nSerialNo, TrdPlaceComboOrder.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("TrdPlaceComboOrder failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive TrdPlaceComboOrder: %s\n", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MMAPI.init();
TrdDemo trd = new TrdDemo();
trd.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- Output
Send TrdPlaceComboOrder: 2
Receive TrdPlaceComboOrder: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"header": {
"trdEnv": 0,
"accID": "281756457888247915",
"trdMarket": 2
},
"orderIDEx": "FH1C79E90941477000"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
moomoo::u32_t PlaceComboOrder(const Trd_PlaceComboOrder::Request &stReq);
virtual void OnReply_PlaceComboOrder(moomoo::u32_t nSerialNo, const Trd_PlaceComboOrder::Response &stRsp) = 0;
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
2
3
4
5
6
7
8
9
10
11
12
- Callback
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
2
3
4
5
- Example
class Program : public MMSPI_Qot, public MMSPI_Trd, public MMSPI_Conn
{
public:
Program() {
m_pTrdApi = MMAPI::CreateTrdApi();
m_pTrdApi->RegisterTrdSpi(this);
m_pTrdApi->RegisterConnSpi(this);
}
~Program() {
if (m_pTrdApi != nullptr)
{
m_pTrdApi->UnregisterTrdSpi();
m_pTrdApi->UnregisterConnSpi();
MMAPI::ReleaseTrdApi(m_pTrdApi);
m_pTrdApi = nullptr;
}
}
void Start() {
m_pTrdApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(MMAPI_Conn* pConn, moomoo::i64_t nErrCode, const char* strDesc) {
cout << "connect" << endl;
// Pack request
Trd_PlaceComboOrder::Request req;
Trd_PlaceComboOrder::C2S *c2s = req.mutable_c2s();
Trd_Common::TrdHeader *header = c2s->mutable_header();
header->set_accid(3637840);
header->set_trdenv(0);
header->set_trdmarket(2);
Qot_Common::ComboLeg *leg1 = c2s->add_combolegs();
leg1->mutable_security()->set_market(Qot_Common::QotMarket_US_Security);
leg1->mutable_security()->set_code("AAPL260529C302500");
leg1->set_side(Trd_Common::TrdSide_Buy);
leg1->set_qtyratio(1);
Qot_Common::ComboLeg *leg2 = c2s->add_combolegs();
leg2->mutable_security()->set_market(Qot_Common::QotMarket_US_Security);
leg2->mutable_security()->set_code("AAPL");
leg2->set_side(Trd_Common::TrdSide_Sell);
leg2->set_qtyratio(100);
c2s->set_qty(1);
c2s->set_price(9.9);
c2s->set_ordertype(Trd_Common::OrderType_Normal);
m_PlaceComboOrderSerialNo = m_pTrdApi->PlaceComboOrder(req);
cout << "Request PlaceComboOrder SerialNo: " << m_PlaceComboOrderSerialNo << endl;
}
virtual void OnReply_PlaceComboOrder(moomoo::u32_t nSerialNo, const Trd_PlaceComboOrder::Response &stRsp){
if(nSerialNo == m_PlaceComboOrderSerialNo)
{
cout << "OnReply_PlaceComboOrder SerialNo: " << nSerialNo << endl;
// Parse and print internal structure
// See tool.h in Sample for ProtoBufToBodyData and UTF8ToLocal definitions
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
MMAPI_Trd *m_pTrdApi;
moomoo::u32_t m_PlaceComboOrderSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
MMAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
MMAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
- Output
connect
Request PlaceComboOrder SerialNo: 4
OnReply_PlaceComboOrder SerialNo: 4
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"header": {
"trdEnv": 0,
"accID": "3637840",
"trdMarket": 2
},
"orderIDEx": "FH1C79E90941477000"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PlaceComboOrder(req);
Description
Place combo option/combo strategy order
Parameters
message C2S
{
required Common.PacketID packetID = 1;
required Trd_Common.TrdHeader header = 2;
repeated Qot_Common.ComboLeg comboLegs = 3;
required double qty = 4;
optional double price = 5;
required int32 orderType = 6;
optional int32 timeInForce = 7;
optional string expireTime = 8;
optional string remark = 9;
}
2
3
4
5
6
7
8
9
10
11
12
- Return
message S2C
{
required Trd_Common.TrdHeader header = 1;
optional string orderIDEx = 2;
}
2
3
4
5
- Example
import mmWebsocket from "moomoo-api";
import { mmCmdID } from "moomoo-api";
import { Common, Qot_Common, Trd_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function TrdPlaceComboOrder(){
const { RetType, PacketID } = Common
const { TrdEnv, TrdSide, OrderType, SecurityFirm, TrdMarket, TimeInForce } = Trd_Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new mmWebsocket();
let tradeSerialNo = 0;
websocket.onlogin = async ()=>{
try{
let { errCode, retMsg, retType } = await websocket.UnlockTrade({
c2s: {
unlock: true,
securityFirm: SecurityFirm.SecurityFirm_FutuSecurities,
pwdMD5: "d0970714757783e6cf17b26fb8e2298f", // Set to your account trading password MD5
},
});
if(retType == RetType.RetType_Succeed && errCode == 0) { // Unlock trade succeeded
let { errCode, retMsg, retType, s2c: { accList } } = await websocket.GetAccList({
c2s: {
userID: 0,
},
});
if(retType == RetType.RetType_Succeed && errCode == 0) { // Get account list succeeded
let acc = accList.filter((item)=>{
return item.trdEnv == TrdEnv.TrdEnv_Simulate && item.trdMarketAuthList.some((auth)=>{ return auth == TrdMarket.TrdMarket_US})
})[0]; // Example: first US paper trading account
const req = {
c2s: {
packetID:{
connID: websocket.getConnID(),
serialNo: tradeSerialNo++,
},
header: {
trdEnv: acc.trdEnv,
accID: acc.accID,
trdMarket: TrdMarket.TrdMarket_US,
},
comboLegs: [
{
security: {
market: QotMarket.QotMarket_US_Security,
code: "AAPL260529C302500",
},
side: TrdSide.TrdSide_Buy,
qtyRatio: 1,
},
{
security: {
market: QotMarket.QotMarket_US_Security,
code: "AAPL",
},
side: TrdSide.TrdSide_Sell,
qtyRatio: 100,
},
],
qty: 1,
price: 9.9,
orderType: OrderType.OrderType_Normal,
timeInForce: TimeInForce.TimeInForce_DAY,
remark: "combo-demo",
},
};
let { errCode, retMsg, retType, s2c } = await websocket.PlaceComboOrder(req);
console.log("PlaceComboOrder: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(data);
}
}
}
}
catch(err){
console.log(err)
}
};
websocket.start(addr, port, enable_ssl, key);
//Close the connection when no longer needed to avoid wasting resources
//OpenD also limits a maximum of 128 connections
//You can maintain one connection per page or project; this example creates one connection per request
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // Disconnect after 5 seconds
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
- Output
PlaceComboOrder: errCode 0, retMsg , retType 0
{
"header": {
"trdEnv": 0,
"accID": "6684972",
"trdMarket": 2
},
"orderIDEx": "FH1C79E90941477000"
}
stop
2
3
4
5
6
7
8
9
10
Interface Limitations
- A maximum of 15 requests per 30 seconds under a single account ID (acc_id), and the interval between two consecutive requests cannot be less than 0.02 seconds. Shared frequency limit with Place Order.
- When using live trading accounts, you need to unlock trade before calling the order placement interface; paper trading accounts do not require unlocking.
Tips
- Securities in combo_leg_list must belong to the same trading market; the system determines trd_market based on the first leg's market.
- Each leg's qty_ratio and qty together determine the actual order quantity of each leg.