我使用如下代码进行回测 def CalculateMA(n,record): sumMA = 0 for i in range(n): sumMA += record[-(i+1)][“Close”] return sumMA/n
def SimpleMAStrategy(status): account = exchange.GetAccount() ticker = exchange.GetTicker() record = exchange.GetRecords(RecordsTime) MAFast = CalculateMA(MAFastN,record) MASlow = CalculateMA(MASlowN,record) balance = account[“Balance”] stocks = account[“Stocks”] Log(“当前持仓量是:”, account[“Stocks”],“当前余额是:”, account[“Balance”]) currSell1Price = ticker[“Sell”] if (MAFast >= MASlow and status == 0): id = exchange.Buy(-1, balance*rate/ticker[“Sell”]) status = 1 if (MAFast <= MASlow and status == 1): id = exchange.Sell(-1, stocks) status = 0 return status
status = 0 while(true): status = SimpleMAStrategy(status) Sleep(3000)
发现回测中始终输出当前持仓量是: 3.89e-07 当前余额是: 19999.166986677. 请问回测中exchange.GetAccount是始终只会返回配置参数中设定的信息吗?
小草 回测需要把原来添加的删掉,重新添加才会生效