From dad2cad525faa80a8b9383adca62d3288e52579b Mon Sep 17 00:00:00 2001 From: Joe Schr <8218910+TheJoeSchr@users.noreply.github.com> Date: Wed, 26 Jun 2024 19:43:13 +0200 Subject: [PATCH] orderflow: fixing typing --- freqtrade/data/converter/orderflow.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/data/converter/orderflow.py b/freqtrade/data/converter/orderflow.py index e40ac5cab..6372147c2 100644 --- a/freqtrade/data/converter/orderflow.py +++ b/freqtrade/data/converter/orderflow.py @@ -4,6 +4,7 @@ Functions to convert orderflow data from public_trades import logging import time +import typing from collections import OrderedDict import numpy as np @@ -101,7 +102,7 @@ def populate_dataframe_with_trades(config, dataframe, trades): if is_between.any(): from freqtrade.exchange import timeframe_to_next_date - candle_next = timeframe_to_next_date(timeframe, candle_start) + candle_next = timeframe_to_next_date(timeframe, typing.cast(datetime, candle_start)) if candle_next not in trades_grouped_by_candle_start.groups: logger.warning( f"candle at {candle_start} with {len(trades_grouped_df)} trades " @@ -113,7 +114,7 @@ def populate_dataframe_with_trades(config, dataframe, trades): trades_series.loc[indices] = [trades_grouped_df] # Use caching mechanism if (candle_start, candle_next) in cached_grouped_trades: - cache_entry = cached_grouped_trades[(candle_start, candle_next)] + cache_entry = cached_grouped_trades[(typing.cast(datetime, candle_start), candle_next)] # dataframe.loc[is_between] = cache_entry # doesn't take, so we need workaround: # Create a dictionary of the column values to be assigned update_dict = {c: cache_entry[c].iat[0] for c in cache_entry.columns} @@ -169,7 +170,7 @@ def populate_dataframe_with_trades(config, dataframe, trades): dataframe.loc[indices, "total_trades"] = len(trades_grouped_df) # Cache the result - cached_grouped_trades[(candle_start, candle_next)] = dataframe.loc[ + cached_grouped_trades[(typing.cast(datetime, candle_start), candle_next)] = dataframe.loc[ is_between ].copy() @@ -194,7 +195,7 @@ def populate_dataframe_with_trades(config, dataframe, trades): return dataframe -def trades_to_volumeprofile_with_total_delta_bid_ask(trades: pd.DataFrame, scale: float): +def trades_to_volumeprofile_with_total_delta_bid_ask(trades: pd.DataFrame, scale: float) -> pd.DataFrame: """ :param trades: dataframe :param scale: scale aka bin size e.g. 0.5