Merge pull request #1960 from freqtrade/plot_df_stripping

Plot datafame simplification
This commit is contained in:
Matthias 2019-06-24 06:15:54 +02:00 committed by GitHub
commit 1add8ecd0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 46 deletions

View File

@ -53,8 +53,7 @@ class FreqtradeBot(object):
self.rpc: RPCManager = RPCManager(self) self.rpc: RPCManager = RPCManager(self)
exchange_name = self.config.get('exchange', {}).get('name').title() self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange
self.exchange = ExchangeResolver(exchange_name, self.config).exchange
self.wallets = Wallets(self.config, self.exchange) self.wallets = Wallets(self.config, self.exchange)
self.dataprovider = DataProvider(self.config, self.exchange) self.dataprovider = DataProvider(self.config, self.exchange)

View File

@ -63,8 +63,7 @@ class Backtesting(object):
self.config['dry_run'] = True self.config['dry_run'] = True
self.strategylist: List[IStrategy] = [] self.strategylist: List[IStrategy] = []
exchange_name = self.config.get('exchange', {}).get('name').title() self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange
self.exchange = ExchangeResolver(exchange_name, self.config).exchange
self.fee = self.exchange.get_fee() self.fee = self.exchange.get_fee()
if self.config.get('runmode') != RunMode.HYPEROPT: if self.config.get('runmode') != RunMode.HYPEROPT:

View File

@ -22,6 +22,7 @@ class ExchangeResolver(IResolver):
Load the custom class from config parameter Load the custom class from config parameter
:param config: configuration dictionary :param config: configuration dictionary
""" """
exchange_name = exchange_name.title()
try: try:
self.exchange = self._load_exchange(exchange_name, kwargs={'config': config}) self.exchange = self._load_exchange(exchange_name, kwargs={'config': config})
except ImportError: except ImportError:

View File

@ -60,7 +60,7 @@ def get_patched_exchange(mocker, config, api_mock=None, id='bittrex') -> Exchang
patch_exchange(mocker, api_mock, id) patch_exchange(mocker, api_mock, id)
config["exchange"]["name"] = id config["exchange"]["name"] = id
try: try:
exchange = ExchangeResolver(id.title(), config).exchange exchange = ExchangeResolver(id, config).exchange
except ImportError: except ImportError:
exchange = Exchange(config) exchange = Exchange(config)
return exchange return exchange

View File

@ -124,14 +124,14 @@ def test_exchange_resolver(default_conf, mocker, caplog):
caplog.record_tuples) caplog.record_tuples)
caplog.clear() caplog.clear()
exchange = ExchangeResolver('Kraken', default_conf).exchange exchange = ExchangeResolver('kraken', default_conf).exchange
assert isinstance(exchange, Exchange) assert isinstance(exchange, Exchange)
assert isinstance(exchange, Kraken) assert isinstance(exchange, Kraken)
assert not isinstance(exchange, Binance) assert not isinstance(exchange, Binance)
assert not log_has_re(r"No .* specific subclass found. Using the generic class instead.", assert not log_has_re(r"No .* specific subclass found. Using the generic class instead.",
caplog.record_tuples) caplog.record_tuples)
exchange = ExchangeResolver('Binance', default_conf).exchange exchange = ExchangeResolver('binance', default_conf).exchange
assert isinstance(exchange, Exchange) assert isinstance(exchange, Exchange)
assert isinstance(exchange, Binance) assert isinstance(exchange, Binance)
assert not isinstance(exchange, Kraken) assert not isinstance(exchange, Kraken)

View File

@ -31,7 +31,7 @@ from typing import Any, Dict, List
import pandas as pd import pandas as pd
from freqtrade.arguments import Arguments, TimeRange from freqtrade.arguments import Arguments
from freqtrade.data import history from freqtrade.data import history
from freqtrade.data.btanalysis import load_trades, extract_trades_of_period from freqtrade.data.btanalysis import load_trades, extract_trades_of_period
from freqtrade.optimize import setup_configuration from freqtrade.optimize import setup_configuration
@ -43,38 +43,6 @@ from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def get_tickers_data(strategy, exchange, pairs: List[str], timerange: TimeRange,
datadir: Path, refresh_pairs: bool, live: bool):
"""
Get tickers data for each pairs on live or local, option defined in args
:return: dictionary of tickers. output format: {'pair': tickersdata}
"""
ticker_interval = strategy.ticker_interval
tickers = history.load_data(
datadir=datadir,
pairs=pairs,
ticker_interval=ticker_interval,
refresh_pairs=refresh_pairs,
timerange=timerange,
exchange=exchange,
live=live,
)
# No ticker found, impossible to download, len mismatch
for pair, data in tickers.copy().items():
logger.debug("checking tickers data of pair: %s", pair)
logger.debug("data.empty: %s", data.empty)
logger.debug("len(data): %s", len(data))
if data.empty:
del tickers[pair]
logger.info(
'An issue occured while retreiving data of %s pair, please retry '
'using -l option for live or --refresh-pairs-cached', pair)
return tickers
def generate_dataframe(strategy, tickers, pair) -> pd.DataFrame: def generate_dataframe(strategy, tickers, pair) -> pd.DataFrame:
""" """
Get tickers then Populate strategy indicators and signals, then return the full dataframe Get tickers then Populate strategy indicators and signals, then return the full dataframe
@ -100,8 +68,7 @@ def analyse_and_plot_pairs(config: Dict[str, Any]):
-Generate plot files -Generate plot files
:return: None :return: None
""" """
exchange_name = config.get('exchange', {}).get('name').title() exchange = ExchangeResolver(config.get('exchange', {}).get('name'), config).exchange
exchange = ExchangeResolver(exchange_name, config).exchange
strategy = StrategyResolver(config).strategy strategy = StrategyResolver(config).strategy
if "pairs" in config: if "pairs" in config:
@ -113,10 +80,16 @@ def analyse_and_plot_pairs(config: Dict[str, Any]):
timerange = Arguments.parse_timerange(config["timerange"]) timerange = Arguments.parse_timerange(config["timerange"])
ticker_interval = strategy.ticker_interval ticker_interval = strategy.ticker_interval
tickers = get_tickers_data(strategy, exchange, pairs, timerange, tickers = history.load_data(
datadir=Path(str(config.get("datadir"))), datadir=Path(str(config.get("datadir"))),
pairs=pairs,
ticker_interval=config['ticker_interval'],
refresh_pairs=config.get('refresh_pairs', False), refresh_pairs=config.get('refresh_pairs', False),
live=config.get("live", False)) timerange=timerange,
exchange=exchange,
live=config.get("live", False),
)
pair_counter = 0 pair_counter = 0
for pair, data in tickers.items(): for pair, data in tickers.items():
pair_counter += 1 pair_counter += 1