Make risk guard symbol aware
This commit is contained in:
@@ -171,6 +171,23 @@ class CryptoSpotBot:
|
||||
)
|
||||
)
|
||||
continue
|
||||
symbol_guard = self._risk_guard_for_symbol(risk_guard, symbol)
|
||||
if symbol_guard.get("block_new_entries"):
|
||||
self.storage.insert_signal(
|
||||
Signal(
|
||||
symbol,
|
||||
"HOLD",
|
||||
0.0,
|
||||
"risk_guard: symbol blocked",
|
||||
{
|
||||
"strategy_mode": self.settings.strategy_mode,
|
||||
"risk_guard": risk_guard,
|
||||
"symbol_guard": symbol_guard,
|
||||
"checks": {"risk_guard_symbol_ok": False},
|
||||
},
|
||||
)
|
||||
)
|
||||
continue
|
||||
llm = {}
|
||||
if (
|
||||
self.settings.llm_advisor_enabled
|
||||
@@ -211,6 +228,17 @@ class CryptoSpotBot:
|
||||
prices,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _risk_guard_for_symbol(risk_guard: dict, symbol: str) -> dict:
|
||||
rows = risk_guard.get("symbols")
|
||||
if not isinstance(rows, list):
|
||||
return {}
|
||||
symbol_upper = symbol.upper()
|
||||
for row in rows:
|
||||
if isinstance(row, dict) and str(row.get("symbol", "")).upper() == symbol_upper:
|
||||
return row
|
||||
return {}
|
||||
|
||||
def _with_exposure_context(self, rules: dict) -> dict:
|
||||
enriched = dict(rules)
|
||||
current_exposure = self.broker.exposure()
|
||||
|
||||
Reference in New Issue
Block a user