do date parsing while loading json, not later

This commit is contained in:
Janne Sinivirta
2017-10-29 10:16:53 +02:00
parent da9c3e7d7d
commit 54987fd9ca
2 changed files with 6 additions and 5 deletions

View File

@@ -56,12 +56,12 @@ def backtest(conf, pairs, mocker):
for index, row in ticker[ticker.buy == 1].iterrows():
trade = Trade(
open_rate=row['close'],
open_date=arrow.get(row['date']).datetime,
open_date=row['date'],
amount=1,
)
# calculate win/lose forwards from buy point
for index2, row2 in ticker[index:].iterrows():
if should_sell(trade, row2['close'], arrow.get(row2['date']).datetime):
if should_sell(trade, row2['close'], row2['date']):
current_profit = (row2['close'] - trade.open_rate) / trade.open_rate
trades.append((pair, current_profit, index2 - index))