
This content is for educational and informational purposes only and should not be construed as investment advice, a recommendation, or an offer to buy or sell any securities or cryptocurrencies. Any strategies discussed are illustrative only and may not be suitable for all investors. This article reflects the experience of an individual user, is not representative of all customers, and should not be considered an endorsement or guarantee of future performance. The views and opinions expressed are those of the author and do not reflect or represent the views and opinions of Alpaca. Alpaca does not recommend any specific securities or investment strategies.The author was not compensated for this content but did receive nominal promotional items from Alpaca.
Background: Why I Built This
I'm the CPO at CUSP Wealth, a DFSA-regulated investment platform in Dubai. My day job is building the infrastructure that connects licenses, custody, compliance, and capital into functioning investment products across multiple jurisdictions.
In regulated investment management, every decision needs a traceable rationale. Not because regulators ask for it, but because it forces clarity at the point of decision. I wanted to see what happens when you apply that same architectural thinking to a personal trading system: structured proposals, explicit governance rules, a human approval gate, deterministic risk controls, full decision logging.
Most algo trading systems optimize for signal and execution. This one optimizes for process integrity first. The experiment explored whether introducing structured governance and human oversight would change how trading decisions were reviewed and evaluated relative to systems focused primarily on execution speed.
I'm running the experiment on a $100K Alpaca paper account. The full build is documented publicly on LinkedIn as it happens.
The Core Idea: Specialization Over Generalization
One LLM with a broad prompt mixes momentum logic with macro logic. Signals dilute. The solution: building five isolated agents, each optimized for one strategic lens, reading different data, with no visibility into each other's output before a structured proposal is submitted.
Alpaca Data (OHLCV) + Finnhub + yfinance + FRED
↓
Regime-Aware Screener (S&P 500 universe)
↓
5 Research Agents (parallel, isolated)
↓
Critic Agent → Investment Memo validation
↓
Human Gate (APPROVE / REJECT / REVISE)
↓
Risk Guard (deterministic Python)
↓
Alpaca Execution → Position Monitor (every 15 min)
Universe: S&P 500 only. Holding period: 2–28 days. Directions: long, short, paired. Account: $100K paper on Alpaca.
Data Layer: Alpaca as the Foundation
Every morning at 06:30 ET, one bulk OHLCV pull covers all ~500 S&P 500 tickers. The same Alpaca client handles execution and position monitoring later in the day.
from alpaca.data.historical.stock import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame
client = StockHistoricalDataClient(
api_key=ALPACA_KEY,
secret_key=ALPACA_SECRET
)
request = StockBarsRequest(
symbol_or_symbols=sp500_tickers,
timeframe=TimeFrame.Day,
start=start_date,
limit=252
)
bars = client.get_stock_bars(request).dfIndividual requests for the 500 tickers hit rate limits before the data finishes loading. One batch request solves this. Price-based metrics (returns, Relative Strength Index (RSI), Average True Range (ATR), beta, rolling correlations) are all calculated directly from Alpaca OHLCV data. No third-party analytics layer needed.
What Gets Layered On Top
Alpaca covers price and volume. Three additional sources fill the gaps agents actually need:
- Finnhub: Fundamentals (Price-to-Earnings (PE), Enterprise Value to EBITDA, Free Cash Flow (FCF)), insider activity, analyst ratings, earnings calendar. An agent evaluating a momentum thesis needs to know if insiders are selling into the breakout.
- yfinance: cross-asset data including Volatility Index (VIX) term structure, yield curve shape, and sector ETF returns. A macro agent without the US Dollar Index (DXY) and real rates is missing half the picture.
- Federal Reserve Economic Data (FRED): High-yield spreads, Fed Funds expectations, inflation breakevens. Credit markets signal before equity does.
All four sources consolidate into a single SQLite market_snapshot table. Agents query one interface and never call data sources directly. By the time agents run, the data is clean, calculated, and ready.
The 5 Research Agents
Agents run in parallel via Python async. Each sees the same market snapshot but through a different lens, with no visibility into what the others are proposing.
| Agent | Strategic Lens | Primary Data Inputs |
|---|---|---|
| Momentum | Breakouts, relative strength | Price action, volume, RSI |
| Macro | Sector rotation, factor plays | FRED, yield curve, VIX |
| StatArb | Pairs, spread dislocations | Rolling correlation, dislocation scores |
| Contrarian | Oversold bounces, crowded unwinds | Sentiment, insider activity |
| Exotic | Calendar effects, earnings binary | Earnings calendar, volume patterns |
Every agent returns a structured proposal with fixed required fields:
ticker: TICKER
direction: long
thesis: >
Momentum breakout above 52-week resistance on above-average volume.
Sector tailwind from defensive rotation. Insider buying in prior 30 days.
entry_conditions: open above resistance with volume > 1.3x 20-day average
exits:
take_profit_pct: 8
stop_loss_pct: 4
time_stop_days: 7
macro_alignment: WITH
confidence_score: 0.72macro_alignment is a required field, not optional context. During March 18 to April 5, WITH strategies averaged +1.62% vs AGAINST at +0.21%.
Critic + Human Gate
Critic Agent
Before any proposal reaches the human gate, a separate critic agent reads it against the investment_memo.yaml. The governance document covers: S&P 500 only, no ETFs, no crypto, leverage capped at 1.0x, max single position 10%, required fields, holding period constraints.
The critic checks structural validity. It does not evaluate whether the trade will work. The agent that generated the idea does not get to validate it.
Funnel for the March 18 to April 5 period: 82 proposals submitted, 26 approved (32%).
Human Gate
Every proposal that passes the critic goes through a human decision before execution: APPROVE, REJECT, or REVISE.

Morning Gate UI: three simultaneous proposals from one session. Each card shows thesis, critic warnings, macro alignment, and entry/exit parameters.
Illustrative prototype interface used in a paper trading environment. Displayed examples are hypothetical and for demonstration purposes only.
The screenshot shows three simultaneous proposals: an Exotic short on APA, a StatArb pair on MU/AMD, and a Momentum long on SLB. The middle card was sent to revision: the critic flagged duplicate exposure to an existing position in the same ticker and binary event risk on the short leg four days from earnings.
Why not fully autonomous: at the paper trading stage, validating signal quality matters more than speed. The deeper principle comes from regulated finance. Process integrity requires a human decision point where accountability sits. The gate is there by design, not because the system cannot execute autonomously.
Execution via Alpaca
Risk Guard: deterministic Python, no LLM
# execution/risk_guard.py (simplified)
def check_position_limits(proposal, portfolio_value, current_positions):
position_pct = proposal['position_sizing_pct']
if position_pct > 10.0:
return False, "Exceeds max single position (10%)"
sector = get_sector(proposal['ticker'])
sector_exposure = sum(
p['sizing_pct'] for p in current_positions
if get_sector(p['ticker']) == sector
)
if sector_exposure + position_pct > 30.0:
return False, "Exceeds max sector concentration (30%)"
return True, "OK"Position limit: 10% max. Sector concentration: 30% max. Leverage: 1.0x. Drawdown halts at 5% daily, 10% weekly, 15% total. Risk checks run as deterministic code, unit-tested, with no model in the loop.
Order placement
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import (
MarketOrderRequest, TakeProfitRequest, StopLossRequest
)
from alpaca.trading.enums import OrderSide, TimeInForce, OrderClass
# Entry
entry_req = MarketOrderRequest(
symbol=ticker,
qty=shares,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY,
)
entry = trade_client.submit_order(entry_req)
# TP + SL as OCO bracket (GTC)
bracket_req = MarketOrderRequest(
symbol=ticker,
qty=shares,
side=OrderSide.SELL,
time_in_force=TimeInForce.GTC,
order_class=OrderClass.OCO,
take_profit=TakeProfitRequest(limit_price=take_profit_price),
stop_loss=StopLossRequest(stop_price=stop_loss_price),
)
bracket = trade_client.submit_order(bracket_req)Market orders are intentional at this stage. The goal at this stage is observing how the system behaves under different market conditions and evaluating operational workflows in a simulated environment. Adding limit order complexity may introduce entry timing noise before there is enough signal data to justify it. Once directional accuracy stabilizes, the execution layer gets upgraded.
Every 15 minutes, the position monitor checks Alpaca positions against stored TP/SL levels. Pure price checks, no LLM. If an active position is missing its bracket order, it gets rebuilt automatically.
Results: 18 Days in a Falling Market
The following results are based on a limited, simulated paper trading period and are provided for illustrative purposes only. They do not reflect actual trading, do not account for real-world factors such as liquidity, slippage, or execution delays, and should not be interpreted as indicative of future performance.
S&P 500 dropped 4.2% between March 18 and April 5. Of 15 trading days with market briefs, 7 were flagged Risk-Off or liquidity squeeze.
Gross and net exposure
| Date | Gross Long | Gross Short | Net |
|---|---|---|---|
| Mar 18 | 63.6% | 0% | 63.6% |
| Mar 20 | 32.0% | 15.2% | 16.8% |
| Mar 24 | 15.8% | 15.0% | 0.82% |
By March 24, net exposure was 0.82% but gross was still ~31%. During this limited simulation period, the portfolio composition shifted toward paired positions as certain directional positions closed under predefined exit conditions.
Hypothetical Paper Trading Metrics From Limited Simulation
| Agent | Realized P&L | Trades | Avg per Trade |
|---|---|---|---|
| Macro | +$1,046 | 7 | +1.89% |
| Momentum | +$413 | 5 | +1.11% |
| Exotic | +$141 | 4 | +1.21% |
| Contrarian | −$232 | 8 | −0.35% |
| StatArb | −$69 | 1 | −0.88% |
These figures represent results from a limited number of simulated trades and should not be interpreted as indicative of future performance. Variability across agents reflects differences in how each strategy type interacted with prevailing market conditions during this specific timeframe.
Win Rate and Trade Characteristics
The system recorded a win rate of approximately 48% (12 out of 25 closed trades). However, this includes an initial period where system parameters were actively being adjusted, limiting its reliability as a standalone metric.
Across strategies, take-profit to stop-loss ratios ranged from approximately 2:1 to 2.7:1. In this configuration, overall outcomes depend not only on win rate but also on position sizing, risk controls, and consistency of execution, factors that were not fully tested in this limited simulation.
Please note during the limited simulation period, outcomes varied across trades and strategy types. Due to the small sample size, ongoing parameter adjustments, and use of paper trading, these observations have limited interpretive value and should not be viewed as predictive.
Key Observations
- Different strategy types performed differently under the same market conditions. For example, strategies aligned with broader market trends during this period produced different outcomes than those designed to capture reversals.
- The system’s ability to shift between directional and paired exposures contributed to changes in net exposure over time.
- Short-term results were influenced by the specific market regime and may not persist under different conditions.
Important Limitations
All results presented above are based on paper trading. Simulated performance has inherent limitations and does not represent actual trading. It does not reflect the impact of market liquidity, order execution, transaction costs, or behavioral factors that may affect real-world outcomes.
No representation is being made that any strategy will or is likely to achieve similar results. Past simulated performance is not indicative of future results.
What I’d Build Differently + What’s Next
Two things I’d change
All agents are currently in a learning phase. Critic feedback and closed-trade outcomes feed back into agent logic. What I would add from day one: a regime gate for the Contrarian agent. In trending markets, its weight should drop automatically. Discovering that through live losses is the slower way to learn it.
Data source rate limits also need active monitoring from the start. A FRED or Finnhub surprise at 07:00 ET, when the pipeline is already mid-run, is an expensive problem to debug under time pressure.
What’s next
- Long and short positions are already running. The next layer is options, with a dedicated options agent in development.
- Limit orders once directional accuracy data is large enough to measure entry timing impact.
- Future experimentation may include additional testing in live-market environments.
The system described relies in part on large language models and automated workflows, which can produce inconsistent, incomplete, or inaccurate outputs. Human review and predefined risk controls were incorporated to reduce, but not eliminate, these risks.
Additional Alpaca Resources
If you want to start building your own systematic trading system, here are the resources I found most useful:
Alpaca's Trading API (docs.alpaca.markets/docs/trading-api) is the place to start. The paper trading will have you placing simulated orders quickly.
Alpaca Market Data API (docs.alpaca.markets/docs/about-market-data-api) provides the historical and real-time data that powers everything. The free tier (IEX feed) is more than enough to get started.
Alpaca Paper Trading (docs.alpaca.markets/docs/paper-trading) lets you set up a paper account in minutes. Same API, same execution, no risk.
- How to Open a Live Alpaca Trading API Account as a US Resident
- How to Open a Live Alpaca Trading API Account as a Non-US Resident
- How to Fund Your Alpaca Live Trading Account
- How to Start Paper Trading with Alpaca's Trading API
- Alpaca-py GitHub Page
- Alpaca-py Documentation
- Alpaca's Trading API Reference
About the Author
Fedor Panteleev is the CPO at CUSP Wealth, a DFSA-regulated investment platform in Dubai.
*The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, “Alpaca”) is not authorized to do business.
**Commission free trading is available to Alpaca's retail customers. Commission free trading means that there are no commission charges for Alpaca self-directed individual cash brokerage accounts that trade U.S.-listed securities and options through an API. However, certain arrangements with authorized business partners or the use of the Elite Smart Router as part of the Alpaca Elite offering may preclude commission free trades by Alpaca Securities. Please refer to the Brokerage Fee Schedule for more information. Relevant regulatory fees may apply. Alpaca reserves the right to charge additional fees if it is determined that order flow is non-retail in nature.
Please note that this article is for educational and general informational purposes only. The examples above are for illustrative purposes only. The views and opinions expressed are those of the author and do not reflect or represent the views and opinions of Alpaca. Alpaca does not recommend any specific securities or investment strategies. Testimonials and examples used are for illustrative purposes only and are not indicative of future performance or success.
Alpaca and the entities referenced in this article are not affiliated and are not responsible for the liabilities of the others.
Alpaca does not prepare, edit, or endorse Third Party Content. Alpaca does not guarantee the accuracy, timeliness, completeness or usefulness of Third Party Content, and is not responsible or liable for any content, advertising, products, or other materials on or available from third party sites.
Past hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.
All investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.
Options trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options before investing in options.
Cryptocurrency is highly speculative in nature, involves a high degree of risks, such as volatile market price swings, market manipulation, flash crashes, and cybersecurity risks. Cryptocurrency is not regulated or is lightly regulated in most countries. Cryptocurrency trading can lead to large, immediate and permanent loss of financial value. You should have appropriate knowledge and experience before engaging in cryptocurrency trading. For additional information please click here.
Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.
Cryptocurrency services are made available by Alpaca Crypto LLC ("Alpaca Crypto"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA. Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC. Please see the Disclosure Library for more information.
This is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto, respectively, are not registered or licensed, as applicable.
