Loading ...

关于如何在BitMEX挂仅被动成交做市单和批量下单(IO范例)

Author: 小草, Created: 2019-04-17 15:46:32, Updated: 2019-04-19 15:25:48

使用IO函数,具体参数参考BitMEX文档:https://www.fmz.com/bbs-topic/3666

做市单(仅被动成交)

var id = exchange.IO("api", "POST", "/api/v1/order", "symbol=XBTUSD&side=Buy&orderQty=1&price=5000&execInst=ParticipateDoNotInitiate")

批量挂单

var bulk = []
bulk.push({symbol:'XBTUSD', side:'Buy', orderQty:100, price:5000, execInst:'ParticipateDoNotInitiate'})
bulk.push({symbol:'XBTUSD', side:'Buy', orderQty:200, price:5100, execInst:'ParticipateDoNotInitiate'})
var param = "orders=" + JSON.stringify(bulk)
var ids = exchange.IO("api", "POST", "/api/v1/order/bulk", param)
Log(ids)

撤销所有订单

exchange.IO("api","DELETE","/api/v1/order/all","symbol=XBTUSD")

Related

More

wufuhao100w 如果是post_only的话有可能下单不成功的,如果下单不成功的话会返回什么值呢?会不会导致机器人停止?

不要香菜 HTTP请求 POST /api/futures/v3/order 请求示例 POST/api/futures/v3/order{"client_oid": “12233456”,"order_type”:”1”,"instrument_id":"BTC-USD-180213","type":"1","price":"432.11","size":"2","match_price":"0"} order_type String 否 参数填数字,0:普通委托(order type不填或填0都是普通委托) 1:只做Maker(Post only) 2:全部成交或立即取消(FOK) 3:立即成交并取消剩余(IOC)

wufuhao100w 好的

小草 直接Log的返回结果吗,查bitmex文档就好

wufuhao100w 不好意思又来打扰您了,我下单成功了但是返回的是一串信息并不是订单id: map[account:251345 avgPx:<nil> clOrdID: clOrdLinkID: contingencyType: cumQty:0 currency:XBT displayQty:<nil> exDestination:XBME execInst:ParticipateDoNotInitiate leavesQty:20 multiLegReporting 请问怎么解决?

wufuhao100w 好的,谢谢

小草 对,str(num)

wufuhao100w 你好,我尝试了一下,报错说TypeError: can only concatenate str (not "int") to str,用的是python,是否要把orderQty = 1的“1”和price = 5000的“5000”改成字符串格式?

小草 对,最好再查一下文档,看看有没有变

wufuhao100w 想问一下大神,如果我要下post_only的单只需要把上面的代码 exchange.IO("api", "POST", "/api/v1/order", "symbol=XBTUSD&side=Buy&orderQty=1&price=5000&execInst=ParticipateDoNotInitiate") 复制过去就可以了吗?具体就是把方向、价格、数量的参数改成想要的数值就可以了?

wufuhao100w 好的,谢谢

小草 看bitemx的文档,有返回结果介绍。要处理正确就不会有问题