mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
orderflow: fixing typing
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user