stable/freqtrade/configuration/create_datadir.py

21 lines
575 B
Python
Raw Normal View History

2019-07-12 00:26:27 +00:00
import logging
from typing import Any, Dict, Optional
2019-07-17 18:53:29 +00:00
from pathlib import Path
2019-07-12 00:26:27 +00:00
logger = logging.getLogger(__name__)
def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> str:
2019-07-17 18:53:29 +00:00
folder = Path(datadir) if datadir else Path('user_data/data')
2019-07-12 00:26:27 +00:00
if not datadir:
# set datadir
exchange_name = config.get('exchange', {}).get('name').lower()
2019-07-17 18:53:29 +00:00
folder = folder.joinpath(exchange_name)
2019-07-12 00:26:27 +00:00
2019-07-17 18:53:29 +00:00
if not folder.is_dir():
folder.mkdir(parents=True)
2019-07-12 00:26:27 +00:00
logger.info(f'Created data directory: {datadir}')
2019-07-17 18:53:29 +00:00
return str(folder)