imbalance_ratio: use ratio instead of percentage
This commit is contained in:
@@ -24,7 +24,7 @@ This guide walks you through utilizing public trade data for advanced orderflow
|
|||||||
"scale": 0.5,
|
"scale": 0.5,
|
||||||
"stacked_imbalance_range": 3, // needs at least this amount of imbalance next to each other
|
"stacked_imbalance_range": 3, // needs at least this amount of imbalance next to each other
|
||||||
"imbalance_volume": 1, // filters out below
|
"imbalance_volume": 1, // filters out below
|
||||||
"imbalance_ratio": 300 // filters out ratio lower than
|
"imbalance_ratio": 3 // filters out ratio lower than
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ CONF_SCHEMA = {
|
|||||||
"scale": {"type": "number", "minimum": 0.0},
|
"scale": {"type": "number", "minimum": 0.0},
|
||||||
"stacked_imbalance_range": {"type": "number"},
|
"stacked_imbalance_range": {"type": "number"},
|
||||||
"imbalance_volume": {"type": "number"},
|
"imbalance_volume": {"type": "number"},
|
||||||
"imbalance_ratio": {"type": "number"},
|
"imbalance_ratio": {"type": "number", "minimum": 0.0},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -211,16 +211,16 @@ def trades_to_volumeprofile_with_total_delta_bid_ask(trades: pd.DataFrame, scale
|
|||||||
def trades_orderflow_to_imbalances(df: pd.DataFrame, imbalance_ratio: int, imbalance_volume: int):
|
def trades_orderflow_to_imbalances(df: pd.DataFrame, imbalance_ratio: int, imbalance_volume: int):
|
||||||
"""
|
"""
|
||||||
:param df: dataframes with bid and ask
|
:param df: dataframes with bid and ask
|
||||||
:param imbalance_ratio: imbalance_ratio e.g. 300
|
:param imbalance_ratio: imbalance_ratio e.g. 3
|
||||||
:param imbalance_volume: imbalance volume e.g. 3)
|
:param imbalance_volume: imbalance volume e.g. 10
|
||||||
:return: dataframe with bid and ask imbalance
|
:return: dataframe with bid and ask imbalance
|
||||||
"""
|
"""
|
||||||
bid = df.bid
|
bid = df.bid
|
||||||
ask = df.ask.shift(-1)
|
ask = df.ask.shift(-1)
|
||||||
bid_imbalance = (bid / ask) > (imbalance_ratio / 100)
|
bid_imbalance = (bid / ask) > (imbalance_ratio)
|
||||||
# overwrite bid_imbalance with False if volume is not big enough
|
# overwrite bid_imbalance with False if volume is not big enough
|
||||||
bid_imbalance_filtered = np.where(df.total_volume < imbalance_volume, False, bid_imbalance)
|
bid_imbalance_filtered = np.where(df.total_volume < imbalance_volume, False, bid_imbalance)
|
||||||
ask_imbalance = (ask / bid) > (imbalance_ratio / 100)
|
ask_imbalance = (ask / bid) > (imbalance_ratio)
|
||||||
# overwrite ask_imbalance with False if volume is not big enough
|
# overwrite ask_imbalance with False if volume is not big enough
|
||||||
ask_imbalance_filtered = np.where(df.total_volume < imbalance_volume, False, ask_imbalance)
|
ask_imbalance_filtered = np.where(df.total_volume < imbalance_volume, False, ask_imbalance)
|
||||||
dataframe = pd.DataFrame(
|
dataframe = pd.DataFrame(
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ def test_public_trades_mock_populate_dataframe_with_trades__check_orderflow(
|
|||||||
"orderflow": {
|
"orderflow": {
|
||||||
"scale": 0.005,
|
"scale": 0.005,
|
||||||
"imbalance_volume": 0,
|
"imbalance_volume": 0,
|
||||||
"imbalance_ratio": 300,
|
"imbalance_ratio": 3,
|
||||||
"stacked_imbalance_range": 3,
|
"stacked_imbalance_range": 3,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ def test_public_trades_trades_mock_populate_dataframe_with_trades__check_trades(
|
|||||||
"orderflow": {
|
"orderflow": {
|
||||||
"scale": 0.5,
|
"scale": 0.5,
|
||||||
"imbalance_volume": 0,
|
"imbalance_volume": 0,
|
||||||
"imbalance_ratio": 300,
|
"imbalance_ratio": 3,
|
||||||
"stacked_imbalance_range": 3,
|
"stacked_imbalance_range": 3,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user