1
This commit is contained in:
1 parent
2ea1a79bda
commit
85425483c0
50 files changed
+6468
-1854
No files matched your search
@@ -0,0 +1,74 @@
|
||||
"""Desktop account and per-symbol state, independent of Tk widgets."""
|
||||
from __future__ import annotations
|
||||
from collections import deque
|
||||
from dataclasses import dataclass, field
|
||||
import strategy
|
||||
|
||||
@dataclass
|
||||
class Position:
|
||||
trade_id: int
|
||||
symbol: str
|
||||
entry_price: float
|
||||
qty: float
|
||||
stake: float
|
||||
entry_fee: float
|
||||
opened_at: float
|
||||
last_add_price: float
|
||||
add_count: int = 0
|
||||
# Strategy-mode fields; classic positions keep the defaults.
|
||||
side: str = "long"
|
||||
mode: str = strategy.STRATEGY_CLASSIC
|
||||
leverage: float = 1.0
|
||||
stop_price: float = 0.0
|
||||
initial_stop: float = 0.0
|
||||
atr: float = 0.0
|
||||
extreme: float = 0.0
|
||||
partial_target: float = 0.0 # 0 = none
|
||||
final_target: float = 0.0 # 0 = none
|
||||
partial_done: bool = False
|
||||
realized_gross: float = 0.0
|
||||
realized_fees: float = 0.0
|
||||
opened_stake: float = 0.0
|
||||
|
||||
|
||||
@dataclass
|
||||
class ClosedTrade:
|
||||
trade_id: int
|
||||
symbol: str
|
||||
entry_price: float
|
||||
exit_price: float
|
||||
qty: float
|
||||
gross_pnl: float
|
||||
fees: float
|
||||
net_pnl: float
|
||||
roi_pct: float
|
||||
opened_at: float
|
||||
closed_at: float
|
||||
reason: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class CurrencyState:
|
||||
"""Independent market and position state for one concurrently traded symbol."""
|
||||
prices: deque = field(default_factory=deque)
|
||||
candles: deque = field(default_factory=deque)
|
||||
entry_markers: deque = field(default_factory=deque)
|
||||
last_price: float | None = None
|
||||
baseline_close: float | None = None
|
||||
last_signal_pct: float | None = None
|
||||
last_signal_ready: bool = False
|
||||
previous_entry_signal_pct: float | None = None
|
||||
live_minute_prices: deque = field(default_factory=deque)
|
||||
last_ws_message: float = 0.0
|
||||
position: Position | None = None
|
||||
live_position: Position | None = None
|
||||
live_position_info: dict | None = None
|
||||
live_order_busy: bool = False
|
||||
live_transition_pending: bool = False
|
||||
live_halted: bool = False
|
||||
# Strategy modes A/B: last evaluated signal candle and the signal valid until the next close.
|
||||
mode_signal: dict | None = None
|
||||
mode_signal_bucket: int = 0
|
||||
mode_eval_busy: bool = False
|
||||
|
||||
|
||||
Reference in new issue
Block a user