量化交易

Botvs的GetOrder函数不支持Bithumb的解决办法

对于交易所bithumb, 调用botvs的GetOrder函数提示not supported.

年化70%,适用于单边趋势和震荡行情的期货实盘策略,查看详情 >>>

主要原因是:bithumb的api接口返回的数据太少,无法达到封装标准导致的。

解决办法是自己使用io函数,调用bithumb的api获取对应的数值。

以下是代码:

function retry_get_order(ex,order_id,otype){
var exname=ex.GetName();
if (exname.toUpperCase() === “BITHUMB”){
var symbol = ex.GetCurrency();
var arr = symbol.split(“_”);
var currency = arr[0];
var typeValue = (otype===”buy”?ORDER_TYPE_BUY:ORDER_TYPE_SELL);
var urltype=(otype===”buy”?”bid”:”ask”);

var iodata=ex.IO(“api”,”POST”,”/info/order_detail”,”order_id=”+order_id+”&type=”+urltype+”&currency=”+currency);
while (!iodata || iodata.status!==”0000″){
Log(“ex.IO失败,retrying…”);
Sleep(wait_ms);
iodata=ex.IO(“api”,”POST”,”/info/order_detail”,”order_id=”+order_id+”&type=”+urltype+”&currency=”+currency);
}

var orderd={
Info:iodata,
Id:order_id,
Price:0,
Amount:0,
DealAmount:iodata.data[0].units_traded,
AvgPrice:iodata.data[0].price,
Status:ORDER_STATE_CLOSED,
Type:typeValue,
};

return orderd;
}else{
var orderdata=_C(ex.GetOrder,order_id);
return orderdata;
}
}

需要注意的是:如果挂单未成交,bithumb无法使用api接口order_detail获取订单状态。同时也无法使用cancelorder取消未成交订单。

年化70%,适用于单边趋势和震荡行情的期货实盘策略,查看详情 >>>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.