Reduce maximum order size to 50 shares#50
Conversation
Changed the default Netlify Blob store from 'order-book' to 'state-logs' to write state snapshots directly to long-term storage while the UI manages the cut-over between blob stores. This allows the UI to handle reading from both old (order-book) and new (state-logs) blob stores during the transition period without the archive workflow interfering by moving blobs between stores. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Critical fixes for Pattern Day Trading protection:
1. **Check filled orders, not just open orders** (pdt_gate.py:71-160)
- OLD: Only checked open orders from today
- NEW: Checks recent filled stock + option orders (last 1 day)
- Uses `last_transaction_at` (fill time) not `created_at` (order time)
- Prevents PDT violations from orders that filled earlier in the day
2. **Add same-day fill cache** (pdt_gate.py:19)
- Cache format: {symbol: {'buy': date, 'sell': date}}
- Faster checks after initial API fetch
- Auto-clears fills from previous days
3. **Track option fills for underlying stocks** (pdt_gate.py:122-154)
- BUY to open option = BUY underlying (for PDT purposes)
- SELL to close option = SELL underlying (for PDT purposes)
- Prevents day trades via options on same underlying
4. **Block paired orders if day trade risk** (main.py:239-255)
- Before placing paired buy+sell orders, check both sides for PDT risk
- Skip paired order placement if either side would violate PDT
- Prevents immediate round trips from paired DCA orders
5. **Clear warning messages** (pdt_gate.py:66-69)
- "⚠️ WILL CREATE DAY TRADE" when opposite side filled today
- Shows day trade count (e.g., "0/3 used")
- Helps traders make informed decisions
Test coverage:
- tests/test_pdt_guard.py: Live data validation
- Verified with real positions: BTC stock + IWN options
Before this fix:
❌ Could sell BTC same day as buy (missed filled order)
❌ Could close IWN options same day (missed option fills)
❌ Paired orders could create instant day trades
After this fix:
✅ Detects BTC buy from today → warns on sell attempt
✅ Detects IWN option opens from today → warns on close attempt
✅ Blocks paired orders if day trade risk detected
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Changed DEFAULT_LOT_SIZE from 250 to 50 to limit order sizes for risk management. This affects: - Live strategy order sizing (momentum_dca_strategy.py) - Backtest simulations - All paired buy/sell orders 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review — PR #50Overall: Simple config change — NoteThis same change is already included in PR #45's diff (along with the blob store rename and PDT fixes). Merging both will cause a conflict or redundancy. Recommend merging whichever PR lands first and rebasing the other. Generated by Claude Code |
Follow-up Review — PR #50The lot size change itself is fine, but this PR contains significant unrelated changes that need attention:
Generated by Claude Code |
|
Stale PR notice — This PR has been open for 25 days with no new commits since Mar 18. Two prior reviews flagged a title/scope mismatch (the 1-line lot-size change is bundled with a Generated by Claude Code |
|
Stale — 5 weeks, no activity since Mar 18. The 1-line lot-size change is buried under a Generated by Claude Code |
Summary
DEFAULT_LOT_SIZEfrom 250 to 50 share - BTC is going up!