Type/to search
0
Follow
0
Followers
Notas sobre o uso de exchange.GetPosition(): primeiro verifique se é uma matriz vazia
FAQ
Created 2018-11-07 08:17:28  Updated 2019-04-17 15:52:12
 2
 2419
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)
Related Recommendations
Comment
All comments (2)

    var position = _C(exchange.GetPosition);
    Log("持仓数组实际内容", position);

    var len = position.length; //取数组长度var
    Log("持仓数组长度", len);

    结果 len :空仓是0,有仓是1

    取数组长度,怎么是1,不是其它数字

    谢谢小小梦

    8 years ago

    GetPosition 返回的是持仓数组, 如果没有持仓返回的是 [] , 一个空数组, 如果没有持仓, 后面代码 调用position[0].Amount 肯定就报错了,因为position[0] 是不存在的。
    这个是您策略程序没有处理好。

    8 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)