0
关注
0
关注者
exchange.GetPosition() 使用注意事项,要先判断是否为空数组
创建于 2018-11-07 08:17:28 更新于 2019-04-17 15:52:12
2
2417
exchange.SetTimeout(3000);
exchange.SetContractType("XBTUSD");
//取得第一次币量
position = _C(exchange.GetPosition);
last_Amount = position[0].Amount; //持币数量
hold_price = Math.round(position[0].Price); //持币均价
TypeError: cannot read property 'Amount' of undefined at main (FILE:38)
相关推荐
评论
全部评论 (2)
var position = _C(exchange.GetPosition);
Log("持仓数组实际内容", position);
var len = position.length; //取数组长度var
Log("持仓数组长度", len);
结果 len :空仓是0,有仓是1
取数组长度,怎么是1,不是其它数字
谢谢小小梦
8 年前
GetPosition 返回的是持仓数组, 如果没有持仓返回的是 [] , 一个空数组, 如果没有持仓, 后面代码 调用position[0].Amount 肯定就报错了,因为position[0] 是不存在的。
这个是您策略程序没有处理好。
8 年前
- 1
