このコードを使って反省しました
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は常に配置パラメータで設定された情報のみを返しているのですか?
- 1
