1
Follow
0
Followers
Tổng quan về lợi nhuận của thử nghiệm mô phỏng là chỉ có doanh số bán mà không có giao dịch mua.
Created 2020-12-07 23:24:34
2
1176
Như tôi đã thấy trên hình, khi tôi kiểm tra giao dịch tiền mặt, tôi thấy rằng biểu đồ tổng quan lợi nhuận đã tính mua là kho trống, bán không có thống kê, không biết có vị thần nào có thể chỉ ra điều đó.
Một điều khác nữa làexchange.GetPosition()Phương pháp này không được hỗ trợ trong phản hồi.
Mã như sau:
javascript
/*backtest
start: 2020-05-01 00:00:00
end: 2020-12-03 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Huobi","currency":"BTC_USDT"}]
*/
var times = 0;
var lasttime = null;
var hasPosition = false; //持仓数量
function main() {
Log("strategy started.");
while(true){
var records = _C(exchange.GetRecords, PERIOD_D1);
records = records.slice(-20);
var {Time} = records[records.length - 1];
if(lasttime != Time){
lasttime = Time;
var fast = TA.MA(records, 5);
var slow = TA.MA(records, 20);
var lastFast1 = fast[fast.length - 2];
var lastSlow1 = slow[slow.length - 2];
var lastFast2 = fast[fast.length - 3];
var lastSlow2 = slow[slow.length - 3];
if(lastFast2 < lastSlow2 && lastFast1 > lastSlow1 && !hasPosition){
//当前为金叉
//$.Buy(0.001);
exchange.Buy(-1, 0.01);
hasPosition = true;
}
if(lastFast2 > lastSlow2 && lastFast1 < lastSlow1 && hasPosition){
//当前为死叉
exchange.Sell(-1, 0.01);
hasPosition = false;
}
}
}
}
function init() {
const account = _C(exchange.GetAccount);
Log('strategy inted.', exchange.GetName(), account);
}
Related Recommendations
How to Specify Different Versions of Data for the Rented Strategy by Its Rental Code MetadataAdvanced Tutorial for FMZ Quant platform Strategy WritingElementary Tutorial for FMZ Quant platform Strategy WritingGet Started with FMZ Quant PlatformSECURITY BUGI keep getting error: Exchange_GetAccount: Invalid ContractTypeWe have an incredibly profitable market making algorithm for sideways markets on Bitmex - but need expert to help eliminate wait times during downward volatility in the marketError with deribitLimitations of the backtesting engineHow to install ta-lib on linux docker?


