[FEATURE] Paper mode in hub: blue palette, banner, sample runner - closes #86 #87#90
Conversation
ddf2a56 to
bf03ad8
Compare
Manual Testing Guide — PR #90: Paper Trading Demo ScriptPrerequisitesgit fetch fork && git checkout feat/87-paper-trading-demo
cd app1. Run the demopython pt_paper_trading_demo.pyExpected: Script runs to completion without errors. Should print a summary of simulated trades, account balance, P&L. 2. Verify it does not touch live APIsCheck output for any Robinhood/Binance connection attempts — there should be none. All prices come from 3. Sanity check output
Rollbackgit checkout main -- app/pt_paper_trading_demo.py |
|
Nice idea @Ibrahim-3d - The paper trading system existed beforehand; i've just never needed to test/demo it. I think the demo should use the same UI, personally. Don't think it massively matters. |
|
@sjackson0109 yeah you're right, demo should live in the hub. Closing this in favour of doing it properly there. One thing though — "sensible traders manage their own risk" assumes the user already knows what they're doing. I'm honestly not in that bucket yet, and a few friends I've shown this to aren't either. We'd want to watch it run on paper for a bit before pointing it at real money. The "Paper" label is the trust signal — "just use small sizes" doesn't really replace it for newcomers. Plus it's useful for us: every time we touch So proposing:
Sound good? Happy to close this PR and open a new one against |
|
Going to pivot this PR — keep the live-price + full buy/sell scenario, but wire it into the hub's Paper mode as a "Run sample" button instead of a standalone script. That way the demo lives behind the actual UI like you suggested, and we get rid of the duplicate Will force-push to this branch once it's ready. |
|
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. |
|
I see no reason to close/cancel this PR, or just pivot, up to you. |
…r (#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.
|
Pivoted into #97 per the discussion above (@sjackson0109's spec: blue palette, PAPER TRADING label in trades section, file-menu toggle). The live BTC + buy/sell scenario now lives behind a Will close this PR once #97 is merged so the standalone script does not get re-introduced. |
5202c00 to
ffa282d
Compare
|
Force-pushed the pivot. Standalone |
CI on Python 3.12 surfaced that the MarketDataSimulator's per-call +-0.5% random drift compounds across the multiple get_current_price() calls inside place_order (risk check + cost estimate + execution) plus the matching pair on the sell side. The original 500 USD delta was tight enough that random seeds on the runner could push the buy fill just past it. Loosen to 5 percent of the seeded price (about 3800 USD on the 76k seed) so the assertion still proves the price tracks the live feed without being seed-sensitive. The round-trip balance check moves from <5 USD to <20 USD for the same reason - drift dominates over commission at this notional.
|
Now that #97 has been merged into development branch - can we cancel this PR? @Ibrahim-3d |
|
@sjackson0109 Small correction: #97 was closed, not merged, |
Manual QA guide - Paper Mode (#90)Manual walkthrough to validate this PR before merge. Covers the File-menu toggle, blue palette + banner, persistence, and the sample-trade runner (Binance live + simulator fallback). Prerequisites
T1 - Toggle paper mode on
T2 - Visual safety cues
T3 - Persistence across restart
T4 - Sample trade, live Binance price (happy path)
T5 - Sample trade, offline fallback (simulator)
T6 - Toggle paper mode off
T7 - Corrupt/missing settings (negative)
Pass checklist
Automated backstop
|
|
@Ibrahim-3d has transitioned paper-trading-mode from CLI based to GUI based, with a new blue background to help clearly distinguish between the two modes. This is an increadible achievement in such a short timeframe. |
Summary
Pivoted per the discussion below: kept the live-price buy/sell scenario but moved it behind a button inside the hub, plus the visual safety rails @sjackson0109 asked for.
Paper Modecheckbutton; selection persists ingui_settings.jsonPAPER TRADINGbanner across the top + contrasting label inside 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.pyscriptdemo_paper_trading()stub at the bottom ofpt_paper_trading.pyCloses #86 and #87.
Why this looks like a different PR
Force-pushed to replace the original standalone-script commit with the in-hub integration per the pivot agreement above. Older PR diff is gone from the file list - history is now one commit on top of
main.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 andoption_addclassic-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