add --ticker-interval
This commit is contained in:
parent
0df1404d6a
commit
9b644b0305
@ -108,6 +108,14 @@ def build_subcommands(parser: argparse.ArgumentParser) -> None:
|
|||||||
dest='live',
|
dest='live',
|
||||||
help='using live data',
|
help='using live data',
|
||||||
)
|
)
|
||||||
|
backtest.add_argument(
|
||||||
|
'-i', '--ticker-interval',
|
||||||
|
help='specify ticker interval in minutes (default: 5)',
|
||||||
|
dest='ticker_interval',
|
||||||
|
default=5,
|
||||||
|
type=int,
|
||||||
|
metavar='INT',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def start_backtesting(args) -> None:
|
def start_backtesting(args) -> None:
|
||||||
@ -122,6 +130,7 @@ def start_backtesting(args) -> None:
|
|||||||
'BACKTEST': 'true',
|
'BACKTEST': 'true',
|
||||||
'BACKTEST_LIVE': 'true' if args.live else '',
|
'BACKTEST_LIVE': 'true' if args.live else '',
|
||||||
'BACKTEST_CONFIG': args.config,
|
'BACKTEST_CONFIG': args.config,
|
||||||
|
'BACKTEST_TICKER_INTERVAL': str(args.ticker_interval),
|
||||||
})
|
})
|
||||||
path = os.path.join(os.path.dirname(__file__), 'tests', 'test_backtesting.py')
|
path = os.path.join(os.path.dirname(__file__), 'tests', 'test_backtesting.py')
|
||||||
pytest.main(['-s', path])
|
pytest.main(['-s', path])
|
||||||
|
@ -91,12 +91,15 @@ def test_backtest(backtest_conf, backdata, mocker):
|
|||||||
with open(conf_path, 'r') as fp:
|
with open(conf_path, 'r') as fp:
|
||||||
config = json.load(fp)
|
config = json.load(fp)
|
||||||
|
|
||||||
|
ticker_interval = int(os.environ.get('BACKTEST_TICKER_INTERVAL') or 5)
|
||||||
|
print('Using ticker_interval: {}'.format(ticker_interval))
|
||||||
|
|
||||||
livedata = {}
|
livedata = {}
|
||||||
if os.environ.get('BACKTEST_LIVE'):
|
if os.environ.get('BACKTEST_LIVE'):
|
||||||
print('Downloading data for all pairs in whitelist ...'.format(conf_path))
|
print('Downloading data for all pairs in whitelist ...'.format(conf_path))
|
||||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||||
for pair in config['exchange']['pair_whitelist']:
|
for pair in config['exchange']['pair_whitelist']:
|
||||||
livedata[pair] = exchange.get_ticker_history(pair)
|
livedata[pair] = exchange.get_ticker_history(pair, ticker_interval)
|
||||||
|
|
||||||
config = config or backtest_conf
|
config = config or backtest_conf
|
||||||
data = livedata or backdata
|
data = livedata or backdata
|
||||||
|
Loading…
Reference in New Issue
Block a user