策略目标:策略的涨幅大于BTC每日涨幅,跌幅小于每日跌幅。
上文中网格策略无法达到策略目标,稍作优化后,便有了下文的网络变种策略:
网格变种策略
*前提条件不变,策略做法如下:
- 每秒检测一次当前价格,记录今日最低价格。
- 每次最低价格刷新时,买入。
- 不进行卖出操作(即在收盘时卖出所有持仓)
策略核心代码如下:
for( let i=1; i<mergedData.length; ++i ){
let curPrice = mergedData[i]["close"];
curTotalPrice+= curPrice;
if( curPrice<lowPrice ){
lowPrice = curPrice;
lowTimes++;
if( lowTimes%grap==0 ){
if( lowTotalPrice+curPrice*buyCount > seedMoney ){
break;
}
lowTotalPrice += curPrice*buyCount;
lowHoldNumber += buyCount;
}
}
}
模拟收益
originalSituation:-25.90%, mySituation:-12.28%
originalSituation:-70.30%, mySituation:-50.51%
originalSituation:141.70%, mySituation:148.18%
originalSituation:-47.80%, mySituation:-25.02%
originalSituation:-78.50%, mySituation:-64.37%
originalSituation:100.90%, mySituation:132.75%
originalSituation:0.30%, mySituation:6.84%
originalSituation:-27.00%, mySituation:11.92%
originalSituation:-38.80%, mySituation:-19.82%
originalSituation:-35.90%, mySituation:2.35%
......
originAvg:6.68% , myAvg:35.23%
[Finished in 3.5s]
从模拟收益率来看,完全达成了我们的策略目标。然而抛开持仓只谈收益率的策略都是耍流氓。
如果我有10000本金,使用本策略在某日行情下只能投入100元,收益率10%,收益为10,但实际当天真正收益率只有0.01%。
网友评论