[FEATURE] Paper mode in hub: blue palette, banner, sample runner - closes #86#97
Closed
Ibrahim-3d wants to merge 1 commit into
Closed
[FEATURE] Paper mode in hub: blue palette, banner, sample runner - closes #86#97Ibrahim-3d wants to merge 1 commit into
Ibrahim-3d wants to merge 1 commit into
Conversation
#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.
4 tasks
Collaborator
Author
|
Closing - work belongs on the existing PR #90 branch per author. Cherry-picking the commit there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires paper trading into the hub UI per @sjackson0109's feedback on #90 and the pivot proposed there.
Paper Modecheckbutton; selection persists ingui_settings.jsonPAPER TRADINGbanner across the top + contrasting label in the Current Trades panelRun sample tradebutton that pulls a live BTC price from Binance's public ticker and routes a simulated buy then sell throughPaperTradingAccountdemo_paper_trading()stub frompt_paper_trading.pySupersedes #90 (the standalone demo script approach) and closes #86.
Why this pivot
From #90 conversation:
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
app/pt_paper_mode.pyowns the palette, banner widget, sample runner, and disk-read helper. Keepspt_hub.pyedits surgical (~190 lines added, all isolated to the menu/theme entry points)._apply_forced_dark_modecall so the window does not flash dark before settling on blue.Restart for full effectnotice 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.Files
app/pt_paper_mode.pyapp/pt_hub.pyapp/pt_paper_trading.pydemo_paper_trading()stubapp/test_paper_mode.pyLocal 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,W503cleanpython -m flake8 app/pt_hub.py --select=E9,F63,F7,F82clean (hard-error gate)python -m pytest app/test_paper_mode.py app/test_paper_trading_integration.py -q-> 22 passedTest plan
File > Paper Modeoff then on - checkgui_settings.jsonflips and a restart paints blue with banner + Current Trades labelRun sample tradewith internet on - banner shows live BTC, buy/sell delta is small (commission + drift)Run sample tradewith internet off - banner showsoffline (using sim), trade still fills via simulator