Alpaca Trading API
Account, position, order, activity, portfolio-history, market-clock, and exchange-calendar state.
Separate paper and live endpoints
Technical overview / Vibe Trader
An implementation architecture that combines brokerage state, live market context, model reasoning, deterministic risk controls, and traceable execution.
AI Integration Architecture
Logical boundaries and authoritative services
Portfolio, agents, watchlists, market news, decisions, and AI advisor
Builds market context, requests model targets, applies deterministic controls, and translates approved targets into orders
Produces news assessments, portfolio targets, reasoning, and advisory analysis from supplied context
Authoritative brokerage execution, account state, positions, market data, clock, calendar, and news
Durable configuration, assessments, decisions, account mappings, and performance snapshots
Data sources & services
External inputs, model boundary, and derived context
Account, position, order, activity, portfolio-history, market-clock, and exchange-calendar state.
Separate paper and live endpoints
IEX stock snapshots, bars, latest quotes, market movers, most-active names, and corporate actions.
Single and multi-symbol retrieval
Recent market headlines, summaries, sources, symbols, and publication timestamps for research context.
Deduplicated before assessment
Gemini is used by the current implementation for news assessment, target allocation, reasoning, and advisor responses.
Model boundary also supports approved endpoints
Agent configuration, watchlists, news assessments, ticker sentiment, decisions, and account-value snapshots.
Scoped durable state and audit history
Trend, relative strength, ATR, liquidity, spread, market regime, exposure, and position-risk calculations.
Computed by deterministic application logic
Agent decision lifecycle
From scheduled market context to recorded broker outcome
A protected minute-level tick confirms the activity switch, broker clock, and extended-hours window; outside that window agents only record equity snapshots.
Once per tick and shared by every agent, Alpaca headlines are ingested, scored for sentiment and impact, and rolled up into time-decayed per-symbol sentiment.
For each active agent: candidate discovery, account state, agent-owned positions and resting orders, quotes, bars, market screens, corporate actions, and the scored news already stored.
Within the same pass the system computes trend across horizons, relative strength, volatility, tradability, spread, event risk, and a debounced risk-on / risk-off regime.
Before the model is consulted, code-only stop logic exits positions on ATR, trailing, break-even, and time conditions, and applies the daily loss circuit breaker.
The AI model receives the bounded context and returns a target portfolio: symbols, desired weights, rationale, supporting news references, and stale orders to cancel.
Deterministic rules clamp or reject targets that breach eligibility, minimum hold, cooldowns, sizing, cash, exposure, concentration, or loss limits, and may backfill or park exposure.
The difference between approved targets and the agent's own book becomes sized orders, sells before buys, within no-churn and turnover limits and verified ownership.
Surviving orders are submitted to the matching Alpaca paper or live account as market or marketable-limit orders; responses and failures are captured.
Decision reasoning, controls applied, broker references, realized results, and account value snapshots remain available for review.
Orchestration component network
Detailed flow inside the Vibe Trader control plane
A protected minute-level endpoint confirms the activity switch, broker clock, and extended-hours window before any agent runs; outside the window only equity snapshots are taken
Once per tick, shared across all agents: Alpaca headlines are ingested, scored by a model for sentiment and impact, then rolled up into time-decayed per-symbol sentiment
For each active agent: candidate discovery, account state, agent-owned positions and orders, quotes, bars, market screens, corporate actions, scored news, and stale-order cleanup
Computed within context assembly: multi-horizon trend, relative strength, ATR and volatility, tradability, bid/ask spread, event risk, and a debounced risk-on / risk-off regime
Before the model is consulted, code-only stop logic exits positions and applies the daily loss circuit breaker, so protection never depends on model output
The model receives the bounded context and returns desired symbol weights with a reason and supporting news references, plus stale orders to cancel — never executable trades
Deterministic policy overrides the proposal: eligibility, minimum hold, cooldowns, per-symbol and sector caps, cash floor, and exposure backfill or risk-off parking
Approved weights are differenced against the agent's own book and sized into orders, sells before buys, within no-churn and turnover limits and verified ownership
Only surviving orders are submitted to the agent's Alpaca paper or live account as market or marketable-limit orders according to session state
Every proposal, clamp, skip, failure, and fill is written with its reasoning and broker reference, then realized results and account value snapshots are recomputed
Responsibility & trust boundaries
Authority by system component
User intent, portfolio presentation, agent settings, watchlists, and decision review
Does not hold broker secrets or submit orders directly
News interpretation, contextual reasoning, target-weight proposals, and advisor narrative
Cannot bypass controls, modify records, or call Alpaca directly
Context assembly, eligibility, policy, sizing, target clamping, order translation, and execution sequencing
Does not invent market prices or replace the broker's accepted state
Broker account state, positions, orders, fills, market clock, market data, and source news
Does not define Vibe Trader strategy or application policy
Configuration, assessments, sentiment rollups, decision history, and performance snapshots
Does not supersede current broker positions or fill status
Risk & operational controls
Deterministic safeguards around model output
Broker secrets are encrypted at rest and resolved only within server execution boundaries.
No credentials in browser state
Paper and live accounts use distinct Alpaca endpoints; live credentials require an explicit enablement switch.
Mode-specific routing
Price, liquidity, bid/ask spread, volatility, symbol, sector, exposure, concurrent-position, and cash limits are enforced in code.
Model output remains advisory
Daily soft stops, hard drawdown limits, ATR-based stops, trailing protection, and time-based exits constrain the active book.
Fail-closed enforcement
The exchange clock and calendar govern regular, pre-market, after-hours, and closed-session behavior.
Order type follows session state
Each agent acts only on its own positions and resting orders, preserving other agents and human-managed holdings.
Scoped cancellation and exit
Persistent application records
Configuration, intelligence, decisions, and performance history
User settings
Encrypted Alpaca paper/live credentials, default mode, and live-trading enablement
Accounts & membership
Workspace ownership and access scope used to isolate portfolio context
Agents
Strategy configuration, risk tolerance, universe, budgets, operating mode, and cumulative statistics
Watchlist
User-scoped symbols included in monitoring and research context
News items
Deduplicated Alpaca headlines, summaries, sources, symbols, and timestamps
News assessments
Model-derived sentiment, impact, watch conditions, suggested action, rationale, and model identifier
Ticker sentiment
Time-decayed per-symbol sentiment rollups weighted by recency and assessed impact
Agent decisions
Proposals, controls, order intent, broker results, status, reasoning, and realized outcomes
Value snapshots
Timestamped equity, cash, and position-value measurements for agent performance