mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: adds max_candles to orderflow 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:
|
||||
|
||||
- `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.
|
||||
- `imbalance_volume`: Filters out imbalances with volume below this threshold.
|
||||
@@ -28,6 +29,7 @@ This guide walks you through utilizing public trade data for advanced orderflow
|
||||
|
||||
```json
|
||||
"orderflow": {
|
||||
"max_candles": 1500,
|
||||
"scale": 0.5,
|
||||
"stacked_imbalance_range": 3, // needs at least this amount of imbalance next to each other
|
||||
"imbalance_volume": 1, // filters out below
|
||||
|
||||
@@ -537,12 +537,19 @@ CONF_SCHEMA = {
|
||||
"orderflow": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"max_candles": {"type": "number", "minimum": 1, "default": 1500},
|
||||
"scale": {"type": "number", "minimum": 0.0},
|
||||
"stacked_imbalance_range": {"type": "number", "minimum": 0},
|
||||
"imbalance_volume": {"type": "number", "minimum": 0},
|
||||
"imbalance_ratio": {"type": "number", "minimum": 0.0},
|
||||
},
|
||||
"required": ["scale", "stacked_imbalance_range", "imbalance_volume", "imbalance_ratio"],
|
||||
"required": [
|
||||
"max_candles",
|
||||
"scale",
|
||||
"stacked_imbalance_range",
|
||||
"imbalance_volume",
|
||||
"imbalance_ratio",
|
||||
],
|
||||
},
|
||||
},
|
||||
"definitions": {
|
||||
|
||||
@@ -68,8 +68,11 @@ def populate_dataframe_with_trades(
|
||||
# calculate ohlcv candle start and end
|
||||
_calculate_ohlcv_candle_start_and_end(trades, timeframe)
|
||||
|
||||
# get date of earliest max_candles candle
|
||||
max_candles = config_orderflow["max_candles"]
|
||||
start_date = df.tail(max_candles).date.iat[0]
|
||||
# slice of trades that are before current ohlcv candles to make groupby faster
|
||||
trades = trades.loc[trades.candle_start >= df.date[0]]
|
||||
trades = trades.loc[trades.candle_start >= start_date]
|
||||
trades.reset_index(inplace=True, drop=True)
|
||||
|
||||
# group trades by candle start
|
||||
|
||||
@@ -90,6 +90,7 @@ def test_public_trades_mock_populate_dataframe_with_trades__check_orderflow(
|
||||
config = {
|
||||
"timeframe": "5m",
|
||||
"orderflow": {
|
||||
"max_candles": 1500,
|
||||
"scale": 0.005,
|
||||
"imbalance_volume": 0,
|
||||
"imbalance_ratio": 3,
|
||||
@@ -200,6 +201,7 @@ def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades(
|
||||
config = {
|
||||
"timeframe": "5m",
|
||||
"orderflow": {
|
||||
"max_candles": 1500,
|
||||
"scale": 0.5,
|
||||
"imbalance_volume": 0,
|
||||
"imbalance_ratio": 3,
|
||||
@@ -355,6 +357,27 @@ def test_public_trades_binned_big_sample_list(public_trades_list):
|
||||
assert 52.7199999 == pytest.approx(df["delta"].iat[0]) # delta
|
||||
|
||||
|
||||
def test_public_trades_config_max_trades(
|
||||
default_conf, populate_dataframe_with_trades_dataframe, populate_dataframe_with_trades_trades
|
||||
):
|
||||
dataframe = populate_dataframe_with_trades_dataframe.copy()
|
||||
trades = populate_dataframe_with_trades_trades.copy()
|
||||
default_conf["exchange"]["use_public_trades"] = True
|
||||
orderflow_config = {
|
||||
"timeframe": "5m",
|
||||
"orderflow": {
|
||||
"max_candles": 1,
|
||||
"scale": 0.005,
|
||||
"imbalance_volume": 0,
|
||||
"imbalance_ratio": 3,
|
||||
"stacked_imbalance_range": 3,
|
||||
},
|
||||
}
|
||||
|
||||
df = populate_dataframe_with_trades(default_conf | orderflow_config, dataframe, trades)
|
||||
assert df.delta.count() == 1
|
||||
|
||||
|
||||
def test_public_trades_testdata_sanity(
|
||||
candles,
|
||||
public_trades_list,
|
||||
|
||||
Reference in New Issue
Block a user