07.4.3.14 — Auto Trading UI. Realistic Pricing & Debug Live Tools
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
from src.core.config import load_settings
|
||||
@@ -49,6 +50,9 @@ class AutoTradeService:
|
||||
|
||||
previous_signal = state.last_signal
|
||||
previous_decision_status = state.decision_status
|
||||
|
||||
if previous_signal != normalized_signal or state.signal_started_at is None:
|
||||
state.signal_started_at = time.monotonic()
|
||||
|
||||
state.last_signal = normalized_signal
|
||||
state.last_signal_repeat_count = repeat_count
|
||||
@@ -85,6 +89,18 @@ class AutoTradeService:
|
||||
|
||||
return state
|
||||
|
||||
# установить капитал, выделенный под автоторговлю
|
||||
def set_allocated_balance_usd(self, value: float) -> AutoTradeState:
|
||||
state = self.get_state()
|
||||
|
||||
if value <= 0:
|
||||
value = 1000.0
|
||||
|
||||
state.allocated_balance_usd = value
|
||||
state.execution_block_reason = None
|
||||
state.execution_size_adjustment_reason = None
|
||||
return state
|
||||
|
||||
# получить текущее состояние автоторговли
|
||||
def get_state(self) -> AutoTradeState:
|
||||
if not self._state.symbol:
|
||||
@@ -264,6 +280,7 @@ class AutoTradeService:
|
||||
state.is_signal_confirmed = False
|
||||
state.is_signal_ready = False
|
||||
state.execution_block_reason = None
|
||||
state.signal_started_at = None
|
||||
|
||||
# собрать контекст для стратегии
|
||||
def _build_strategy_context(self) -> StrategyContext:
|
||||
@@ -397,6 +414,9 @@ class AutoTradeService:
|
||||
previous_signal = state.last_signal
|
||||
previous_decision_status = state.decision_status
|
||||
|
||||
if previous_signal != signal or state.signal_started_at is None:
|
||||
state.signal_started_at = time.monotonic()
|
||||
|
||||
state.last_signal = signal
|
||||
state.last_signal_repeat_count = self._same_signal_count
|
||||
state.last_signal_confidence = confidence
|
||||
|
||||
Reference in New Issue
Block a user