Introduce datatype for informative pairs

This commit is contained in:
hroff-1902 2020-05-16 11:09:50 +03:00
parent 72165a1926
commit bf25746965
3 changed files with 9 additions and 5 deletions

View File

@ -9,11 +9,13 @@ from typing import Any, Dict, List, Optional, Tuple
from pandas import DataFrame from pandas import DataFrame
from freqtrade.data.common import ListPairsWithTimeframes
from freqtrade.data.history import load_pair_history from freqtrade.data.history import load_pair_history
from freqtrade.exceptions import DependencyException, OperationalException from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.state import RunMode from freqtrade.state import RunMode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -25,8 +27,8 @@ class DataProvider:
self._pairlists = pairlists self._pairlists = pairlists
def refresh(self, def refresh(self,
pairlist: List[Tuple[str, str]], pairlist: ListPairsWithTimeframes,
helping_pairs: List[Tuple[str, str]] = None) -> None: helping_pairs: ListPairsWithTimeframes = None) -> None:
""" """
Refresh data, called with each cycle Refresh data, called with each cycle
""" """
@ -36,7 +38,7 @@ class DataProvider:
self._exchange.refresh_latest_ohlcv(pairlist) self._exchange.refresh_latest_ohlcv(pairlist)
@property @property
def available_pairs(self) -> List[Tuple[str, str]]: def available_pairs(self) -> ListPairsWithTimeframes:
""" """
Return a list of tuples containing (pair, timeframe) for which data is currently cached. Return a list of tuples containing (pair, timeframe) for which data is currently cached.
Should be whitelist + open trades. Should be whitelist + open trades.

View File

@ -18,6 +18,7 @@ from ccxt.base.decimal_to_precision import (ROUND_DOWN, ROUND_UP, TICK_SIZE,
TRUNCATE, decimal_to_precision) TRUNCATE, decimal_to_precision)
from pandas import DataFrame from pandas import DataFrame
from freqtrade.data.common import ListPairsWithTimeframes
from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list
from freqtrade.exceptions import (DependencyException, InvalidOrderException, from freqtrade.exceptions import (DependencyException, InvalidOrderException,
OperationalException, TemporaryError) OperationalException, TemporaryError)
@ -676,7 +677,7 @@ class Exchange:
logger.info("Downloaded data for %s with length %s.", pair, len(data)) logger.info("Downloaded data for %s with length %s.", pair, len(data))
return data return data
def refresh_latest_ohlcv(self, pair_list: List[Tuple[str, str]]) -> List[Tuple[str, List]]: def refresh_latest_ohlcv(self, pair_list: ListPairsWithTimeframes) -> List[Tuple[str, List]]:
""" """
Refresh in-memory OHLCV asynchronously and set `_klines` with the result Refresh in-memory OHLCV asynchronously and set `_klines` with the result
Loops asynchronously over pair_list and downloads all pairs async (semi-parallel). Loops asynchronously over pair_list and downloads all pairs async (semi-parallel).

View File

@ -12,6 +12,7 @@ from typing import Dict, List, NamedTuple, Optional, Tuple
import arrow import arrow
from pandas import DataFrame from pandas import DataFrame
from freqtrade.data.common import ListPairsWithTimeframes
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.exceptions import StrategyError from freqtrade.exceptions import StrategyError
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes
@ -185,7 +186,7 @@ class IStrategy(ABC):
""" """
return False return False
def informative_pairs(self) -> List[Tuple[str, str]]: def informative_pairs(self) -> ListPairsWithTimeframes:
""" """
Define additional, informative pair/interval combinations to be cached from the exchange. Define additional, informative pair/interval combinations to be cached from the exchange.
These pair/interval combinations are non-tradeable, unless they are part These pair/interval combinations are non-tradeable, unless they are part