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

+42 -13
View File
@@ -88,19 +88,48 @@ real time (well under a second), unlike GeckoTerminal's 1–2 minute delay. «С
USDⓈ-M `bookTicker` (`fstream…/public/stream`) as a one-level book and `aggTrade` (`…/market/stream`) as trades; the
paper fees stay Bybit's (0.055% taker / 0.02% maker; Binance's are 0.05% / 0.02%).
**Web interface** (`py -3 web_sim.py` or `run_web_sim.bat` → http://127.0.0.1:8765, opens in the browser): every
coin of the connection list runs at the same time with its own feeds, its own paper account and journal
(`web_sim_data/<coin>.json/.csv`) and its own Start/Stop (a new coin starts stopped; Stop only forbids new entries).
Top: the common trade settings («Применить ко всем монетам», saved in `web_sim_data/settings.json`; the first start
copies the Tk window's). Left: coin tiles (green dot = trading, open positions, price, result). Centre: a chart of both
exchanges' prices as % change over the last 1/5/10 minutes with entry/exit markers, the coin's statistics, Start/Stop,
«Закрыть все позиции», and the trade table — open positions on top in yellow with ✕ (close that one at the current
price), then closed trades, newest first. Tiles also show the win rate. The last tile «+» opens the **scanner panel**:
start/stop of the autonomous search (meme_matcher/autoscan.py, runs in the background), its log, and the coins it
checked (how often the DEX led, the latest figures); «+ Добавить» puts a coin where the DEX led into the left panel
(stopped, ready to test) when its pool and futures are supported. «Добавлять найденные автоматически» lets the search
add them by itself (off by default; meme_matcher/autoscan_config.json). Coins added to the list appear within 30 s. The Tk window
(`py -3 scalp_hint.py`) keeps its own separate account.
**Web interface** (`py -3 web_sim.py` or `run_web_sim.bat` → [local page](http://127.0.0.1:8765), opens in the
browser): every coin has its own feeds, trade history and Start/Stop. A new coin starts stopped; Stop forbids
new entries while existing positions remain managed. All paper coins in «Симулятор» and «Арбитраж → Симуляция»
use **one virtual account**, persisted in `web_sim_data/virtual_account.json`. The Tk window
(`py -3 scalp_hint.py`) and the main desktop application keep their separate accounts.
The «Общий виртуальный счёт» panel shows balance, equity, reserved capital and free capital. Enter a positive
amount and click «Пополнить» to add it or «Списать» to subtract it; the journal shows recent operations newest
first. These are virtual adjustments, not exchange transfers, and do not change the recorded trading result.
Free capital is `max(0, min(balance, equity) - reserved)`: unrealized profits cannot fund another entry, while
unrealized losses reduce the available amount. Every paper entry must fit the shared capital limit, including
its reserve and fees. Withdrawals cannot exceed free capital and are refused if an open position's valuation
is older than 30 seconds. Deposits remain available with a working connection. The initial deposit comes once
from the old common budget (default 300 $); initial balances of individual coins are not added together.
Open paper positions, their reserved capital and strategy exit state survive a restart. The shared account
snapshot is authoritative for the attached coin and paper-arbitrage engines; old closed trades remain available
as history. Restored valuations remain stale until fresh quotes arrive. «Сбросить статистику» does not replenish
the virtual account and is refused while the selected engine has open positions or unfinished real execution.
Changing a coin between simulation and real trading also requires both modes to be free of open positions and
unfinished orders. Real mode uses a **separate private signal ledger**, not the common virtual wallet: virtual
top-ups, withdrawals and paper profits cannot change real order sizing or allow real entries. Exchange balances
and the real execution gate determine whether those orders can be sent.
The top status bar distinguishes the selected mode from connection health. A failed initial request is retried
by the read polling loop; missing or stale server data disables commands until reconnection. Submitted trading
commands are never automatically retried. The separate «Справка» button opens a searchable reference covering
terms, every exposed setting, strategy modes, account controls, API keys, the scanner and the budget calculator.
Common coin settings are applied with «Применить ко всем монетам» and stored in `web_sim_data/settings.json`;
the first start copies the Tk window's settings. The former editable per-coin budget is replaced by the shared
account controls. Arbitrage simulation and real trading retain separate settings and unsaved drafts when
switching between them in the current browser page. Coin tiles show the trading status, open positions, price,
result and win rate. The centre shows both prices as percentage changes over 1/5/10 minutes, entry/exit markers,
the selected coin's statistics, Start/Stop, «Закрыть все позиции» and the trade table. Open positions appear in
yellow with a close button; closed trades follow newest first.
The last tile «+» opens the **scanner panel**: start/stop of `meme_matcher/autoscan.py`, its log and checked coins.
«+ Добавить» adds a supported pool/futures pair stopped and ready to test. «Добавлять найденные автоматически»
allows automatic additions (off by default; `meme_matcher/autoscan_config.json`); new connections appear within
30 seconds. Removing a pair first stops new entries and requests closing its exposure. If execution or recovery
is unfinished, the connection stays available for management; the removal intent survives restart.
**Live leader check** (`require_leader`, on by default, all lead modes): the policy samples both prices every 0.5 s
and every 10 s measures, over up to the last 20 minutes, the positive correlations of price changes with the follower