How jay-withers/market-agent works
MarketAgent is a paper-trading and investment-research platform: scheduled jobs gather news and market data, an LLM recommends actions, deterministic risk checks constrain them, and approved orders go to Alpaca’s paper account. Separate jobs synchronize broker state, report performance against benchmarks, and produce weekly reviews. The read-only API serves the dashboard’s portfolio, history, decisions, and activity views. The README documents these major workflows; sampled source confirms API/query boundaries and selected storage, broker, and review behavior, but does not expose every job’s call wiring.
Main entry points: agent.py Agent workflow · App.tsx Dashboard app · summary.py Daily summary · weekly.py Weekly review
Components 31
Research and trading
- Agent workflow
apps/marketagent/src/marketagent/jobs/agent.py - News research
apps/marketagent/src/marketagent/news.py - Market data
apps/marketagent/src/marketagent/marketdata.py - LLM analysis
apps/marketagent/src/marketagent/llm/deepseek_provider.py - Risk engine
apps/marketagent/src/marketagent/risk.py - Broker adapter
apps/marketagent/src/marketagent/broker/alpaca.py - Account sync
apps/marketagent/src/marketagent/sync.py
Reporting and review
- Daily summary
apps/marketagent/src/marketagent/jobs/summary.py - Benchmarks
apps/marketagent/src/marketagent/benchmarks.py - Weekly review
apps/marketagent/src/marketagent/jobs/weekly.py - Email delivery
apps/marketagent/src/marketagent/mailer.py
Read API
- Read-only API
apps/marketagent/src/marketagent/api/main.py - Portfolio routes
apps/marketagent/src/marketagent/api/routers/portfolio.py - Decision routes
apps/marketagent/src/marketagent/api/routers/decisions.py - Activity routes
apps/marketagent/src/marketagent/api/routers/activity.py - Read queries
apps/marketagent/src/marketagent/queries.py
Dashboard
- Dashboard app
apps/dashboard/src/App.tsx - Dashboard API client
apps/dashboard/src/api.ts - Portfolio tables
apps/dashboard/src/components/Tables.tsx - Performance chart
apps/dashboard/src/components/PerformanceChart.tsx - Price trends
apps/dashboard/src/components/PriceTrends.tsx - Account comparison
apps/dashboard/src/components/Compare.tsx - Weekly review view
apps/dashboard/src/components/Review.tsx
Other components
- Job scheduler
- Alpaca paper account
- Application database
- Financial news sources
- Market data sources
- DeepSeek service
- Email provider
- Dashboard user
Connections 40
- Job scheduler → Agent workflow: schedules
- Job scheduler → Account sync: schedules
- Job scheduler → Daily summary: schedules
- Job scheduler → Weekly review: schedules
- Agent workflow → News research: fetches research
- Agent workflow → Market data: fetches prices
- Agent workflow → LLM analysis: requests analysis
- Agent workflow → Risk engine: checks recommendations
- Agent workflow → Broker adapter: submits approved orders
- Agent workflow → Application database: records run and decisions
- News research → Financial news sources: retrieves articles
- Market data → Market data sources: retrieves prices
- LLM analysis → DeepSeek service: requests completion
- Broker adapter → Alpaca paper account: places and reads orders
- Account sync → Broker adapter: reads account snapshot
- Account sync → Application database: stores account state
- Daily summary → Broker adapter: reconciles fills
- Daily summary → Benchmarks: compares performance
- Daily summary → Application database: reads and records summary
- Daily summary → Email delivery: sends summary
- Benchmarks → Market data: uses price history
- Weekly review → Application database: reads metrics and stores review
- Weekly review → LLM analysis: requests review
- Weekly review → Email delivery: sends review
- Email delivery → Email provider: delivers email
- Read-only API → Portfolio routes: mounts routes
- Read-only API → Decision routes: mounts routes
- Read-only API → Activity routes: mounts routes
- Portfolio routes → Read queries: requests portfolio data
- Decision routes → Read queries: requests decision data
- Activity routes → Read queries: requests activity data
- Read queries → Application database: reads
- Dashboard user → Dashboard app: views
- Dashboard app → Dashboard API client: requests dashboard data
- Dashboard API client → Read-only API: calls GET endpoints
- Dashboard app → Portfolio tables: renders tables
- Dashboard app → Performance chart: renders performance
- Dashboard app → Price trends: renders price history
- Dashboard app → Account comparison: renders comparisons
- Dashboard app → Weekly review view: renders weekly review