Skip to content

feat: Alpaca paper account portfolio with manual and automated trading - #66

Merged
kingabzpro merged 1 commit into
masterfrom
feat/alpaca-paper-portfolio
Nov 14, 2026
Merged

kingabzpro merged 1 commit into
masterfrom
feat/alpaca-paper-portfolio

Conversation

@kingabzpro

Copy link
Copy Markdown
Owner

Summary

  • The Portfolio page now shows the real Alpaca paper trading account: cash, buying power, total equity and positions (with current price and unrealized P&L) come from paper-api.alpaca.markets using the existing ALPACA_API_KEY/ALPACA_SECRET_KEY; paper trading only, never live orders
  • Manual buy/sell: a trade form submits market orders; the displayed price is the latest Alpaca trade (IEX); BUY is capped by buying power, SELL by held shares
  • Automated trading (opt-in toggle): every 5 minutes, while the tab is visible, it picks today's top gainer with a market cap of $1B or more (Alpaca movers screener + Yahoo fundamentals, cached 60 s), runs one real decision on it, and submits BUY (10% of paper cash), SELL (10% of held shares) or HOLD as a paper order; activity log persisted in the browser, plus a Run now button
  • Interactive equity chart: snapshots of cash/positions/equity after account refreshes and orders (max 500, stored in the browser), drawn with the existing chart helpers, with hover and arrow-key inspection
  • The browser-local practice portfolio stays on the decision card; its fills CSV export and reset moved to a Portfolio page footer

New backend module fasttrade/paper.py (overview, last price, order submission, movers) routed through the shared pooled HTTP client and circuit breakers; loopback-only endpoints GET /api/paper/account, POST /api/paper/order, GET /api/paper/price, GET /api/paper/movers.

Checks

  • pytest: 407 passed, 1 skipped (16 new: paper module, $1B cap filter, endpoint validation/caching)
  • node chart tests: 7 passed; UI tests: 59 passed (rewritten portfolio tests + 6 new Alpaca/auto-trade/equity tests)
  • Live smoke against the real Alpaca paper account: account overview, latest-trade price, movers with the cap filter correctly reporting no qualifying $1B+ gainer today, and one real paper BUY (1 AAPL) accepted by Alpaca (queued for next market open)
  • Browser visual pass: 6/6 scenarios, zero console errors, desktop and mobile screenshots clean

Note: docs/usage.md was updated locally but docs/ is intentionally untracked since 044bf04, so the doc edit stays out of the repo.

The Portfolio page now shows the real Alpaca paper account (cash, buying
power, equity, positions) and submits paper market orders: manually from
a trade form priced at the latest Alpaca trade, or automatically from an
opt-in watcher that every five minutes picks the top gainer with a B+
market cap, runs one decision on it, and acts on the signal with the
existing suggested sizing. An interactive equity chart records account
snapshots with hover and keyboard inspection. The browser-local practice
portfolio stays on the decision card; its fills export and reset move to
a footer of the Portfolio page.
Comment thread fasttrade/web.py
try:
result = paper.overview()
except ValueError as exc:
return JSONResponse({'error': str(exc)}, status_code=503)
Comment thread fasttrade/web.py
try:
result = await run_in_threadpool(paper.submit_order, body.symbol, body.side, body.quantity)
except ValueError as exc:
return JSONResponse({'error': str(exc)}, status_code=503)
Comment thread fasttrade/web.py
try:
return await run_in_threadpool(paper.last_price, symbol)
except ValueError as exc:
return JSONResponse({'error': str(exc)}, status_code=503)
Comment thread fasttrade/web.py
try:
result = paper.movers()
except ValueError as exc:
return JSONResponse({'error': str(exc)}, status_code=503)
@kingabzpro
kingabzpro merged commit 53163cf into master Nov 14, 2026
6 checks passed
@kingabzpro
kingabzpro deleted the feat/alpaca-paper-portfolio branch November 14, 2026 11:08
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.

2 participants