Grid: заменить basket-stop локальным symbol+side loss control #505

Merged
andrei merged 1 commit from fix/grid-local-loss-control into master 2026-07-21 18:17:19 +00:00
Owner

Fixes #504

Thinking Path

Редкие side-wide basket-stop события закрывали независимые Grid legs и создавали хвостовые убытки. Решение локализует контроль до точного symbol+side и не останавливает торговлю остальных legs.

What Changed

  • Порог каждой позиции: max($0.50, 0.5% от position notional).
  • Закрывается только breaching Grid leg конкретного symbol+side.
  • Перед закрытием отменяются только expanding non-reduce-only orders этой стороны и символа; ошибка отмены блокирует close.
  • Opposite side, другие symbols и reduce-only orders не затрагиваются.
  • Re-entry latch снимается только новым favourable regime confirmation, сохраняется в DB runner_state и переживает restart.
  • Hedge-only recovery получает явный bounded bypass.
  • Ownership protection теперь scoped по symbol+side.

Verification

  • Full backend: 7370 passed, 7 skipped.
  • Grid/related: 584 passed.
  • py_compile: passed.
  • git diff --check: passed.
  • diff-scoped gitleaks: no leaks found.

Risks

  • Изменяет live loss-control behavior; operator enable switches сохранены.
  • Фактическое live-event поведение будет проверено после controlled deploy.

Model Used

  • gpt-5.6-sol

Checklist

  • I searched the GitHub PR list for similar PRs and confirmed this is not a duplicate
  • Scope ограничен issue #504; attribution/dedup не смешаны
  • Full tests и security scan пройдены
Fixes #504 ## Thinking Path Редкие side-wide basket-stop события закрывали независимые Grid legs и создавали хвостовые убытки. Решение локализует контроль до точного symbol+side и не останавливает торговлю остальных legs. ## What Changed - Порог каждой позиции: max($0.50, 0.5% от position notional). - Закрывается только breaching Grid leg конкретного symbol+side. - Перед закрытием отменяются только expanding non-reduce-only orders этой стороны и символа; ошибка отмены блокирует close. - Opposite side, другие symbols и reduce-only orders не затрагиваются. - Re-entry latch снимается только новым favourable regime confirmation, сохраняется в DB runner_state и переживает restart. - Hedge-only recovery получает явный bounded bypass. - Ownership protection теперь scoped по symbol+side. ## Verification - Full backend: 7370 passed, 7 skipped. - Grid/related: 584 passed. - py_compile: passed. - git diff --check: passed. - diff-scoped gitleaks: no leaks found. ## Risks - Изменяет live loss-control behavior; operator enable switches сохранены. - Фактическое live-event поведение будет проверено после controlled deploy. ## Model Used - gpt-5.6-sol ## Checklist - [x] I searched the GitHub PR list for similar PRs and confirmed this is not a duplicate - [x] Scope ограничен issue #504; attribution/dedup не смешаны - [x] Full tests и security scan пройдены
fix(grid): scope loss control to local legs
All checks were successful
Arnold Forgejo CI / backend-tests (pull_request) Successful in 5m21s
Arnold Forgejo CI / frontend-audit (pull_request) Successful in 18s
Arnold Forgejo CI / secret-scan (pull_request) Successful in 3s
Forgejo Smoke Test / Smoke (pull_request) Successful in 1s
d17a8fbb5e
andrei merged commit 6dda323da6 into master 2026-07-21 18:17:19 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
europa-tech-srl/arnold-trader-app!505
No description provided.