fixed error checking
This commit is contained in:
parent
a82b87fcae
commit
021791e2c8
@ -128,9 +128,9 @@ def load_pair_history(pair: str,
|
|||||||
drop_incomplete=drop_incomplete)
|
drop_incomplete=drop_incomplete)
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f'No history data for pair: "{pair}", interval: {ticker_interval}. '
|
f'No history data for pair: "{pair}", interval: {ticker_interval}, in {datadir}. '
|
||||||
'Use --refresh-pairs-cached option or `freqtrade download-data` '
|
'Provide the correct path to datadir in config.json, or download data with '
|
||||||
'script to download the data'
|
'--refresh-pairs-cached option or `freqtrade download-data`. '
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ Various tool function for Freqtrade and scripts
|
|||||||
"""
|
"""
|
||||||
import gzip
|
import gzip
|
||||||
import logging
|
import logging
|
||||||
from os import chdir
|
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -115,23 +114,3 @@ def deep_merge_dicts(source, destination):
|
|||||||
destination[key] = value
|
destination[key] = value
|
||||||
|
|
||||||
return destination
|
return destination
|
||||||
|
|
||||||
|
|
||||||
def find_project_root(path=None):
|
|
||||||
"""Locates root directory of the project.
|
|
||||||
Root is defined by existence of "LICENSE" and the dir 'freqtrade'.
|
|
||||||
:param path: pathlib.Path object, or string pointing to project root directory.
|
|
||||||
:return: path to project root directory
|
|
||||||
"""
|
|
||||||
if path is None:
|
|
||||||
path = Path(__file__).parent
|
|
||||||
i = 0
|
|
||||||
try:
|
|
||||||
chdir(path)
|
|
||||||
assert Path('LICENSE').is_file() and Path('freqtrade').exists()
|
|
||||||
except AssertionError:
|
|
||||||
while i < 5 and not (Path(path, 'LICENSE').is_file() and Path(path, 'freqtrade').exists()):
|
|
||||||
path = Path(path).parent
|
|
||||||
i += 1
|
|
||||||
logger.info(f'project_root is {path}')
|
|
||||||
return path
|
|
||||||
|
@ -3,7 +3,7 @@ from pathlib import Path
|
|||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from freqtrade import OperationalException
|
||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
from freqtrade.data import history
|
from freqtrade.data import history
|
||||||
from freqtrade.data.btanalysis import (combine_tickers_with_mean,
|
from freqtrade.data.btanalysis import (combine_tickers_with_mean,
|
||||||
@ -33,24 +33,29 @@ def init_plotscript(config):
|
|||||||
pairs = config["pairs"]
|
pairs = config["pairs"]
|
||||||
else:
|
else:
|
||||||
pairs = config["exchange"]["pair_whitelist"]
|
pairs = config["exchange"]["pair_whitelist"]
|
||||||
assert pairs is not None, ('No pairs available in config.')
|
if pairs is None:
|
||||||
|
raise OperationalException('No pairs available in config.')
|
||||||
|
|
||||||
# Set timerange to use
|
# Set timerange to use
|
||||||
timerange = TimeRange.parse_timerange(config.get("timerange"))
|
timerange = TimeRange.parse_timerange(config.get("timerange"))
|
||||||
|
if timerange is None:
|
||||||
|
raise OperationalException('Could not parse timerange in config.')
|
||||||
|
|
||||||
tickers = history.load_data(
|
tickers = history.load_data(
|
||||||
datadir=Path(config.get("datadir"), config.get("exchange").get("name")),
|
datadir=Path(str(config.get("datadir"))),
|
||||||
pairs=pairs,
|
pairs=pairs,
|
||||||
ticker_interval=config.get('ticker_interval', '5m'),
|
ticker_interval=config.get('ticker_interval', '5m'),
|
||||||
timerange=timerange,
|
timerange=timerange,
|
||||||
)
|
)
|
||||||
assert tickers is not None, ('No ticker data available as specified in config.')
|
if tickers is None:
|
||||||
|
raise OperationalException('No ticker data available as specified in config.')
|
||||||
|
|
||||||
trades = load_trades(config['trade_source'],
|
trades = load_trades(config['trade_source'],
|
||||||
db_url=config.get('db_url'),
|
db_url=config.get('db_url'),
|
||||||
exportfilename=config.get('exportfilename'),
|
exportfilename=config.get('exportfilename'),
|
||||||
)
|
)
|
||||||
assert trades is not None, ('No trades available as specified in config.')
|
if trades is None:
|
||||||
|
raise OperationalException('No trades available as specified in config.')
|
||||||
|
|
||||||
return {"tickers": tickers,
|
return {"tickers": tickers,
|
||||||
"trades": trades,
|
"trades": trades,
|
||||||
@ -342,9 +347,9 @@ def load_and_plot_trades(config: Dict[str, Any]):
|
|||||||
|
|
||||||
plot_elements = init_plotscript(config)
|
plot_elements = init_plotscript(config)
|
||||||
trades = plot_elements['trades']
|
trades = plot_elements['trades']
|
||||||
if trades is None:
|
# if trades is None:
|
||||||
raise ValueError('No trades to analyze')
|
# # raise ValueError('No trades to analyze')
|
||||||
else:
|
# else:
|
||||||
pair_counter = 0
|
pair_counter = 0
|
||||||
for pair, data in plot_elements["tickers"].items():
|
for pair, data in plot_elements["tickers"].items():
|
||||||
pair_counter += 1
|
pair_counter += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user