replaced candle_type: Optional[str] = '' with candle_type: str = ''
This commit is contained in:
parent
64a6abc541
commit
e2f98a8dab
@ -266,7 +266,7 @@ def convert_ohlcv_format(
|
||||
convert_from: str,
|
||||
convert_to: str,
|
||||
erase: bool,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
):
|
||||
"""
|
||||
Convert OHLCV from one format to another
|
||||
|
@ -99,7 +99,12 @@ class DataProvider:
|
||||
logger.warning(f"No data found for ({pair}, {timeframe}).")
|
||||
return data
|
||||
|
||||
def get_analyzed_dataframe(self, pair: str, timeframe: str) -> Tuple[DataFrame, datetime]:
|
||||
def get_analyzed_dataframe(
|
||||
self,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
candle_type: str = ''
|
||||
) -> Tuple[DataFrame, datetime]:
|
||||
"""
|
||||
Retrieve the analyzed dataframe. Returns the full dataframe in trade mode (live / dry),
|
||||
and the last 1000 candles (up to the time evaluated at this moment) in all other modes.
|
||||
@ -177,7 +182,13 @@ class DataProvider:
|
||||
raise OperationalException(NO_EXCHANGE_EXCEPTION)
|
||||
return list(self._exchange._klines.keys())
|
||||
|
||||
def ohlcv(self, pair: str, timeframe: str = None, copy: bool = True) -> DataFrame:
|
||||
def ohlcv(
|
||||
self,
|
||||
pair: str,
|
||||
timeframe: str = None,
|
||||
copy: bool = True,
|
||||
candle_type: str = ''
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Get candle (OHLCV) data for the given pair as DataFrame
|
||||
Please use the `available_pairs` method to verify which pairs are currently cached.
|
||||
|
@ -42,7 +42,7 @@ class HDF5DataHandler(IDataHandler):
|
||||
cls,
|
||||
datadir: Path,
|
||||
timeframe: str,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> List[str]:
|
||||
"""
|
||||
Returns a list of all pairs with ohlcv data available in this datadir
|
||||
@ -67,7 +67,7 @@ class HDF5DataHandler(IDataHandler):
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
data: pd.DataFrame,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Store data in hdf5 file.
|
||||
@ -88,7 +88,7 @@ class HDF5DataHandler(IDataHandler):
|
||||
|
||||
def _ohlcv_load(self, pair: str, timeframe: str,
|
||||
timerange: Optional[TimeRange] = None,
|
||||
candle_type: Optional[str] = "") -> pd.DataFrame:
|
||||
candle_type: str = '') -> pd.DataFrame:
|
||||
"""
|
||||
Internal method used to load data for one pair from disk.
|
||||
Implements the loading and conversion to a Pandas dataframe.
|
||||
@ -125,7 +125,7 @@ class HDF5DataHandler(IDataHandler):
|
||||
'low': 'float', 'close': 'float', 'volume': 'float'})
|
||||
return pairdata
|
||||
|
||||
def ohlcv_purge(self, pair: str, timeframe: str, candle_type: Optional[str] = "") -> bool:
|
||||
def ohlcv_purge(self, pair: str, timeframe: str, candle_type: str = '') -> bool:
|
||||
"""
|
||||
Remove data for this pair
|
||||
:param pair: Delete data for this pair.
|
||||
@ -143,7 +143,7 @@ class HDF5DataHandler(IDataHandler):
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
data: pd.DataFrame,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Append data to existing data structures
|
||||
@ -238,7 +238,7 @@ class HDF5DataHandler(IDataHandler):
|
||||
datadir: Path,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> Path:
|
||||
pair_s = misc.pair_to_filename(pair)
|
||||
if candle_type:
|
||||
|
@ -29,6 +29,7 @@ def load_pair_history(pair: str,
|
||||
startup_candles: int = 0,
|
||||
data_format: str = None,
|
||||
data_handler: IDataHandler = None,
|
||||
candle_type: str = ''
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Load cached ohlcv history for the given pair.
|
||||
@ -64,6 +65,7 @@ def load_data(datadir: Path,
|
||||
startup_candles: int = 0,
|
||||
fail_without_data: bool = False,
|
||||
data_format: str = 'json',
|
||||
candle_type: str = ''
|
||||
) -> Dict[str, DataFrame]:
|
||||
"""
|
||||
Load ohlcv history data for a list of pairs.
|
||||
@ -105,6 +107,7 @@ def refresh_data(datadir: Path,
|
||||
exchange: Exchange,
|
||||
data_format: str = None,
|
||||
timerange: Optional[TimeRange] = None,
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Refresh ohlcv history data for a list of pairs.
|
||||
@ -124,8 +127,13 @@ def refresh_data(datadir: Path,
|
||||
timerange=timerange, exchange=exchange, data_handler=data_handler)
|
||||
|
||||
|
||||
def _load_cached_data_for_updating(pair: str, timeframe: str, timerange: Optional[TimeRange],
|
||||
data_handler: IDataHandler) -> Tuple[DataFrame, Optional[int]]:
|
||||
def _load_cached_data_for_updating(
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
timerange: Optional[TimeRange],
|
||||
data_handler: IDataHandler,
|
||||
candle_type: str = ''
|
||||
) -> Tuple[DataFrame, Optional[int]]:
|
||||
"""
|
||||
Load cached data to download more data.
|
||||
If timerange is passed in, checks whether data from an before the stored data will be
|
||||
@ -162,7 +170,7 @@ def _download_pair_history(pair: str, *,
|
||||
new_pairs_days: int = 30,
|
||||
data_handler: IDataHandler = None,
|
||||
timerange: Optional[TimeRange] = None,
|
||||
candle_type: Optional[str] = "") -> bool:
|
||||
candle_type: str = '') -> bool:
|
||||
"""
|
||||
Download latest candles from the exchange for the pair and timeframe passed in parameters
|
||||
The data is downloaded starting from the last correct data that
|
||||
@ -232,7 +240,7 @@ def refresh_backtest_ohlcv_data(exchange: Exchange, pairs: List[str], timeframes
|
||||
datadir: Path, timerange: Optional[TimeRange] = None,
|
||||
new_pairs_days: int = 30, erase: bool = False,
|
||||
data_format: str = None,
|
||||
candle_type: Optional[str] = "") -> List[str]:
|
||||
candle_type: str = '') -> List[str]:
|
||||
"""
|
||||
Refresh stored ohlcv data for backtesting and hyperopt operations.
|
||||
Used by freqtrade download-data subcommand.
|
||||
@ -365,7 +373,7 @@ def convert_trades_to_ohlcv(
|
||||
erase: bool = False,
|
||||
data_format_ohlcv: str = 'json',
|
||||
data_format_trades: str = 'jsongz',
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Convert stored trades data to ohlcv data
|
||||
|
@ -39,7 +39,7 @@ class IDataHandler(ABC):
|
||||
cls,
|
||||
datadir: Path,
|
||||
timeframe: str,
|
||||
candle_type: Optional[str] = ''
|
||||
candle_type: str = ''
|
||||
) -> List[str]:
|
||||
"""
|
||||
Returns a list of all pairs with ohlcv data available in this datadir
|
||||
@ -55,7 +55,7 @@ class IDataHandler(ABC):
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
data: DataFrame,
|
||||
candle_type: Optional[str] = ''
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Store ohlcv data.
|
||||
@ -68,7 +68,7 @@ class IDataHandler(ABC):
|
||||
@abstractmethod
|
||||
def _ohlcv_load(self, pair: str, timeframe: str,
|
||||
timerange: Optional[TimeRange] = None,
|
||||
candle_type: Optional[str] = ''
|
||||
candle_type: str = ''
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Internal method used to load data for one pair from disk.
|
||||
@ -83,7 +83,7 @@ class IDataHandler(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def ohlcv_purge(self, pair: str, timeframe: str, candle_type: Optional[str] = '') -> bool:
|
||||
def ohlcv_purge(self, pair: str, timeframe: str, candle_type: str = '') -> bool:
|
||||
"""
|
||||
Remove data for this pair
|
||||
:param pair: Delete data for this pair.
|
||||
@ -97,7 +97,7 @@ class IDataHandler(ABC):
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
data: DataFrame,
|
||||
candle_type: Optional[str] = ''
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Append data to existing data structures
|
||||
@ -165,7 +165,7 @@ class IDataHandler(ABC):
|
||||
drop_incomplete: bool = True,
|
||||
startup_candles: int = 0,
|
||||
warn_no_data: bool = True,
|
||||
candle_type: Optional[str] = ''
|
||||
candle_type: str = ''
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Load cached candle (OHLCV) data for the given pair.
|
||||
|
@ -42,7 +42,7 @@ class JsonDataHandler(IDataHandler):
|
||||
cls,
|
||||
datadir: Path,
|
||||
timeframe: str,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> List[str]:
|
||||
"""
|
||||
Returns a list of all pairs with ohlcv data available in this datadir
|
||||
@ -66,7 +66,7 @@ class JsonDataHandler(IDataHandler):
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
data: DataFrame,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Store data in json format "values".
|
||||
@ -94,7 +94,7 @@ class JsonDataHandler(IDataHandler):
|
||||
|
||||
def _ohlcv_load(self, pair: str, timeframe: str,
|
||||
timerange: Optional[TimeRange] = None,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Internal method used to load data for one pair from disk.
|
||||
@ -124,7 +124,7 @@ class JsonDataHandler(IDataHandler):
|
||||
infer_datetime_format=True)
|
||||
return pairdata
|
||||
|
||||
def ohlcv_purge(self, pair: str, timeframe: str, candle_type: Optional[str] = "") -> bool:
|
||||
def ohlcv_purge(self, pair: str, timeframe: str, candle_type: str = '') -> bool:
|
||||
"""
|
||||
Remove data for this pair
|
||||
:param pair: Delete data for this pair.
|
||||
@ -142,7 +142,7 @@ class JsonDataHandler(IDataHandler):
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
data: DataFrame,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> None:
|
||||
"""
|
||||
Append data to existing data structures
|
||||
@ -222,7 +222,7 @@ class JsonDataHandler(IDataHandler):
|
||||
datadir: Path,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> Path:
|
||||
pair_s = misc.pair_to_filename(pair)
|
||||
if candle_type:
|
||||
|
@ -200,15 +200,11 @@ class Binance(Exchange):
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
async def _async_get_historic_ohlcv(
|
||||
self,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
since_ms: int,
|
||||
is_new_pair: bool,
|
||||
raise_: bool = False,
|
||||
candle_type: Optional[str] = ""
|
||||
) -> Tuple[str, str, List]:
|
||||
async def _async_get_historic_ohlcv(self, pair: str, timeframe: str,
|
||||
since_ms: int, is_new_pair: bool = False,
|
||||
raise_: bool = False,
|
||||
candle_type: str = ''
|
||||
) -> Tuple[str, str, List]:
|
||||
"""
|
||||
Overwrite to introduce "fast new pair" functionality by detecting the pair's listing date
|
||||
Does not work for other exchanges, which don't return the earliest data when called with "0"
|
||||
|
@ -1311,7 +1311,7 @@ class Exchange:
|
||||
|
||||
def get_historic_ohlcv(self, pair: str, timeframe: str,
|
||||
since_ms: int, is_new_pair: bool = False,
|
||||
candle_type: Optional[str] = "") -> List:
|
||||
candle_type: str = '') -> List:
|
||||
"""
|
||||
Get candle history using asyncio and returns the list of candles.
|
||||
Handles all async work for this.
|
||||
@ -1329,7 +1329,7 @@ class Exchange:
|
||||
return data
|
||||
|
||||
def get_historic_ohlcv_as_df(self, pair: str, timeframe: str,
|
||||
since_ms: int, candle_type: Optional[str] = "") -> DataFrame:
|
||||
since_ms: int, candle_type: str = '') -> DataFrame:
|
||||
"""
|
||||
Minimal wrapper around get_historic_ohlcv - converting the result into a dataframe
|
||||
:param pair: Pair to download
|
||||
@ -1344,7 +1344,7 @@ class Exchange:
|
||||
async def _async_get_historic_ohlcv(self, pair: str, timeframe: str,
|
||||
since_ms: int, is_new_pair: bool,
|
||||
raise_: bool = False,
|
||||
candle_type: Optional[str] = ""
|
||||
candle_type: str = ''
|
||||
) -> Tuple[str, str, List]:
|
||||
"""
|
||||
Download historic ohlcv
|
||||
@ -1383,8 +1383,8 @@ class Exchange:
|
||||
|
||||
def refresh_latest_ohlcv(self, pair_list: ListPairsWithTimeframes, *,
|
||||
since_ms: Optional[int] = None, cache: bool = True,
|
||||
candle_type: Optional[str] = ""
|
||||
) -> Dict[Tuple[str, str], DataFrame]:
|
||||
candle_type: str = ''
|
||||
) -> Dict[Tuple[str, str, str], DataFrame]:
|
||||
"""
|
||||
Refresh in-memory OHLCV asynchronously and set `_klines` with the result
|
||||
Loops asynchronously over pair_list and downloads all pairs async (semi-parallel).
|
||||
@ -1450,7 +1450,12 @@ class Exchange:
|
||||
|
||||
return results_df
|
||||
|
||||
def _now_is_time_to_refresh(self, pair: str, timeframe: str) -> bool:
|
||||
def _now_is_time_to_refresh(
|
||||
self,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
candle_type: str = ''
|
||||
) -> bool:
|
||||
# Timeframe in seconds
|
||||
interval_in_sec = timeframe_to_seconds(timeframe)
|
||||
|
||||
@ -1463,8 +1468,8 @@ class Exchange:
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
since_ms: Optional[int] = None,
|
||||
candle_type: Optional[str] = "",
|
||||
) -> Tuple[str, str, List]:
|
||||
candle_type: str = '',
|
||||
) -> Tuple[str, str, str, List]:
|
||||
"""
|
||||
Asynchronously get candle history data using fetch_ohlcv
|
||||
:param candle_type:
|
||||
|
Loading…
Reference in New Issue
Block a user