Convert datadir within config to Path
(it's used as Path all the time!)
This commit is contained in:
parent
506907ddc9
commit
bb8acc61db
@ -403,7 +403,7 @@ class Configuration:
|
|||||||
config['pairs'] = config.get('exchange', {}).get('pair_whitelist')
|
config['pairs'] = config.get('exchange', {}).get('pair_whitelist')
|
||||||
else:
|
else:
|
||||||
# Fall back to /dl_path/pairs.json
|
# Fall back to /dl_path/pairs.json
|
||||||
pairs_file = Path(config['datadir']) / "pairs.json"
|
pairs_file = config['datadir'] / "pairs.json"
|
||||||
if pairs_file.exists():
|
if pairs_file.exists():
|
||||||
with pairs_file.open('r') as f:
|
with pairs_file.open('r') as f:
|
||||||
config['pairs'] = json_load(f)
|
config['pairs'] = json_load(f)
|
||||||
|
@ -9,7 +9,7 @@ from freqtrade.constants import USER_DATA_FILES
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> str:
|
def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> Path:
|
||||||
|
|
||||||
folder = Path(datadir) if datadir else Path(f"{config['user_data_dir']}/data")
|
folder = Path(datadir) if datadir else Path(f"{config['user_data_dir']}/data")
|
||||||
if not datadir:
|
if not datadir:
|
||||||
@ -20,7 +20,7 @@ def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> str
|
|||||||
if not folder.is_dir():
|
if not folder.is_dir():
|
||||||
folder.mkdir(parents=True)
|
folder.mkdir(parents=True)
|
||||||
logger.info(f'Created data directory: {datadir}')
|
logger.info(f'Created data directory: {datadir}')
|
||||||
return str(folder)
|
return folder
|
||||||
|
|
||||||
|
|
||||||
def create_userdata_dir(directory: str, create_dir=False) -> Path:
|
def create_userdata_dir(directory: str, create_dir=False) -> Path:
|
||||||
|
@ -5,7 +5,6 @@ including Klines, tickers, historic data
|
|||||||
Common Interface for bot and strategy to access data.
|
Common Interface for bot and strategy to access data.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
@ -65,7 +64,7 @@ class DataProvider:
|
|||||||
"""
|
"""
|
||||||
return load_pair_history(pair=pair,
|
return load_pair_history(pair=pair,
|
||||||
timeframe=timeframe or self._config['ticker_interval'],
|
timeframe=timeframe or self._config['ticker_interval'],
|
||||||
datadir=Path(self._config['datadir'])
|
datadir=self._config['datadir']
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_pair_dataframe(self, pair: str, timeframe: str = None) -> DataFrame:
|
def get_pair_dataframe(self, pair: str, timeframe: str = None) -> DataFrame:
|
||||||
|
@ -191,9 +191,8 @@ def start_download_data(args: Dict[str, Any]) -> None:
|
|||||||
"Downloading data requires a list of pairs. "
|
"Downloading data requires a list of pairs. "
|
||||||
"Please check the documentation on how to configure this.")
|
"Please check the documentation on how to configure this.")
|
||||||
|
|
||||||
dl_path = Path(config['datadir'])
|
|
||||||
logger.info(f'About to download pairs: {config["pairs"]}, '
|
logger.info(f'About to download pairs: {config["pairs"]}, '
|
||||||
f'intervals: {config["timeframes"]} to {dl_path}')
|
f'intervals: {config["timeframes"]} to {config["datadir"]}')
|
||||||
|
|
||||||
pairs_not_available: List[str] = []
|
pairs_not_available: List[str] = []
|
||||||
|
|
||||||
@ -203,17 +202,17 @@ def start_download_data(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
if config.get('download_trades'):
|
if config.get('download_trades'):
|
||||||
pairs_not_available = refresh_backtest_trades_data(
|
pairs_not_available = refresh_backtest_trades_data(
|
||||||
exchange, pairs=config["pairs"], datadir=Path(config['datadir']),
|
exchange, pairs=config["pairs"], datadir=config['datadir'],
|
||||||
timerange=timerange, erase=config.get("erase"))
|
timerange=timerange, erase=config.get("erase"))
|
||||||
|
|
||||||
# Convert downloaded trade data to different timeframes
|
# Convert downloaded trade data to different timeframes
|
||||||
convert_trades_to_ohlcv(
|
convert_trades_to_ohlcv(
|
||||||
pairs=config["pairs"], timeframes=config["timeframes"],
|
pairs=config["pairs"], timeframes=config["timeframes"],
|
||||||
datadir=Path(config['datadir']), timerange=timerange, erase=config.get("erase"))
|
datadir=config['datadir'], timerange=timerange, erase=config.get("erase"))
|
||||||
else:
|
else:
|
||||||
pairs_not_available = refresh_backtest_ohlcv_data(
|
pairs_not_available = refresh_backtest_ohlcv_data(
|
||||||
exchange, pairs=config["pairs"], timeframes=config["timeframes"],
|
exchange, pairs=config["pairs"], timeframes=config["timeframes"],
|
||||||
datadir=Path(config['datadir']), timerange=timerange, erase=config.get("erase"))
|
datadir=config['datadir'], timerange=timerange, erase=config.get("erase"))
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit("SIGINT received, aborting ...")
|
sys.exit("SIGINT received, aborting ...")
|
||||||
|
@ -977,7 +977,7 @@ def test_pairlist_resolving_fallback(mocker):
|
|||||||
|
|
||||||
assert config['pairs'] == ['ETH/BTC', 'XRP/BTC']
|
assert config['pairs'] == ['ETH/BTC', 'XRP/BTC']
|
||||||
assert config['exchange']['name'] == 'binance'
|
assert config['exchange']['name'] == 'binance'
|
||||||
assert config['datadir'] == str(Path.cwd() / "user_data/data/binance")
|
assert config['datadir'] == Path.cwd() / "user_data/data/binance"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("setting", [
|
@pytest.mark.parametrize("setting", [
|
||||||
|
Loading…
Reference in New Issue
Block a user