fix backtest download
This commit is contained in:
parent
aa4f139a36
commit
5c945bd10c
@ -3,6 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
from typing import Optional, List, Dict
|
from typing import Optional, List, Dict
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
from freqtrade.exchange import get_ticker_history
|
from freqtrade.exchange import get_ticker_history
|
||||||
@ -35,7 +36,7 @@ def load_tickerdata_file(datadir, pair, ticker_interval, timerange=None):
|
|||||||
path = make_testdata_path(datadir)
|
path = make_testdata_path(datadir)
|
||||||
file = '{abspath}/{pair}-{ticker_interval}.json'.format(
|
file = '{abspath}/{pair}-{ticker_interval}.json'.format(
|
||||||
abspath=path,
|
abspath=path,
|
||||||
pair=pair,
|
pair=pair.replace('/', '_'),
|
||||||
ticker_interval=ticker_interval,
|
ticker_interval=ticker_interval,
|
||||||
)
|
)
|
||||||
gzipfile = file + '.gz'
|
gzipfile = file + '.gz'
|
||||||
@ -135,7 +136,7 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
|
|||||||
interval=interval,
|
interval=interval,
|
||||||
))
|
))
|
||||||
|
|
||||||
filepair = pair.replace("-", "_")
|
filepair = pair.replace("/", "_")
|
||||||
filename = os.path.join(path, '{pair}-{interval}.json'.format(
|
filename = os.path.join(path, '{pair}-{interval}.json'.format(
|
||||||
pair=filepair,
|
pair=filepair,
|
||||||
interval=interval,
|
interval=interval,
|
||||||
@ -155,9 +156,11 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
|
|||||||
for row in new_data:
|
for row in new_data:
|
||||||
if row not in data:
|
if row not in data:
|
||||||
data.append(row)
|
data.append(row)
|
||||||
logger.debug("New Start: {}".format(data[1]['T']))
|
logger.debug("New Start: {}".format(
|
||||||
logger.debug("New End: {}".format(data[-1:][0]['T']))
|
datetime.fromtimestamp(data[0][0]/1000.0).strftime('%Y-%m-%dT%H:%M:%S')))
|
||||||
data = sorted(data, key=lambda data: data['T'])
|
logger.debug("New End: {}".format(
|
||||||
|
datetime.fromtimestamp(data[-1:][0][0]/1000.0).strftime('%Y-%m-%dT%H:%M:%S')))
|
||||||
|
data = sorted(data, key=lambda data: data[0])
|
||||||
|
|
||||||
misc.file_dump_json(filename, data)
|
misc.file_dump_json(filename, data)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user