feat: добавить общий виртуальный счёт, справку и восстановление позиций
Offline regression tests / windows (3.11) (push) Canceled after 0s
Offline regression tests / windows (3.12) (push) Canceled after 0s
Offline regression tests / windows (3.13) (push) Canceled after 0s

This commit is contained in:
Igol committed 2026-10-22 23:07:50 +03:00
1 parent 6aa76064dc
commit c5aed5b970
29 files changed
+3600 -224

No files matched your search

+13 -3
View File
@@ -8,8 +8,8 @@ whose real order did not go through is closed at once, so paper and real trades
Results (prices, fees) are the exchange's own fills; `exact` is False where the exchange did not report a figure.
- the tab-wide switch is in web_sim_data/real_simulator.json; it gates new trades only — an open real trade is
always closed with its paper twin;
- real positions are saved (web_sim_data/real_positions_<coin>.json); paper positions do not survive a restart, so
a saved real position is closed right after a restart («осиротевшая»);
- real positions are saved (web_sim_data/real_positions_<coin>.json); a saved real position is conservatively
closed right after a restart («осиротевшая»), independently of the restored paper account;
- every order and every error goes to web_sim_data/real_orders.jsonl (journal on the page).
"""
@@ -108,7 +108,7 @@ def save_settings(values: dict) -> str:
if values.get("reset_stats"):
c["since"] = time.time()
DATA_DIR.mkdir(exist_ok=True)
SETTINGS_FILE.write_text(json.dumps(s), encoding="utf-8")
atomic_write_json(SETTINGS_FILE, s)
return ""
@@ -324,6 +324,16 @@ class FuturesMirror:
elif event == "close" and self.position and self.position.get("uid") == pos.uid:
self.jobs.put(("close", "закрыта в симуляторе"))
def request_close(self, reason: str = "удаление подключения") -> None:
"""Also close a recovered real position whose paper twin no longer exists."""
with self.lock:
if self.position and self.state not in ("recover", "blocked"):
self.jobs.put(("close", reason))
def ready_to_remove(self) -> bool:
with self.lock:
return self.position is None and self.state == "" and not self.storage_error and self.jobs.empty()
# --- worker ------------------------------------------------------------------------------------------------
WATCH_S = 1.0 # while a real position is open: how often to ask the exchange whether TP/SL closed it