mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-17 05:11:15 +00:00
refactor(move function): refresh_latest_trades into dataprovider
needed here to be used for call before analyze also removes need for internal exchange function checking if public_trades is enabled
This commit is contained in:
@@ -446,10 +446,22 @@ class DataProvider:
|
|||||||
final_pairs = (pairlist + helping_pairs) if helping_pairs else pairlist
|
final_pairs = (pairlist + helping_pairs) if helping_pairs else pairlist
|
||||||
# refresh latest ohlcv data
|
# refresh latest ohlcv data
|
||||||
self._exchange.refresh_latest_ohlcv(final_pairs)
|
self._exchange.refresh_latest_ohlcv(final_pairs)
|
||||||
# refresh latest trades data (if enabled)
|
# refresh latest trades data
|
||||||
self._exchange.refresh_latest_trades(final_pairs,
|
self.refresh_latest_trades(final_pairs)
|
||||||
get_datahandler(self._config['datadir'],
|
|
||||||
data_format=self._config['dataformat_trades']))
|
def refresh_latest_trades(self,
|
||||||
|
pairlist: ListPairsWithTimeframes) -> None:
|
||||||
|
"""
|
||||||
|
Refresh latest trades data (if enabled in config)
|
||||||
|
"""
|
||||||
|
|
||||||
|
use_public_trades = self._config.get(
|
||||||
|
'exchange', {}).get('use_public_trades', False)
|
||||||
|
if use_public_trades:
|
||||||
|
return self._exchange.refresh_latest_trades(pairlist,
|
||||||
|
get_datahandler(self._config['datadir'],
|
||||||
|
data_format=self._config['dataformat_trades']))
|
||||||
|
return {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_pairs(self) -> ListPairsWithTimeframes:
|
def available_pairs(self) -> ListPairsWithTimeframes:
|
||||||
|
|||||||
@@ -2297,25 +2297,12 @@ class Exchange:
|
|||||||
now = timeframe_to_next_date(timeframe)
|
now = timeframe_to_next_date(timeframe)
|
||||||
return int((now - timedelta(seconds=move_to // 1000)).timestamp() * 1000)
|
return int((now - timedelta(seconds=move_to // 1000)).timestamp() * 1000)
|
||||||
|
|
||||||
|
|
||||||
def refresh_latest_trades(self,
|
def refresh_latest_trades(self,
|
||||||
pair_list: ListPairsWithTimeframes ,
|
pair_list: ListPairsWithTimeframes ,
|
||||||
data_handler: Callable,# IDataHandler,
|
data_handler: Callable,# IDataHandler,
|
||||||
*,
|
*,
|
||||||
cache: bool = True,
|
cache: bool = True,
|
||||||
) -> Dict[PairWithTimeframe, DataFrame]:
|
) -> Dict[PairWithTimeframe, DataFrame]:
|
||||||
use_public_trades = self._config.get(
|
|
||||||
'exchange', {}).get('use_public_trades', False)
|
|
||||||
if use_public_trades:
|
|
||||||
return self._refresh_latest_trades(pair_list, data_handler, cache=cache)
|
|
||||||
return {}
|
|
||||||
|
|
||||||
def _refresh_latest_trades(self,
|
|
||||||
pair_list: ListPairsWithTimeframes ,
|
|
||||||
data_handler: Callable,# IDataHandler,
|
|
||||||
*,
|
|
||||||
cache: bool = True,
|
|
||||||
) -> Dict[PairWithTimeframe, DataFrame]:
|
|
||||||
"""
|
"""
|
||||||
Refresh in-memory TRADES asynchronously and set `_trades` with the result
|
Refresh in-memory TRADES asynchronously and set `_trades` 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).
|
||||||
|
|||||||
Reference in New Issue
Block a user