Merge commit '35c51c73f713bfdb81bd84721f3dceab0c19e819' into feature/objectify
This commit is contained in:
		| @@ -107,10 +107,28 @@ class Arguments(object): | ||||
|         """ | ||||
|         parser.add_argument( | ||||
|             '-l', '--live', | ||||
|             help='using live data', | ||||
|             action='store_true', | ||||
|             dest='live', | ||||
|             help='using live data', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '-r', '--refresh-pairs-cached', | ||||
|             help='refresh the pairs files in tests/testdata with the latest data from Bittrex. \ | ||||
|                   Use it if you want to run your backtesting with up-to-date data.', | ||||
|             action='store_true', | ||||
|             dest='refresh_pairs', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '--export', | ||||
|             help='export backtest results, argument are: trades\ | ||||
|                   Example --export=trades', | ||||
|             type=str, | ||||
|             default=None, | ||||
|             dest='export', | ||||
|         ) | ||||
|  | ||||
|     @staticmethod | ||||
|     def _optimizer_shared_options(parser: argparse.ArgumentParser) -> None: | ||||
|         parser.add_argument( | ||||
|             '-i', '--ticker-interval', | ||||
|             help='specify ticker interval in minutes (1, 5, 30, 60, 1440)', | ||||
| @@ -124,24 +142,9 @@ class Arguments(object): | ||||
|             action='store_true', | ||||
|             dest='realistic_simulation', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '-r', '--refresh-pairs-cached', | ||||
|             help='refresh the pairs files in tests/testdata with the latest data from Bittrex. \ | ||||
|                   Use it if you want to run your backtesting with up-to-date data.', | ||||
|             action='store_true', | ||||
|             dest='refresh_pairs', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '--export', | ||||
|             help='Export backtest results, argument are: trades\ | ||||
|                   Example --export=trades', | ||||
|             type=str, | ||||
|             default=None, | ||||
|             dest='export', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '--timerange', | ||||
|             help='Specify what timerange of data to use.', | ||||
|             help='specify what timerange of data to use.', | ||||
|             default=None, | ||||
|             type=str, | ||||
|             dest='timerange', | ||||
| @@ -166,20 +169,6 @@ class Arguments(object): | ||||
|             dest='mongodb', | ||||
|             action='store_true', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '-i', '--ticker-interval', | ||||
|             help='specify ticker interval in minutes (1, 5, 30, 60, 1440)', | ||||
|             dest='ticker_interval', | ||||
|             type=int, | ||||
|             metavar='INT', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '--timerange', | ||||
|             help='Specify what timerange of data to use.', | ||||
|             default=None, | ||||
|             type=str, | ||||
|             dest='timerange', | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             '-s', '--spaces', | ||||
|             help='Specify which parameters to hyperopt. Space separate list. \ | ||||
| @@ -202,11 +191,13 @@ class Arguments(object): | ||||
|         # Add backtesting subcommand | ||||
|         backtesting_cmd = subparsers.add_parser('backtesting', help='backtesting module') | ||||
|         backtesting_cmd.set_defaults(func=backtesting.start) | ||||
|         self._optimizer_shared_options(backtesting_cmd) | ||||
|         self._backtesting_options(backtesting_cmd) | ||||
|  | ||||
|         # Add hyperopt subcommand | ||||
|         hyperopt_cmd = subparsers.add_parser('hyperopt', help='hyperopt module') | ||||
|         hyperopt_cmd.set_defaults(func=hyperopt.start) | ||||
|         self._optimizer_shared_options(hyperopt_cmd) | ||||
|         self._hyperopt_options(hyperopt_cmd) | ||||
|  | ||||
|     @staticmethod | ||||
|   | ||||
| @@ -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') | ||||
|             } | ||||
|         ) | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user