在 调试工具 https://www.fmz.com/m/debug
尝试了各种方式,使用币安合约batchOrders API 下订单,均失败
按照 下面搜索到的讨论内容构造url 依然失败
https://github.com/ccxt/ccxt/issues/6805
function main() {
exchange.SetContractType('swap')
var makeOrders = [
{"symbol":"BTCUSDT","side":"BUY","type":"MARKET","quantity":0.002},
{"symbol":"LTCUSDT","side":"BUY","type":"MARKET","quantity":0.002}
]
params = []
for (var i = 0; i < makeOrders.length; i++) {params.push(encodeURI(JSON.stringify(makeOrders[i])))}
params = "batchOrders=["+params.join(",")+"]"
Log(params)
var allOrders = exchange.IO('api', 'POST', '/fapi/v1/batchOrders',params);
Log(allOrders)
}
提示:信息 [{“code”:400,“msg”:null},{“code”:400,“msg”:null}]
按照 https://www.fmz.com/api 内 exchange.IO 的说明 依然失败
function main() {
exchange.SetContractType('swap')
var makeOrders = {
"batchOrders":[
{"symbol":"BTCUSDT", "side":"BUY" , "positionSide":"LONG" , "type":"MARKET", "quantity":0.001},
{"symbol":"BTCUSDT","side":"SELL","positionSide":"SHORT","type":"MARKET","quantity":0.001}
]
}
var allOrders = exchange.IO('api', 'POST', '/fapi/v1/batchOrders',"",JSON.stringify(makeOrders));
Log(allOrders)
}
提示: Futures_Binance 错误 Futures_OP 4: 400: {“timestamp”:1589196850717,“path”:"/fapi/v1/batchOrders",“msg”:“System error”}
有人币安合约batchOrders API问题,以及应该如何构造params么
谢谢
高吸低抛 /fapi/v1/order 使用 传raw参数 也失败,但是使用 params方式正常 ---------------------------- function main() { exchange.SetContractType('swap') var makeOrders = {symbol:'BTCUSDT',side:'BUY',type:'MARKET',quantity:0.001} params = [] var allOrders = exchange.IO('api', 'POST', '/fapi/v1/order',"",JSON.stringify(makeOrders)); Log(allOrders) } ----------------------------- 提示 Futures_Binance 错误 Futures_OP 4: 400: {"timestamp":1589203472728,"path":"/fapi/v1/order","msg":"System error"}
高吸低抛 单向 逐仓 ,双向 逐仓均无法下单
发明者量化-小小梦 是的,币安文档上写的是为数值型,但是写数值是报错的,都传字符串反而正确了。
高吸低抛 测试可用,但是有个小问题,同参数下 "quantity": "0.001" 正常,"quantity":0.001 则失败,就是说 必须先toString 一下amount,在其他接口没发现这情况 function main() { exchange.SetBase("https://testnet.binancefuture.com") exchange.SetContractType('swap') var amount= 0.001 var theOrder ={"symbol": "BTCUSDT", "side": "BUY" , "positionSide": "LONG" , "type": "MARKET", "quantity": amount} //theOrder = exchange.IO("api", "POST", "/fapi/v1/order", "", JSON.stringify(theOrder)) // 正常 var theOrder = { "batchOrders": [ {"symbol": "BTCUSDT", "side": "BUY" , "positionSide": "LONG" , "type": "MARKET", "quantity": amount} ] } theOrder = exchange.IO("api", "POST", "/fapi/v1/batchOrders", "", JSON.stringify(theOrder)) // 失败 Log(theOrder) }
发明者量化-小小梦 已经升级了,下载最新的托管者使用即可,调用方式例子: ``` function main() { /* 批量下单 var obj = { "batchOrders": [{ "symbol": "BTCUSDT", "side": "BUY", "positionSide": "LONG", "type": "LIMIT", "quantity": "0.001", "price": "8000", "timeInForce": "GTC", }, { "symbol": "BTCUSDT", "side": "BUY", "positionSide": "LONG", "type": "LIMIT", "quantity": "0.001", "price": "8000", "timeInForce": "GTC", } ] } var ret = exchange.IO("api", "POST", "/fapi/v1/batchOrders", "", JSON.stringify(obj)) Log("ret:", ret) */ /* 批量撤单 var obj = { "symbol": "BTCUSDT", "orderIdList": ["3873637971", "3873637970"] } var ret = exchange.IO("api", "DELETE", "/fapi/v1/batchOrders", "", JSON.stringify(obj)) Log("ret:", ret) */ Sleep(1000) Log(exchange.GetOrders()) } ``` 已经测试过了,可以了。
小草 币安下批量底单的权重比单个订单高5倍,只从频率看没必要
高吸低抛 我看 https://www.fmz.com/api exchange.IO( 支持传raw参数的交易所,有币安合约 不过我用 params 也凑活用了 batchOrders API ,用order api一个一个下,嘿嘿
高吸低抛 赞赞赞
小草 确实还没有升级,今天应该可以更新上
小草 币安应该不支持这种方式,文档上有说明
高吸低抛 我用的MARKET,参数应该是够了,用传params方式是正常的(就是你的代码),但是用 传raw参数 就失败 exchange.IO('api', 'POST', '/fapi/v1/order',"",JSON.stringify(makeOrders));
小草 仔细看币安的文档,参数没传全。 ``` exchange.IO("api", "POST","/fapi/v1/order","symbol="+symbol+"USDT&side="+side+"&type=LIMIT&timeInForce=GTC&quantity="+amount+"&price="+price+"×tamp="+Date.now()) ```