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:
Joe Schr
2023-06-01 12:26:17 +02:00
parent 64a072e207
commit 4abac1364a
2 changed files with 16 additions and 17 deletions

View File

@@ -2297,25 +2297,12 @@ class Exchange:
now = timeframe_to_next_date(timeframe)
return int((now - timedelta(seconds=move_to // 1000)).timestamp() * 1000)
def refresh_latest_trades(self,
pair_list: ListPairsWithTimeframes ,
data_handler: Callable,# IDataHandler,
*,
cache: bool = True,
) -> 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
Loops asynchronously over pair_list and downloads all pairs async (semi-parallel).