Skip to content

[FEATURE] Paper mode in hub: blue palette, banner, sample runner - closes #86#97

Closed
Ibrahim-3d wants to merge 1 commit into
mainfrom
feat/86-paper-mode-hub
Closed

[FEATURE] Paper mode in hub: blue palette, banner, sample runner - closes #86#97
Ibrahim-3d wants to merge 1 commit into
mainfrom
feat/86-paper-mode-hub

Conversation

@Ibrahim-3d

Copy link
Copy Markdown
Collaborator

Summary

Wires paper trading into the hub UI per @sjackson0109's feedback on #90 and the pivot proposed there.

  • File menu gains a Paper Mode checkbutton; selection persists in gui_settings.json
  • Paper mode paints the hub with a blue palette instead of black
  • PAPER TRADING banner across the top + contrasting label in the Current Trades panel
  • Banner hosts a Run sample trade button that pulls a live BTC price from Binance's public ticker and routes a simulated buy then sell through PaperTradingAccount
  • Drops the duplicate standalone demo_paper_trading() stub from pt_paper_trading.py

Supersedes #90 (the standalone demo script approach) and closes #86.

Why this pivot

From #90 conversation:

sjackson0109: "How about we consider paper mode changes the CSS of the background. Say BLUE instead of BLACK. So it is blatantly obvious which mode we are in. And in the trading section, add the words 'PAPER TRADING'. In a contrasting font colour. The file menu should have the 'paper mode' toggle button."

The standalone script in #90 worked but lived outside the hub, so newcomers had to know about the CLI. This PR moves the same scenario behind a button inside the hub and adds the visual safety rails (blue palette + banner + label) so it is impossible to confuse paper mode for live trading.

Implementation notes

  • New module app/pt_paper_mode.py owns the palette, banner widget, sample runner, and disk-read helper. Keeps pt_hub.py edits surgical (~190 lines added, all isolated to the menu/theme entry points).
  • Paper-mode flag is read straight off disk before the first _apply_forced_dark_mode call so the window does not flash dark before settling on blue.
  • The toggle shows a Restart for full effect notice because matplotlib chart facecolors and option_add classic-widget defaults are baked at widget-creation time. Banner and trades-section label toggle live without restart.
  • Binance fetch is a 5s public GET with a deterministic fallback path; tests cover happy/missing-key/network-error paths and the buy/sell scenario with and without a live price.

Files

File Change
app/pt_paper_mode.py new - palette, banner, sample runner, persistence helper
app/pt_hub.py settings key, settings-load reorder, palette overlay branch, file-menu toggle, banner build, trades-section label, sample-runner handler
app/pt_paper_trading.py removed duplicate async demo_paper_trading() stub
app/test_paper_mode.py new - 14 tests covering palette mirror, disk round-trip, fetch happy/error paths, sample runner with live price + fallback

Local checks

  • python -m black --check app/ clean (102 files unchanged)
  • python -m flake8 app/pt_paper_mode.py app/test_paper_mode.py --max-line-length=100 --extend-ignore=E203,W503 clean
  • python -m flake8 app/pt_hub.py --select=E9,F63,F7,F82 clean (hard-error gate)
  • python -m pytest app/test_paper_mode.py app/test_paper_trading_integration.py -q -> 22 passed

Test plan

  • Toggle File > Paper Mode off then on - check gui_settings.json flips and a restart paints blue with banner + Current Trades label
  • Click Run sample trade with internet on - banner shows live BTC, buy/sell delta is small (commission + drift)
  • Click Run sample trade with internet off - banner shows offline (using sim), trade still fills via simulator
  • Toggle paper mode off mid-session - banner and label disappear immediately, restart prompt shown

#86)

Wires paper trading into the hub per the PR #90 owner feedback:

- File menu gains a "Paper Mode" checkbutton toggle so users can switch
  without touching the CLI. Selection persists across restarts via
  gui_settings.json.
- When paper mode is on, the hub paints a blue palette instead of the
  default dark/black one and shows a "PAPER TRADING" banner across the
  top plus a contrasting label in the Current Trades panel so the user
  cannot mistake the session for live trading.
- The banner hosts a "Run sample trade" button that fetches a live BTC
  price from Binance's public ticker endpoint and routes a simulated
  buy then sell through PaperTradingAccount. Falls back to the existing
  MarketDataSimulator when Binance is unreachable.
- Removes the duplicate async demo_paper_trading() stub from
  pt_paper_trading.py - the in-hub button supersedes it.

Implementation isolates Tk/palette/runner helpers in a new pt_paper_mode
module so pt_hub.py changes stay surgical (~190 lines of additions, no
existing logic touched outside the menu/theme entry points).

Tests cover palette mirroring, settings disk round-trip (including
missing/garbage files), Binance ticker happy path + failure modes, and
the buy/sell scenario both with a live price and the simulator
fallback. 22 tests pass locally.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Ibrahim-3d

Copy link
Copy Markdown
Collaborator Author

Closing - work belongs on the existing PR #90 branch per author. Cherry-picking the commit there.

@Ibrahim-3d Ibrahim-3d closed this May 23, 2026
@Ibrahim-3d Ibrahim-3d deleted the feat/86-paper-mode-hub branch May 23, 2026 15:51
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.

[BUG] Paper trading reports 'not implemented' in pt_integration.py despite PaperTradingAccount existing

2 participants