Stage 07.4.3.3 — Paper Position & Execution Engineg

This commit is contained in:
2026-05-03 07:45:07 +03:00
parent bd6b40fcb2
commit 24c910fade
8 changed files with 398 additions and 8 deletions

View File

@@ -13,6 +13,17 @@ class TrendStrategy:
_last_prices: dict[str, float] = {}
_threshold_percent = 0.02
# рассчитать уверенность сигнала по силе движения цены
def _calculate_confidence(self, change_percent: float) -> float:
strength = abs(change_percent) / self._threshold_percent
if strength < 1:
return 0.0
confidence = 0.35 + ((strength - 1) / 2) * 0.65
return round(min(1.0, confidence), 2)
# анализ простого тренда по изменению цены
def analyze(self, context: StrategyContext) -> SignalResult:
try:
@@ -53,7 +64,7 @@ class TrendStrategy:
return SignalResult(
signal=SignalType.BUY,
reason="Цена растёт выше порога тренда.",
confidence=min(1.0, abs(change_percent) / self._threshold_percent),
confidence=self._calculate_confidence(change_percent),
payload={
"strategy": self.name,
"symbol": symbol,
@@ -67,7 +78,7 @@ class TrendStrategy:
return SignalResult(
signal=SignalType.SELL,
reason="Цена падает ниже порога тренда.",
confidence=min(1.0, abs(change_percent) / self._threshold_percent),
confidence=self._calculate_confidence(change_percent),
payload={
"strategy": self.name,
"symbol": symbol,