Removed candletype from converter methods
This commit is contained in:
parent
ee2ad8ca97
commit
3d95533bf9
@ -17,8 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def ohlcv_to_dataframe(ohlcv: list, timeframe: str, pair: str, *,
|
||||
fill_missing: bool = True, drop_incomplete: bool = True,
|
||||
candle_type: Optional[str] = "") -> DataFrame:
|
||||
fill_missing: bool = True, drop_incomplete: bool = True) -> DataFrame:
|
||||
"""
|
||||
Converts a list with candle (OHLCV) data (in format returned by ccxt.fetch_ohlcv)
|
||||
to a Dataframe
|
||||
@ -43,14 +42,12 @@ def ohlcv_to_dataframe(ohlcv: list, timeframe: str, pair: str, *,
|
||||
'volume': 'float'})
|
||||
return clean_ohlcv_dataframe(df, timeframe, pair,
|
||||
fill_missing=fill_missing,
|
||||
drop_incomplete=drop_incomplete,
|
||||
candle_type=candle_type)
|
||||
drop_incomplete=drop_incomplete)
|
||||
|
||||
|
||||
def clean_ohlcv_dataframe(data: DataFrame, timeframe: str, pair: str, *,
|
||||
fill_missing: bool = True,
|
||||
drop_incomplete: bool = True,
|
||||
candle_type: Optional[str] = "") -> DataFrame:
|
||||
drop_incomplete: bool = True) -> DataFrame:
|
||||
"""
|
||||
Cleanse a OHLCV dataframe by
|
||||
* Grouping it by date (removes duplicate tics)
|
||||
@ -78,17 +75,12 @@ def clean_ohlcv_dataframe(data: DataFrame, timeframe: str, pair: str, *,
|
||||
logger.debug('Dropping last candle')
|
||||
|
||||
if fill_missing:
|
||||
return ohlcv_fill_up_missing_data(data, timeframe, pair, candle_type)
|
||||
return ohlcv_fill_up_missing_data(data, timeframe, pair)
|
||||
else:
|
||||
return data
|
||||
|
||||
|
||||
def ohlcv_fill_up_missing_data(
|
||||
dataframe: DataFrame,
|
||||
timeframe: str,
|
||||
pair: str,
|
||||
candle_type: Optional[str] = ""
|
||||
) -> DataFrame:
|
||||
def ohlcv_fill_up_missing_data(dataframe: DataFrame, timeframe: str, pair: str) -> DataFrame:
|
||||
"""
|
||||
Fills up missing data with 0 volume rows,
|
||||
using the previous close as price for "open", "high" "low" and "close", volume is set to 0
|
||||
|
@ -204,16 +204,14 @@ def _download_pair_history(pair: str, *,
|
||||
)
|
||||
# TODO: Maybe move parsing to exchange class (?)
|
||||
new_dataframe = ohlcv_to_dataframe(new_data, timeframe, pair,
|
||||
fill_missing=False, drop_incomplete=True,
|
||||
candle_type=candle_type)
|
||||
fill_missing=False, drop_incomplete=True)
|
||||
if data.empty:
|
||||
data = new_dataframe
|
||||
else:
|
||||
# Run cleaning again to ensure there were no duplicate candles
|
||||
# Especially between existing and new data.
|
||||
data = clean_ohlcv_dataframe(data.append(new_dataframe), timeframe, pair,
|
||||
fill_missing=False, drop_incomplete=False,
|
||||
candle_type=candle_type)
|
||||
fill_missing=False, drop_incomplete=False)
|
||||
|
||||
logger.debug("New Start: %s",
|
||||
f"{data.iloc[0]['date']:%Y-%m-%d %H:%M:%S}" if not data.empty else 'None')
|
||||
|
@ -212,8 +212,7 @@ class IDataHandler(ABC):
|
||||
pair=pair,
|
||||
fill_missing=fill_missing,
|
||||
drop_incomplete=(drop_incomplete and
|
||||
enddate == pairdf.iloc[-1]['date']),
|
||||
candle_type=candle_type)
|
||||
enddate == pairdf.iloc[-1]['date']))
|
||||
self._check_empty_df(pairdf, pair, timeframe, warn_no_data, candle_type=candle_type)
|
||||
return pairdf
|
||||
|
||||
|
@ -7,7 +7,7 @@ import http
|
||||
import inspect
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import datetime, timezone
|
||||
from math import ceil
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
@ -1339,8 +1339,7 @@ class Exchange:
|
||||
"""
|
||||
ticks = self.get_historic_ohlcv(pair, timeframe, since_ms=since_ms)
|
||||
return ohlcv_to_dataframe(ticks, timeframe, pair=pair, fill_missing=True,
|
||||
drop_incomplete=self._ohlcv_partial_candle,
|
||||
candle_type=candle_type)
|
||||
drop_incomplete=self._ohlcv_partial_candle)
|
||||
|
||||
async def _async_get_historic_ohlcv(self, pair: str, timeframe: str,
|
||||
since_ms: int, is_new_pair: bool,
|
||||
@ -1441,8 +1440,7 @@ class Exchange:
|
||||
# keeping parsed dataframe in cache
|
||||
ohlcv_df = ohlcv_to_dataframe(
|
||||
ticks, timeframe, pair=pair, fill_missing=True,
|
||||
drop_incomplete=self._ohlcv_partial_candle,
|
||||
candle_type=candle_type)
|
||||
drop_incomplete=self._ohlcv_partial_candle)
|
||||
results_df[(pair, timeframe)] = ohlcv_df
|
||||
if cache:
|
||||
self._klines[(pair, timeframe)] = ohlcv_df
|
||||
@ -1469,7 +1467,9 @@ class Exchange:
|
||||
) -> Tuple[str, str, List]:
|
||||
"""
|
||||
Asynchronously get candle history data using fetch_ohlcv
|
||||
:param candle_type: "mark" if retrieving the mark price cnadles, "index" for index price candles
|
||||
:param candle_type:
|
||||
"mark" if retrieving the mark price cnadles
|
||||
"index" for index price candles
|
||||
returns tuple: (pair, timeframe, ohlcv_list)
|
||||
"""
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user