def test_parse_args_config(): args = parse_args(['-c', '/dev/null']) assert args is not None assert args.config == '/dev/null' args = parse_args(['--config', '/dev/null']) assert args is not None assert args.config == '/dev/null'
def test_parse_args_hyperopt_custom(mocker): args = ['-c', 'test_conf.json', 'hyperopt', '--epochs', '20'] call_args = parse_args(args, '') assert call_args.config == 'test_conf.json' assert call_args.epochs == 20 assert call_args.loglevel == 20 assert call_args.subparser == 'hyperopt' assert call_args.func is not None
def test_parse_args_hyperopt_custom(mocker): args = ['-c', 'test_conf.json', 'hyperopt', '--epochs', '20'] call_args = parse_args(args, '') assert call_args.config == 'test_conf.json' assert call_args.epochs == 20 assert call_args.loglevel == 20 assert call_args.subparser == 'hyperopt' assert call_args.func is not None
def test_parse_args_backtesting_custom(): args = [ '-c', 'test_conf.json', 'backtesting', '--live', '--ticker-interval', '1', '--refresh-pairs-cached' ] call_args = parse_args(args, '') assert call_args.config == 'test_conf.json' assert call_args.live is True assert call_args.loglevel == 20 assert call_args.subparser == 'backtesting' assert call_args.func is not None assert call_args.ticker_interval == 1 assert call_args.refresh_pairs is True
def test_parse_args_backtesting(mocker): backtesting_mock = mocker.patch('freqtrade.misc.start_backtesting', MagicMock()) args = parse_args(['backtesting']) assert args is None assert backtesting_mock.call_count == 1 call_args = backtesting_mock.call_args[0][0] assert call_args.config == 'config.json' assert call_args.live is False assert call_args.loglevel == 20 assert call_args.subparser == 'backtesting' assert call_args.func is not None assert call_args.ticker_interval == 5
def test_parse_args_backtesting_custom(): args = [ '-c', 'test_conf.json', 'backtesting', '--live', '--ticker-interval', '1', '--refresh-pairs-cached'] call_args = parse_args(args, '') assert call_args.config == 'test_conf.json' assert call_args.live is True assert call_args.loglevel == 20 assert call_args.subparser == 'backtesting' assert call_args.func is not None assert call_args.ticker_interval == 1 assert call_args.refresh_pairs is True
def test_parse_args_backtesting_custom(mocker): backtesting_mock = mocker.patch('freqtrade.misc.start_backtesting', MagicMock()) args = parse_args([ '-c', 'test_conf.json', 'backtesting', '--live', '--ticker-interval', '1' ]) assert args is None assert backtesting_mock.call_count == 1 call_args = backtesting_mock.call_args[0][0] assert call_args.config == 'test_conf.json' assert call_args.live is True assert call_args.loglevel == 20 assert call_args.subparser == 'backtesting' assert call_args.func is not None assert call_args.ticker_interval == 1
def main(): """ Loads and validates the config and handles the main loop :return: None """ global _CONF args = parse_args(sys.argv[1:]) if not args: exit(0) # Initialize logger logging.basicConfig( level=args.loglevel, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', ) logger.info('Starting freqtrade %s (loglevel=%s)', __version__, logging.getLevelName(args.loglevel)) # Load and validate configuration _CONF = load_config(args.config) # Initialize all modules and start main loop if args.dynamic_whitelist: logger.info( 'Using dynamically generated whitelist. (--dynamic-whitelist detected)' ) init(_CONF) old_state = None while True: new_state = get_state() # Log state transition if new_state != old_state: rpc.send_msg('*Status:* `{}`'.format(new_state.name.lower())) logger.info('Changing state to: %s', new_state.name) if new_state == State.STOPPED: time.sleep(1) elif new_state == State.RUNNING: throttle( _process, min_secs=_CONF['internals'].get('process_throttle_secs', 10), dynamic_whitelist=args.dynamic_whitelist, ) old_state = new_state
def test_parse_args_dynamic_whitelist_invalid_values(): with pytest.raises(SystemExit, match=r'2'): parse_args(['--dynamic-whitelist', 'abc'], '')
def test_parse_args_dynamic_whitelist_10(): args = parse_args(['--dynamic-whitelist', '10'], '') assert args.dynamic_whitelist == 10
def main(sysargv=sys.argv[1:]) -> None: """ Loads and validates the config and handles the main loop :return: None """ global _CONF args = parse_args(sysargv, 'Simple High Frequency Trading Bot for crypto currencies') # A subcommand has been issued if hasattr(args, 'func'): args.func(args) exit(0) # Initialize logger logging.basicConfig( level=args.loglevel, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', ) logger.info( 'Starting freqtrade %s (loglevel=%s)', __version__, logging.getLevelName(args.loglevel) ) # Load and validate configuration _CONF = load_config(args.config) # Initialize all modules and start main loop if args.dynamic_whitelist: logger.info('Using dynamically generated whitelist. (--dynamic-whitelist detected)') # If the user ask for Dry run with a local DB instead of memory if args.dry_run_db: if _CONF.get('dry_run', False): _CONF.update({'dry_run_db': True}) logger.info( 'Dry_run will use the DB file: "tradesv3.dry_run.sqlite". (--dry_run_db detected)' ) else: logger.info('Dry run is disabled. (--dry_run_db ignored)') try: init(_CONF) old_state = None while True: new_state = get_state() # Log state transition if new_state != old_state: rpc.send_msg('*Status:* `{}`'.format(new_state.name.lower())) logger.info('Changing state to: %s', new_state.name) if new_state == State.STOPPED: time.sleep(1) elif new_state == State.RUNNING: throttle( _process, min_secs=_CONF['internals'].get('process_throttle_secs', 10), nb_assets=args.dynamic_whitelist, ) old_state = new_state except KeyboardInterrupt: logger.info('Got SIGINT, aborting ...') except BaseException: logger.exception('Got fatal exception!') finally: cleanup()
def test_parse_args_dynamic_whitelist_invalid_values(): with pytest.raises(SystemExit, match=r'2'): parse_args(['--dynamic-whitelist', 'abc'], '')
def test_parse_args_invalid(): with pytest.raises(SystemExit, match=r'2'): parse_args(['-c'], '')
def test_parse_args_verbose(): args = parse_args(['-v'], '') assert args.loglevel == 10 args = parse_args(['--verbose'], '') assert args.loglevel == 10
def test_parse_args_defaults(): args = parse_args([], '') assert args.config == 'config.json' assert args.dynamic_whitelist is None assert args.loglevel == 20
def test_parse_args_backtesting_invalid(): with pytest.raises(SystemExit, match=r'2'): parse_args(['backtesting --ticker-interval'], '') with pytest.raises(SystemExit, match=r'2'): parse_args(['backtesting --ticker-interval', 'abc'], '')
def test_parse_args_dynamic_whitelist(): args = parse_args(['--dynamic-whitelist']) assert args is not None assert args.dynamic_whitelist is True
def test_parse_args_verbose(): args = parse_args(['-v']) assert args is not None assert args.loglevel == 10
def test_parse_args_defaults(): args = parse_args([], '') assert args.config == 'config.json' assert args.dynamic_whitelist is None assert args.loglevel == 20
def test_parse_args_config(): args = parse_args(['-c', '/dev/null'], '') assert args.config == '/dev/null' args = parse_args(['--config', '/dev/null'], '') assert args.config == '/dev/null'
def test_parse_args_config(): args = parse_args(['-c', '/dev/null'], '') assert args.config == '/dev/null' args = parse_args(['--config', '/dev/null'], '') assert args.config == '/dev/null'
def test_parse_args_verbose(): args = parse_args(['-v'], '') assert args.loglevel == 10 args = parse_args(['--verbose'], '') assert args.loglevel == 10
def test_parse_args_version(): with pytest.raises(SystemExit, match=r'0'): parse_args(['--version'], '')
def test_parse_args_version(): with pytest.raises(SystemExit, match=r'0'): parse_args(['--version'], '')
def test_parse_args_dynamic_whitelist_10(): args = parse_args(['--dynamic-whitelist', '10'], '') assert args.dynamic_whitelist == 10
def test_parse_args_invalid(): with pytest.raises(SystemExit, match=r'2'): parse_args(['-c'], '')
def test_parse_args_backtesting_invalid(): with pytest.raises(SystemExit, match=r'2'): parse_args(['backtesting --ticker-interval'], '') with pytest.raises(SystemExit, match=r'2'): parse_args(['backtesting --ticker-interval', 'abc'], '')
def main(sysargv=sys.argv[1:]) -> None: """ Loads and validates the config and handles the main loop :return: None """ global _CONF args = parse_args( sysargv, 'Simple High Frequency Trading Bot for crypto currencies') # A subcommand has been issued if hasattr(args, 'func'): args.func(args) exit(0) # Initialize logger logging.basicConfig( level=args.loglevel, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', ) logger.info('Starting freqtrade %s (loglevel=%s)', __version__, logging.getLevelName(args.loglevel)) # Load and validate configuration _CONF = load_config(args.config) # Initialize all modules and start main loop if args.dynamic_whitelist: logger.info( 'Using dynamically generated whitelist. (--dynamic-whitelist detected)' ) # If the user ask for Dry run with a local DB instead of memory if args.dry_run_db: if _CONF.get('dry_run', False): _CONF.update({'dry_run_db': True}) logger.info( 'Dry_run will use the DB file: "tradesv3.dry_run.sqlite". (--dry_run_db detected)' ) else: logger.info('Dry run is disabled. (--dry_run_db ignored)') try: init(_CONF) old_state = None while True: new_state = get_state() # Log state transition if new_state != old_state: rpc.send_msg('*Status:* `{}`'.format(new_state.name.lower())) logger.info('Changing state to: %s', new_state.name) if new_state == State.STOPPED: time.sleep(1) elif new_state == State.RUNNING: throttle( _process, min_secs=_CONF['internals'].get('process_throttle_secs', 10), nb_assets=args.dynamic_whitelist, ) old_state = new_state except KeyboardInterrupt: logger.info('Got SIGINT, aborting ...') except BaseException: logger.exception('Got fatal exception!') finally: cleanup()