Type/to search
0
Follow
0
Followers
Uso de exchange.GetAccount() en pruebas retrospectivas
Help
Created 2021-03-11 18:28:35  
 1
 1274

El código que utilizo para hacer este retroceso es el siguiente:
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 (("La cantidad actual de la posición es:", account["Stocks"], "el saldo actual es:", cuenta["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)

Se encontró que la retrospectiva siempre emitió la cantidad de la posición actual: 3.89e-07 El saldo actual es: 19999.166986677. ¿Exchange.GetAccount siempre devuelve la información establecida en los parámetros de configuración?

Related Recommendations
Comment
All comments (1)

    回测需要把原来添加的删掉,重新添加才会生效

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