support download for multiple testdata sets
This commit is contained in:
parent
80e7f37f50
commit
3277e491f1
@ -51,6 +51,21 @@ python3 ./freqtrade/main.py backtesting --realistic-simulation --live
|
|||||||
python3 ./freqtrade/main.py backtesting --datadir freqtrade/tests/testdata-20180101
|
python3 ./freqtrade/main.py backtesting --datadir freqtrade/tests/testdata-20180101
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To update your testdata directory, or download into another testdata directory:
|
||||||
|
```bash
|
||||||
|
mkdir freqtrade/tests/testdata-20180113
|
||||||
|
cp freqtrade/tests/testdata/pairs.json freqtrade/tests/testdata-20180113
|
||||||
|
cd freqtrade/tests/testdata-20180113
|
||||||
|
|
||||||
|
Possibly edit pairs.json file to include/exclude pairs
|
||||||
|
|
||||||
|
python download_backtest_data.py -p pairs.json
|
||||||
|
```
|
||||||
|
|
||||||
|
The script will read your pairs.json file, and download ticker data
|
||||||
|
into the current working directory.
|
||||||
|
|
||||||
|
|
||||||
For help about backtesting usage, please refer to
|
For help about backtesting usage, please refer to
|
||||||
[Backtesting commands](#backtesting-commands).
|
[Backtesting commands](#backtesting-commands).
|
||||||
|
|
||||||
|
@ -15,6 +15,11 @@ from freqtrade import __version__
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def file_dump_json(filename, data):
|
||||||
|
with open(filename, 'w') as fp:
|
||||||
|
json.dump(data, fp)
|
||||||
|
|
||||||
|
|
||||||
class State(enum.Enum):
|
class State(enum.Enum):
|
||||||
RUNNING = 0
|
RUNNING = 0
|
||||||
STOPPED = 1
|
STOPPED = 1
|
||||||
|
@ -1,29 +1,38 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""This script generate json data from bittrex"""
|
"""This script generate json data from bittrex"""
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
from os import path
|
|
||||||
|
|
||||||
from freqtrade import exchange
|
from freqtrade import exchange
|
||||||
from freqtrade.exchange import Bittrex
|
from freqtrade.exchange import Bittrex
|
||||||
|
from freqtrade import misc
|
||||||
|
|
||||||
PAIRS = [
|
parser = misc.common_args_parser('download utility')
|
||||||
'BTC_BCC', 'BTC_ETH', 'BTC_MER', 'BTC_POWR', 'BTC_ETC',
|
parser.add_argument(
|
||||||
'BTC_OK', 'BTC_NEO', 'BTC_EMC2', 'BTC_DASH', 'BTC_LSK',
|
'-p', '--pair',
|
||||||
'BTC_LTC', 'BTC_XZC', 'BTC_OMG', 'BTC_STRAT', 'BTC_XRP',
|
help='JSON file containing pairs to download',
|
||||||
'BTC_QTUM', 'BTC_WAVES', 'BTC_VTC', 'BTC_XLM', 'BTC_MCO'
|
dest='pair',
|
||||||
]
|
default=None
|
||||||
TICKER_INTERVAL = 5 # ticker interval in minutes (currently implemented: 1 and 5)
|
)
|
||||||
OUTPUT_DIR = path.dirname(path.realpath(__file__))
|
args = parser.parse_args(sys.argv[1:])
|
||||||
|
|
||||||
|
TICKER_INTERVALS = [1, 5] # ticker interval in minutes (currently implemented: 1 and 5)
|
||||||
|
PAIRS = []
|
||||||
|
|
||||||
|
if args.pair:
|
||||||
|
with open(args.pair) as file:
|
||||||
|
PAIRS = json.load(file)
|
||||||
|
PAIRS = list(set(PAIRS))
|
||||||
|
|
||||||
|
print('About to download pairs:', PAIRS)
|
||||||
|
|
||||||
# Init Bittrex exchange
|
# Init Bittrex exchange
|
||||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||||
|
|
||||||
for pair in PAIRS:
|
for pair in PAIRS:
|
||||||
data = exchange.get_ticker_history(pair, TICKER_INTERVAL)
|
for tick_interval in TICKER_INTERVALS:
|
||||||
filename = path.join(OUTPUT_DIR, '{}-{}.json'.format(
|
print('downloading pair %s, interval %s' % (pair, tick_interval))
|
||||||
pair,
|
data = exchange.get_ticker_history(pair, tick_interval)
|
||||||
TICKER_INTERVAL,
|
filename = '{}-{}.json'.format(pair, tick_interval)
|
||||||
))
|
misc.file_dump_json(filename, data)
|
||||||
with open(filename, 'w') as fp:
|
|
||||||
json.dump(data, fp)
|
|
||||||
|
23
freqtrade/tests/testdata/pairs.json
vendored
Normal file
23
freqtrade/tests/testdata/pairs.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[
|
||||||
|
"BTC_ADA",
|
||||||
|
"BTC_BAT",
|
||||||
|
"BTC_DASH",
|
||||||
|
"BTC_ETC",
|
||||||
|
"BTC_ETH",
|
||||||
|
"BTC_GBYTE",
|
||||||
|
"BTC_LSK",
|
||||||
|
"BTC_LTC",
|
||||||
|
"BTC_NEO",
|
||||||
|
"BTC_NXT",
|
||||||
|
"BTC_POWR",
|
||||||
|
"BTC_STORJ",
|
||||||
|
"BTC_QTUM",
|
||||||
|
"BTC_WAVES",
|
||||||
|
"BTC_VTC",
|
||||||
|
"BTC_XLM",
|
||||||
|
"BTC_XMR",
|
||||||
|
"BTC_XVG",
|
||||||
|
"BTC_XRP",
|
||||||
|
"BTC_ZEC"
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user