This commit is contained in:
Janne Sinivirta 2017-12-26 09:59:38 +02:00
parent ae0a1436e2
commit 7b0beb0afa
3 changed files with 10 additions and 18 deletions

View File

@ -4,11 +4,9 @@ import logging
import json
import os
from typing import Optional, List, Dict
from pandas import DataFrame
from freqtrade.exchange import get_ticker_history
from freqtrade.optimize.hyperopt_conf import hyperopt_optimize_conf
from pandas import DataFrame
from freqtrade.analyze import populate_indicators, parse_ticker_dataframe
logger = logging.getLogger(__name__)
@ -50,10 +48,8 @@ def load_data(ticker_interval: int = 5, pairs: Optional[List[str]] = None,
def preprocess(tickerdata: Dict[str, List]) -> Dict[str, DataFrame]:
"""Creates a dataframe and populates indicators for given ticker data"""
processed = {}
for pair, pair_data in tickerdata.items():
processed[pair] = populate_indicators(parse_ticker_dataframe(pair_data))
return processed
return {pair: populate_indicators(parse_ticker_dataframe(pair_data))
for pair, pair_data in tickerdata.items()}
def testdata_path() -> str:

View File

@ -111,14 +111,14 @@ def backtest(stake_amount: float, processed: Dict[str, DataFrame],
if min_roi_reached(trade, row2.close, row2.date) or row2.sell == 1:
current_profit_percent = trade.calc_profit_percent(rate=row2.close)
current_profit_BTC = trade.calc_profit(rate=row2.close)
current_profit_btc = trade.calc_profit(rate=row2.close)
lock_pair_until = row2.Index
trades.append(
(
pair,
current_profit_percent,
current_profit_BTC,
current_profit_btc,
row2.Index - row.Index
)
)

View File

@ -118,8 +118,7 @@ def optimizer(params):
backtesting.populate_buy_trend = buy_strategy_generator(params)
results = backtest(OPTIMIZE_CONFIG['stake_amount'], PROCESSED)
result = format_results(results)
result_explanation = format_results(results)
total_profit = results.profit_percent.sum()
trade_count = len(results.index)
@ -135,20 +134,17 @@ def optimizer(params):
loss = trade_loss + profit_loss
_CURRENT_TRIES += 1
result_data = {
log_results({
'loss': loss,
'current_tries': _CURRENT_TRIES,
'total_tries': TOTAL_TRIES,
'result': result,
}
log_results(result_data)
'result': result_explanation,
})
return {
'loss': loss,
'status': STATUS_OK,
'result': result,
'total_profit': total_profit,
'avg_profit': results.profit_percent.mean() * 100.0,
'result': result_explanation,
}