mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-06 06:10:24 +00:00
orderflow: adds cache_size to config
This commit is contained in:
@@ -21,6 +21,7 @@ This guide walks you through utilizing public trade data for advanced orderflow
|
||||
|
||||
2. **Configure Orderflow Processing:** Define your desired settings for orderflow processing within the orderflow section of config.json. Here, you can adjust factors like:
|
||||
|
||||
- `cache_size`: How many previous orderflow candles are saved into cache instead of calculated every new candle
|
||||
- `max_candles`: Filter how many candles get processed from the tail
|
||||
- `scale`: This controls the price bin size for the footprint chart.
|
||||
- `stacked_imbalance_range`: Defines the minimum consecutive imbalanced price levels required for consideration.
|
||||
@@ -29,6 +30,7 @@ This guide walks you through utilizing public trade data for advanced orderflow
|
||||
|
||||
```json
|
||||
"orderflow": {
|
||||
"cache_size": 1000,
|
||||
"max_candles": 1500,
|
||||
"scale": 0.5,
|
||||
"stacked_imbalance_range": 3, // needs at least this amount of imbalance next to each other
|
||||
|
||||
@@ -537,6 +537,7 @@ CONF_SCHEMA = {
|
||||
"orderflow": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cache_size": {"type": "number", "minimum": 1, "default": 1000},
|
||||
"max_candles": {"type": "number", "minimum": 1, "default": 1500},
|
||||
"scale": {"type": "number", "minimum": 0.0},
|
||||
"stacked_imbalance_range": {"type": "number", "minimum": 0},
|
||||
|
||||
@@ -14,6 +14,9 @@ from collections import OrderedDict
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Global cache dictionary
|
||||
cached_grouped_trades = OrderedDict()
|
||||
|
||||
|
||||
def _init_dataframe_with_trades_columns(dataframe: pd.DataFrame):
|
||||
"""
|
||||
@@ -56,11 +59,6 @@ def _calculate_ohlcv_candle_start_and_end(df: pd.DataFrame, timeframe: str):
|
||||
df.drop(columns=["datetime"], inplace=True)
|
||||
|
||||
|
||||
# Global cache dictionary
|
||||
cache_size = 1000 # TODO move that in config
|
||||
cached_grouped_trades = OrderedDict() # TODO move that where?
|
||||
|
||||
|
||||
def populate_dataframe_with_trades(config, dataframe, trades):
|
||||
"""
|
||||
Populates a dataframe with trades
|
||||
@@ -68,8 +66,9 @@ def populate_dataframe_with_trades(config, dataframe, trades):
|
||||
:param trades: Trades to populate with
|
||||
:return: Dataframe with trades populated
|
||||
"""
|
||||
config_orderflow = config["orderflow"]
|
||||
timeframe = config["timeframe"]
|
||||
config_orderflow = config["orderflow"]
|
||||
cache_size = config_orderflow["cache_size"]
|
||||
|
||||
# create columns for trades
|
||||
_init_dataframe_with_trades_columns(dataframe)
|
||||
|
||||
@@ -90,6 +90,7 @@ def test_public_trades_mock_populate_dataframe_with_trades__check_orderflow(
|
||||
config = {
|
||||
"timeframe": "5m",
|
||||
"orderflow": {
|
||||
"cache_size": 1000,
|
||||
"max_candles": 1500,
|
||||
"scale": 0.005,
|
||||
"imbalance_volume": 0,
|
||||
@@ -201,6 +202,7 @@ def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades(
|
||||
config = {
|
||||
"timeframe": "5m",
|
||||
"orderflow": {
|
||||
"cache_size": 1000,
|
||||
"max_candles": 1500,
|
||||
"scale": 0.5,
|
||||
"imbalance_volume": 0,
|
||||
@@ -243,7 +245,7 @@ def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades(
|
||||
assert 169.442 == row["ask"]
|
||||
|
||||
# Assert the number of trades
|
||||
assert 151 == len(row.trades)
|
||||
assert 151 == len(row["trades"])
|
||||
|
||||
# Assert specific details of the first trade
|
||||
t = row["trades"].iloc[0]
|
||||
@@ -367,6 +369,7 @@ def test_public_trades_config_max_trades(
|
||||
orderflow_config = {
|
||||
"timeframe": "5m",
|
||||
"orderflow": {
|
||||
"cache_size": 1000,
|
||||
"max_candles": 1,
|
||||
"scale": 0.005,
|
||||
"imbalance_volume": 0,
|
||||
|
||||
Reference in New Issue
Block a user