46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
from web_core.constants import TREND_BEAR, TREND_BULL
|
|
|
|
|
|
def build_live_decision_guide(
|
|
trend_now: str,
|
|
previous_trend: str,
|
|
latest_classification: str,
|
|
) -> dict[str, str]:
|
|
if trend_now == TREND_BULL:
|
|
bias = "Long Bias"
|
|
action = "Prefer pullback longs and avoid fresh shorts while the bullish trend remains active."
|
|
invalidation = "Bullish bias is invalidated only after 2 consecutive real bearish bars confirm a reversal."
|
|
elif trend_now == TREND_BEAR:
|
|
bias = "Short Bias"
|
|
action = "Prefer short setups on pops and avoid fresh longs while the bearish trend remains active."
|
|
invalidation = "Bearish bias is invalidated only after 2 consecutive real bullish bars confirm a reversal."
|
|
else:
|
|
bias = "Stand Aside / Neutral"
|
|
action = "Wait for 2 consecutive real bars in one direction before taking directional exposure."
|
|
invalidation = "No active trend yet; avoid forcing trades in noisy ranges."
|
|
|
|
if trend_now in {TREND_BULL, TREND_BEAR} and trend_now != previous_trend:
|
|
confirmation = "Fresh Confirmation"
|
|
confirmation_detail = "Latest closed bar confirmed a new active trend."
|
|
else:
|
|
confirmation = "No New Confirmation"
|
|
confirmation_detail = "Latest closed bar did not confirm a new trend reversal."
|
|
|
|
classification_hint = {
|
|
"real_bull": "Latest bar closed above the previous range.",
|
|
"real_bear": "Latest bar closed below the previous range.",
|
|
"fake": "Latest bar stayed inside the previous range (noise).",
|
|
"unclassified": "Latest bar is unclassified.",
|
|
}.get(latest_classification, "Latest bar classification unavailable.")
|
|
|
|
return {
|
|
"bias": bias,
|
|
"action": action,
|
|
"invalidation": invalidation,
|
|
"confirmation": confirmation,
|
|
"confirmation_detail": confirmation_detail,
|
|
"classification_hint": classification_hint,
|
|
}
|