Merge commit '35c51c73f713bfdb81bd84721f3dceab0c19e819' into feature/objectify

This commit is contained in:
Gerald Lonlas
2018-03-04 01:33:39 -08:00
3 changed files with 30 additions and 43 deletions

View File

@@ -147,13 +147,12 @@ class Backtesting(object):
realistic: do we try to simulate realistic trades? (default: True)
sell_profit_only: sell if profit only
use_sell_signal: act on sell-signal
stoploss: use stoploss
:return: DataFrame
"""
headers = ['date', 'buy', 'open', 'close', 'sell']
processed = args['processed']
max_open_trades = args.get('max_open_trades', 0)
realistic = args.get('realistic', True)
realistic = args.get('realistic', False)
record = args.get('record', None)
records = []
trades = []
@@ -251,7 +250,6 @@ class Backtesting(object):
'realistic': self.config.get('realistic_simulation', False),
'sell_profit_only': sell_profit_only,
'use_sell_signal': use_sell_signal,
'stoploss': self.analyze.strategy.stoploss,
'record': self.config.get('export')
}
)

View File

@@ -433,23 +433,21 @@ class Hyperopt(Backtesting):
return populate_buy_trend
def optimizer(self, params) -> Dict:
if 'roi_t1' in params:
def generate_optimizer(self, params) -> Dict:
if self.has_space('roi'):
self.analyze.strategy.minimal_roi = self.generate_roi_table(params)
if 'trigger' in params:
if self.has_space('buy'):
self.populate_buy_trend = self.buy_strategy_generator(params)
if 'stoploss' in params:
stoploss = params['stoploss']
else:
stoploss = self.analyze.strategy.stoploss
if self.has_space('stoploss'):
self.analyze.strategy.stoploss = params['stoploss']
results = self.backtest(
{
'stake_amount': self.config['stake_amount'],
'processed': self.processed,
'stoploss': stoploss
'realistic': params['realistic_simulation'],
}
)
result_explanation = self.format_results(results)
@@ -542,7 +540,7 @@ class Hyperopt(Backtesting):
self.logging.set_format('\n%(message)s')
best_parameters = fmin(
fn=self.optimizer,
fn=self.generate_optimizer,
space=self.hyperopt_space(),
algo=tpe.suggest,
max_evals=self.total_tries,