OnPaper - Automated Scalps walkthrough

Walkthrough - 30-Second Momentum Scalper Simulator & Dashboard Tab

⛔ RETIRED 2026-08-11 — do not rebuild from this page

The strategy was measured and does not work. See Finding 20 for the numbers: the trailing stop caused 91% of Scenario 2 exits while the designed momentum-collapse exit fired 9% of the time, and both scenarios were net negative. The trail distance is smaller than SOXL’s noise at that timescale, and a better data feed would not fix it.

Everything below describes infrastructure that no longer exists:

This page says Reality since 2026-08-11
⚡ 30s Scalper dashboard tab removed from index.html
/api/paper_30s_scalper endpoint removed from dashboard_server.py
get_paper_30s_scalper_payload() removed
cron lines to start 06:30 / pkill 13:00 were never installed — it was always run by hand

paper_30s_scalper.py still exists, carries a RETIRED banner, and is kept only for its data and its QUOTE FRESHNESS instrumentation — which is genuinely reusable and diagnosed this failure unprompted. paper_30s_scalper_trades.csv (3,892 rows) is the evidence; do not delete it.

Kept as a record of how the thing was built, and because the negative result is worth more than a deleted page.

We have implemented the 30-second momentum scalper paper simulator and integrated a new dedicated ⚡ 30s Scalper tab into your live trading dashboard (http://localhost:8080).


🛠️ Summary of Changes

1. Dual-Scenario Paper Simulator Engine

[NEW] paper_30s_scalper.py

  • Scenario #1 (Standard 3.0s Polling): Aggregates 30-second OHLCV candles, tracks rolling 30s VWAP and 30s MACD slope, and executes $10.00 paper positions with a $0.25 trailing stop and $0.02 slippage penalty.
  • Scenario #2 (Ultra-Fast 1.0s Polling): Pushes polling speed to 1.0s to measure API rate limits and execution speed. Uses 15s/30s momentum triggers with a tight $0.15 trailing stop and tracks live API response latency.
  • State & Logging: Outputs strict JSON state to paper_30s_scalper_state.json and logs executed trades to paper_30s_scalper_trades.csv.

[!IMPORTANT] Technical Clarification: Polling Frequency vs. 30s Bars

  • Query Frequency (1s / 3s): Live quotes are fetched every 1.0s (Scenario 2) or 3.0s (Scenario 1). Exits and trailing stops DO NOT wait 30 seconds to react — they evaluate on every single 1s/3s tick.
  • In-Memory 30s Bars: 30-second bar aggregation occurs solely in-memory to compute rolling indicators (VWAP, MACD slope) without reacting to sub-second noise.

2. Dashboard Server & Web API

[MODIFY] dashboard_server.py

  • Added get_paper_30s_scalper_payload() helper to parse live state and trade logs.
  • Added /api/paper_30s_scalper endpoint serving strict JSON without NaN/Infinity parsing issues.

3. Dashboard Web UI

[MODIFY] index.html

  • Added “⚡ 30s Scalper” tab button in the header navigation.
  • Built two side-by-side scenario cards displaying:
    • Capital, Realized PnL, Win/Loss count, and Win Rate %
    • Real-time indicator gauge: Price, VWAP, MACD Histogram, and Momentum %
    • Open position tracker: Buy price, unrealized PnL, highest price, and trigger reason
    • API Health gauge: Latency ms and HTTP 429 status
  • Added recent paper scalp trade history table showing timestamps, scenario type, action badges, prices, position values, PnL, trigger reasons, and latency.

🧪 Verification & Results

  1. Syntax & Compilation Check:

    • dashboard_server.py compiled cleanly with zero errors (py_compile).
    • paper_30s_scalper.py executed successfully in test mode using ~/trading_env/bin/python3.
  2. API Data Verification:

    • Verified dashboard_server.get_paper_30s_scalper_payload() returns valid JSON with available: true, initial state data for Scenarios 1 & 2, and trade history rows.

🚀 How to Run the Paper Scalper

To start the paper scalping daemon live in your terminal:

/home/aztechguy/trading_env/bin/python3 /home/aztechguy/Projects/shared_trading_lib/paper_30s_scalper.py

Then open http://localhost:8080 in your browser and click the ⚡ 30s Scalper tab!

🛑 How to Stop the Script

  • Interactive Terminal: Press Ctrl + C in the running terminal window.
  • Background / Kill Command: Run pkill -f paper_30s_scalper.py in any terminal to cleanly stop querying.
  • Verify Status: Run ps aux | grep paper_30s_scalper.py to confirm it is completely dormant.

⏰ Optional Cronjob Automation (Market Hours)

To automate starting and stopping the daemon during market hours without manual terminal commands, add the following lines to crontab -e:

# Start 30s paper scalper at 6:30 AM PT (9:30 AM ET) weekdays
30 6 * * 1-5 /home/aztechguy/trading_env/bin/python3 /home/aztechguy/Projects/shared_trading_lib/paper_30s_scalper.py >> /home/aztechguy/Projects/shared_trading_lib/paper_30s_scalper.log 2>&1

# Stop 30s paper scalper at 1:00 PM PT (4:00 PM ET) market close
0 13 * * 1-5 /usr/bin/pkill -f paper_30s_scalper.py >> /dev/null 2>&1