Update data downloading to include funding_fee downloads
This commit is contained in:
parent
17bd990053
commit
ddce28c12d
@ -283,12 +283,15 @@ def refresh_backtest_ohlcv_data(exchange: Exchange, pairs: List[str], timeframes
|
|||||||
# Predefined candletype (and timeframe) depending on exchange
|
# Predefined candletype (and timeframe) depending on exchange
|
||||||
# Downloads what is necessary to backtest based on futures data.
|
# Downloads what is necessary to backtest based on futures data.
|
||||||
timeframe = exchange._ft_has['mark_ohlcv_timeframe']
|
timeframe = exchange._ft_has['mark_ohlcv_timeframe']
|
||||||
candle_type = CandleType.from_string(exchange._ft_has['mark_ohlcv_price'])
|
fr_candle_type = CandleType.from_string(exchange._ft_has['mark_ohlcv_price'])
|
||||||
|
# All exchanges need FundingRate for futures trading.
|
||||||
|
# The timeframe is aligned to the mark-price timeframe.
|
||||||
|
for candle_type in (CandleType.FUNDING_RATE, fr_candle_type):
|
||||||
# TODO: this could be in most parts to the above.
|
# TODO: this could be in most parts to the above.
|
||||||
if erase:
|
if erase:
|
||||||
if data_handler.ohlcv_purge(pair, timeframe, candle_type=candle_type):
|
if data_handler.ohlcv_purge(pair, timeframe, candle_type=candle_type):
|
||||||
logger.info(f'Deleting existing data for pair {pair}, interval {timeframe}.')
|
logger.info(
|
||||||
|
f'Deleting existing data for pair {pair}, interval {timeframe}.')
|
||||||
_download_pair_history(pair=pair, process=process,
|
_download_pair_history(pair=pair, process=process,
|
||||||
datadir=datadir, exchange=exchange,
|
datadir=datadir, exchange=exchange,
|
||||||
timerange=timerange, data_handler=data_handler,
|
timerange=timerange, data_handler=data_handler,
|
||||||
|
@ -1840,8 +1840,8 @@ class Exchange:
|
|||||||
|
|
||||||
if self.funding_fee_cutoff(open_date):
|
if self.funding_fee_cutoff(open_date):
|
||||||
open_date += timedelta(hours=1)
|
open_date += timedelta(hours=1)
|
||||||
|
timeframe = self._ft_has['mark_ohlcv_timeframe']
|
||||||
open_date = timeframe_to_prev_date('1h', open_date)
|
open_date = timeframe_to_prev_date(timeframe, open_date)
|
||||||
|
|
||||||
fees: float = 0
|
fees: float = 0
|
||||||
if not close_date:
|
if not close_date:
|
||||||
@ -1850,11 +1850,9 @@ class Exchange:
|
|||||||
# close_timestamp = int(close_date.timestamp()) * 1000
|
# close_timestamp = int(close_date.timestamp()) * 1000
|
||||||
|
|
||||||
mark_comb: PairWithTimeframe = (
|
mark_comb: PairWithTimeframe = (
|
||||||
pair, '1h', CandleType.from_string(self._ft_has["mark_ohlcv_price"]))
|
pair, timeframe, CandleType.from_string(self._ft_has["mark_ohlcv_price"]))
|
||||||
|
|
||||||
# TODO-lev: 1h seems arbitrary and generates a lot of "empty" lines
|
funding_comb: PairWithTimeframe = (pair, timeframe, CandleType.FUNDING_RATE)
|
||||||
# TODO-lev: probably a exchange-adjusted parameter would make more sense
|
|
||||||
funding_comb: PairWithTimeframe = (pair, '1h', CandleType.FUNDING_RATE)
|
|
||||||
candle_histories = self.refresh_latest_ohlcv(
|
candle_histories = self.refresh_latest_ohlcv(
|
||||||
[mark_comb, funding_comb],
|
[mark_comb, funding_comb],
|
||||||
since_ms=open_timestamp,
|
since_ms=open_timestamp,
|
||||||
|
@ -490,7 +490,7 @@ def test_validate_backtest_data(default_conf, mocker, caplog, testdatadir) -> No
|
|||||||
@pytest.mark.parametrize('trademode,callcount', [
|
@pytest.mark.parametrize('trademode,callcount', [
|
||||||
('spot', 4),
|
('spot', 4),
|
||||||
('margin', 4),
|
('margin', 4),
|
||||||
('futures', 6),
|
('futures', 8), # Called 8 times - 4 normal, 2 funding and 2 mark/index calls
|
||||||
])
|
])
|
||||||
def test_refresh_backtest_ohlcv_data(
|
def test_refresh_backtest_ohlcv_data(
|
||||||
mocker, default_conf, markets, caplog, testdatadir, trademode, callcount):
|
mocker, default_conf, markets, caplog, testdatadir, trademode, callcount):
|
||||||
|
Loading…
Reference in New Issue
Block a user