Type/to search
0
Follow
0
Followers
Verwendung von exchange.GetAccount() im Backtesting
Help
Created 2021-03-11 18:28:35  
 1
 1274

Ich benutze den folgenden Code für die Rückmeldung:
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 ((("die aktuelle Positionsmenge ist:", account["Stocks"], "der aktuelle Saldo ist:", 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)

Es wurde festgestellt, dass die Rückmessung stets die aktuelle Haltbarkeit ausgibt: 3.89e-07 Der aktuelle Saldo ist: 19999.166986677. Bitte fragen Sie, ob die Rückmessung exchange.GetAccount stets nur die in den Konfigurationsparametern festgelegten Informationen zurückgibt?

Related Recommendations
Comment
All comments (1)

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

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