Skip to content

feat: Per-account mode flag with dynamic risk rule routing#785

Merged
dantelrharrell-debug merged 3 commits intomainfrom
copilot/add-per-account-mode-flag
Feb 21, 2026
Merged

feat: Per-account mode flag with dynamic risk rule routing#785
dantelrharrell-debug merged 3 commits intomainfrom
copilot/add-per-account-mode-flag

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

Replace the multi-service pattern with a single service that routes risk rules per account via a mode flag in each account's config file — the standard prop-firm approach to multi-account management.

New: bot/account_mode_manager.py

  • AccountMode enum: normal | recovery | conservative | aggressive | paused
  • ModeRiskOverrides dataclass maps each mode to specific limit overrides (position size, daily loss cap, trade count, entry gate)
  • AccountModeManager applies overrides at runtime without restart; registered as a module-level singleton

Config changes

Each user JSON now carries a mode field:

{ "account": "daivon", "mode": "recovery" }

IndividualUserConfigLoader registers the mode with AccountModeManager on load.

Risk enforcement (bot/user_risk_manager.py)

  • UserRiskLimits gains allow_new_entries: bool field
  • get_limits() returns a copy of base limits with mode overrides applied — base is never mutated, so runtime mode changes take effect immediately
  • can_trade() checks allow_new_entries first; recovery and paused modes block new entries before any other check

Mode → risk rule table

Mode New entries Max position Max daily trades Circuit breaker
normal 20% (default) 20 3%
recovery 5% 5 2%
conservative 10% default 2%
aggressive 30% 30 5%
paused 0

Backward compatibility

UserRiskLimits.from_dict() now strips unknown keys, so existing persisted risk state files without allow_new_entries load cleanly.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@railway-app railway-app bot temporarily deployed to patient-compassion / Nija-pr-785 February 21, 2026 12:37 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 21, 2026

🚅 Deployed to the Nija-pr-785 environment in patient-compassion

Service Status Web Updated (UTC)
Nija ✅ Success (View Logs) Feb 21, 2026 at 12:47 pm

- New bot/account_mode_manager.py: AccountMode enum (normal/recovery/
  conservative/aggressive/paused), ModeRiskOverrides dataclass, and
  AccountModeManager that applies risk overrides per mode at runtime
- config/individual_user_loader.py: add 'mode' field to IndividualUserConfig;
  registers mode with global AccountModeManager on config load
- bot/user_risk_manager.py: add allow_new_entries to UserRiskLimits;
  get_limits() now applies mode overrides on a copy of base limits;
  can_trade() gates new entries when mode is recovery/paused
- config/users/daivon_frazier.json: set mode=recovery
- config/users/tania_gilbert.json: set mode=normal
- test_account_mode_manager.py: 34 tests covering all modes

Co-authored-by: dantelrharrell-debug <232652186+dantelrharrell-debug@users.noreply.github.com>
@railway-app railway-app bot temporarily deployed to patient-compassion / Nija-pr-785 February 21, 2026 12:46 Destroyed
…gitignore

Co-authored-by: dantelrharrell-debug <232652186+dantelrharrell-debug@users.noreply.github.com>
@railway-app railway-app bot temporarily deployed to patient-compassion / Nija-pr-785 February 21, 2026 12:46 Destroyed
Copilot AI changed the title [WIP] Add per-account mode flag for dynamic risk rules feat: Per-account mode flag with dynamic risk rule routing Feb 21, 2026
@dantelrharrell-debug dantelrharrell-debug marked this pull request as ready for review February 21, 2026 12:49
@dantelrharrell-debug dantelrharrell-debug merged commit f14b7be into main Feb 21, 2026
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants