0
Follow
0
Followers
exchange.GetPosition() 사용에 대한 참고사항: 먼저 빈 배열인지 확인하세요
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
JavaScript Bitmex【Recruitment】Quantitative Strategy DevelopmentHow can i get the depth of the market when backtesting?ERR_INSUFFICIENT_ASSET from huobiMyLanguage DocumentHappy Halloween / Coupon-codes for everyone -- FMZ Quant TeamAdding exchanges on our setting listIntroducing Visual Programming on FMZ QuantLooking For PartnershipGreat news! Check out our platforms’ NEW features, the “Demands & Offers” page on our website.
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
