07.4.4.1.11 — Advanced Trend Quality & EMA Distance Layer
This commit is contained in:
@@ -4,6 +4,8 @@ from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
from typing import Any
|
||||
|
||||
from src.integrations.exchange.service import ExchangeService
|
||||
from src.trading.market_analysis.models import (
|
||||
MarketPhase,
|
||||
@@ -133,8 +135,16 @@ class TrendStrategy:
|
||||
"market_phase_change_percent": market.phase_change_percent,
|
||||
"market_phase_direction_consistency": market.payload.get("market_phase_direction_consistency"),
|
||||
"market_phase_reason": market.phase_reason,
|
||||
"momentum_state": market.momentum_state.value,
|
||||
"momentum_direction": market.momentum_direction.value,
|
||||
"momentum_state": (
|
||||
market.momentum_state.value
|
||||
if market.momentum_state is not None
|
||||
else "UNKNOWN"
|
||||
),
|
||||
"momentum_direction": (
|
||||
market.momentum_direction.value
|
||||
if market.momentum_direction is not None
|
||||
else "UNKNOWN"
|
||||
),
|
||||
"momentum_change_percent": market.momentum_change_percent,
|
||||
"momentum_strength": market.momentum_strength,
|
||||
"breakout_level": market.breakout_level,
|
||||
@@ -381,8 +391,12 @@ class TrendStrategy:
|
||||
confidence = 0.55 + (strength_score * 0.35)
|
||||
|
||||
return round(min(0.95, confidence), 2)
|
||||
|
||||
def _analysis_price(self, snapshot: dict[str, object]) -> float:
|
||||
|
||||
|
||||
def _analysis_price(
|
||||
self,
|
||||
snapshot: dict[str, Any],
|
||||
) -> float:
|
||||
bid = self._safe_float(snapshot.get("bid_price"))
|
||||
ask = self._safe_float(snapshot.get("ask_price"))
|
||||
|
||||
@@ -395,7 +409,10 @@ class TrendStrategy:
|
||||
|
||||
return 0.0
|
||||
|
||||
def _safe_float(self, value: object) -> float | None:
|
||||
def _safe_float(
|
||||
self,
|
||||
value: float | int | str | None,
|
||||
) -> float | None:
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user