How It Works Features Architecture Tech Stack Roadmap Contact
AUTONOMOUS TRADING SYSTEM v1.0

The Market
Never Sleeps.
Neither Does
Phantom.

An AI-powered trading bot that combines Gemini 3.5 Flash vision analysis, multimodal chart recognition, and 6 independent signal layers to make disciplined, emotionless trading decisions — 24 hours a day.

0 Signal Layers
0 Absolute Rules
0% Uptime Target
38K 40K 42K 44K 46K 08:00 10:00 12:00 14:00 16:00 18:00 BTC/USD • 1H LIVE PAPER TRADING BUY SIGNAL PARTIAL EXIT 50% SL TP TRAIL
BTC/USD
|
$63,208.45 ▲ +2.34%
|
AI Confidence: 78%
|
Signal: UPTREND
PAPER
WHY BUILD THIS

Human traders sleep. They panic. They get greedy. Markets don't care about any of that.

Humans Need Sleep

BTC moves 8% at 3AM. You're asleep. The opportunity — or the risk — is already gone before you open your eyes.

Emotions Destroy Discipline

Fear and greed override logic every time. A bot has no ego to protect and no fear to paralyze it. Every decision is mathematical.

Missed Signals

5-minute windows close before analysis is complete. By the time a human reacts, the entry is gone and risk:reward is destroyed.

Phantom Trader solves all three — permanently.

THE ANALYSIS CYCLE

Every Decision in 8 Steps

1
Market Data Collection
Alpaca API
250 barsOHLCV
2
News Fetch
Alpaca News
sentimentheadlines
3
Chart Screenshot
Puppeteer · TradingView
headless1H chart
4
Technical Indicators
RSI·MACD·EMA·ATR·BB
EMA-200ADXATR
5
Gemini AI Analysis
Vision + Text · 3.5 Flash
multimodalcontext
6
Decision Engine
6-gate check · 4-signal score
weightedADX≥25
7
Risk Manager
Kelly + ATR · Stops + TP
Kellybracketaudit
8
Order Execution
Bracket Order · Atomic
SL+TPAlpaca API

Full cycle completes in under 90 seconds. From data pull to order confirmation — every step is logged.

Every trade includes stop-loss + take-profit in a single atomic bracket order. No partial fills without protection.

Runs 24/7 via PM2 process manager. Survives internet drops. Survives reboots. Position audit runs on every restart.

WHAT MAKES IT DIFFERENT

6 Layers of Intelligence

Gemini 3.5 Flash Vision

Every 4 hours, Phantom takes a screenshot of the live candlestick chart via Puppeteer and sends it to Gemini 3.5 Flash for multimodal analysis. The AI identifies patterns, trend direction, support/resistance, and momentum from the actual visual chart — not just numbers.

gemini-3.5-flashpuppeteermultimodal1H cycle

1H + 5-Min Dual Engine

The 1H loop runs full AI analysis with chart screenshots and sets the trend direction. The 5-min scalp engine then calls Gemini text-only every 5 minutes — passing the 1H reasoning as context — to find precise entry points within the confirmed trend.

swing modescalp modeauto modecontext passthrough

Weighted Signal Scoring

Four independent signals feed a weighted scoring formula. Technical indicators (35%), AI chart analysis (30%), news sentiment (20%), and the Crypto Fear & Greed Index (15%) combine into a single score. Trade only fires when score ≥ 0.45 AND AI confidence ≥ 70% AND ADX ≥ 25.

RSIMACDEMA-200Fear & GreedADX filter

Let Winners Run

At 50% of the take-profit distance, the system exits half the position and locks in guaranteed profit — then moves the stop to breakeven. The remaining half rides a trailing stop that follows price upward, capturing extended moves without giving back gains.

trailing stoppartial TPbreakevenKelly sizing

Stop-Loss Cannot Be Skipped

Entry, stop-loss, and take-profit are sent to Alpaca as one single atomic request. Physically impossible to open a position without protection. If the bracket is rejected, the entire trade is cancelled. After every restart, a position audit verifies all open trades have stops.

bracket ordersposition auditstartup checkAlpaca API

Gemini Feedback Loop

Before every 1H analysis, Phantom injects the last 5 closed trade outcomes — including what the AI said at entry and whether it won or lost — into the Gemini system prompt. The model learns from its own mistakes in-context, progressively improving its signal calibration over time.

feedback loopin-context learningwin rateprompt engineering
FLEXIBILITY

Three Modes, One System

RECOMMENDED FOR BEGINNERS
Swing
1H CANDLES

Full Gemini analysis with Puppeteer chart screenshot every 4 hours. Slower, more deliberate. Catches major trend moves. Best for operators who want reliability over frequency.

  • Analysis every 4 hours
  • Full AI vision + text
  • 3:1 minimum R:R ratio
  • ATR × 2.0 stop distance
  • 1H candle data
HIGH FREQUENCY
Scalp
5-MIN CANDLES

1H sets the trend via full AI analysis. The 5-min engine then calls Gemini text-only with the 1H context every 5 minutes for precise entries. Up to 5 trades per 4-hour window.

  • 1H: full AI (analyst role)
  • 5-min: Gemini text-only (trader role)
  • 1.5:1 minimum R:R ratio
  • ATR × 1.0 stop distance
  • Max 5 trades per window
AI DECIDES
Auto
ADAPTIVE

The system measures current ATR against its 20-period average. Volatile (ATR > 1.3× average) → scalp mode. Calm and trending → swing mode. No manual intervention needed.

  • ATR volatility detection
  • Automatic mode switching
  • Best of both worlds
  • Logged per window
  • Zero manual input
Feature Swing Scalp Auto
AI per cycleFullFull*Full*
Puppeteer screenshotYes1H only1H only
Trades per day1–33–153–12
Stop distance2× ATR1× ATRAdaptive
Take profit6× ATR1.5× ATRAdaptive
Recommended forBeginnersExperiencedAny level
* Full = text-only with 1H context passthrough
TECHNICAL DEPTH

The Architecture

PHANTOM TRADER SYSTEM SCHEDULER node-cron PM2 ORCHESTRATOR index.js (main loop) KILL SWITCH −5% daily −10% drawdown DATA LAYER priceCollector newsCollector fearGreed API chartScreenshot techAnalyzer AI LAYER geminiClient promptBuilder decisionEngine feedbackLoop contextPassthrough RISK LAYER positionSizer riskManager killSwitch trailingStop correlGuard EXECUTOR orderManager posTracker alpacaClient auditWriter v1.0 — Node.js 20
17 Modules Built to spec, not to prototype
18 Absolute Rules Zero exceptions. Hardcoded guards.
131K+ Context Window Full trade history injected per cycle
CAPITAL PROTECTION

Risk Rules That Cannot Be Overridden

% Position Sizing

Fractional Kelly Criterion calculates optimal bet size based on historical win rate and risk:reward ratio. Hard cap at 1% of portfolio per trade. No single loss can meaningfully damage the account.

f* = (b×p − q) / b × 0.25
Stop Loss

ATR-based stops adapt to actual market volatility. Stop distance = 2×ATR for swing trades, 1×ATR for scalps. Sent as part of the bracket order — lives on Alpaca's servers permanently after entry confirmation.

SL = entry − (ATR × 2.0)
Kill Switch

Two automatic circuit breakers. Daily loss limit: portfolio down 5% → all trading halted until midnight. Drawdown limit: portfolio down 10% from peak → all trading halted indefinitely until manual reset.

Daily −5% | Drawdown −10%
Portfolio Heat

Maximum 3 open positions simultaneously. Maximum 3% of total portfolio at risk across all open trades. Correlation guard prevents opening BTC and ETH simultaneously — 90% correlated assets.

Max 3 positions | Max 3% heat
◼ POSITION RISK CALCULATOR
Portfolio Value:
$
Win Rate:
%
R:R Ratio:
:1
Kelly Fraction: 10.00%
Fractional (0.25×): 2.50%
Kelly Position Size: $2,500
HARD CAP (1%): $1,000 ← APPLIED
Max loss if wrong: −$1,000 (−1.00%)
Max gain if right: +$3,000 (+3.00%)
Expected value: +$800 per trade
BUILT WITH

The Stack

Node.js 20
Runtime Engine
LTS runtime. Async-first architecture. Event loop handles concurrent API calls without blocking.
Google Gemini 3.5
AI Vision + Text
3.5 Flash model for low-latency multimodal analysis. Handles both chart images and text reasoning.
Alpaca Markets
Trading API
Paper + Live accounts. Commission-free crypto/equities. Bracket order support native.
Puppeteer
Chart Screenshots
Headless Chrome automation. Captures live TradingView charts with pixel-perfect fidelity.
technicalindicators
Signal Engine
RSI · MACD · EMA · ATR · Bollinger Bands · ADX · Volume oscillator calculations.
node-cron
Scheduling Engine
Cron expression scheduler. ±0 drift. Fires 24/7 regardless of system load.
PM2
Process Manager
Auto-restart on crash. Cluster mode capable. Boot-time persistence across reboots.
axios
HTTP Client
Direct HTTP calls to Fear & Greed API, Alpaca News, and custom endpoints. No SDK abstraction bugs.
csv-writer
Audit Trail
Full decision log. Every AI analysis, signal score, and trade outcome written to persistent CSV.
dotenv
Secret Management
Environment variable injection. Zero hardcoded API keys. Production-safe from day one.
Fear & Greed API
Sentiment Signal
alternative.me/fng — no API key required. 15% weight in composite signal score.
Kelly Criterion
Position Sizing
Mathematical edge calculation. Fractional (0.25×) applied. Hard-capped at 1% portfolio risk.
PAPER TRIAL TARGETS

Success Is Defined Before Real Money Enters

Phantom Trader operates on a strict 30-day paper trial before any live capital is deployed. Six measurable criteria must all pass — no exceptions, no shortcuts.

14 Consecutive Days

No crashes, no missed cycles, no silent failures. Full operational stability under real market conditions.

Complete Audit Log

Every analysis cycle logged. No missing entries. Full decision trail from signal to execution.

Win Rate > 45%

Over the full 30-day period. Combined with 3:1 R:R, this generates meaningful positive expectancy.

Positive Expected Value

Expected value per trade must be greater than $0 when calculated over the sample. Math must work.

No −5% Daily Loss

The kill switch must never trigger during the paper trial. If it does, the trial resets.

Profit Factor > 1.2

Total gross profits divided by total gross losses must exceed 1.2 across the full sample period.

Only when all 6 criteria pass does TRADING_MODE switch from 'paper' to 'dual'. Live capital starts small. The bot proves itself before it touches real money.
Realistic Weekly Target0.5%–2.0%Not 1–5% daily — sustainable edge
Min Win Rate Needed25%At 3:1 R:R — we target 50%+
Max Risk Per Trade1%Hard cap. Always. No exceptions.
WHERE WE'RE GOING

From Paper to Production

1
Paper Trial IN PROGRESS
Month 1

30-day autonomous paper trading on BTC/USD and SPY. Full audit log generation and performance analysis. Gemini prompt tuning based on observed signal quality.

Goal: All 6 success criteria met with statistical significance.

2
Live Trading (Small Capital) PLANNED
Month 2

Activate dual mode with small live capital. Philippine bank wire or crypto deposit to Alpaca. Monitor live vs paper performance divergence closely.

Goal: Live P&L matches paper P&L within ±15% variance.

3
Cloud Migration PLANNED
Month 3

Migrate from local laptop to AWS EC2 (t3.small or t3.medium). 24/7 uptime without keeping home PC running. CloudWatch monitoring, SNS alerts on kill switch triggers, S3 backup of audit logs.

Goal: 99.9% uptime. Zero missed analysis cycles due to infrastructure.

4
Expansion FUTURE
Month 4+

Add ETH/USD, QQQ, AAPL to active assets. Build web dashboard for real-time monitoring. Explore multi-account management. Consider open-source release with full documentation.

Goal: Production-grade multi-asset autonomous system.

INFRASTRUCTURE NEEDS

Why AWS Startup Credits Matter

The Problem With Local Hosting

Currently running on a local laptop in the Philippines. This creates five structural failure points that no amount of good code can solve:

  • Every power cut = bot goes offline. Positions stay protected by Alpaca, but entries are missed.
  • Internet outage = missed analysis cycles. Gaps in the audit log. Performance degraded.
  • Laptop needed for other tasks = resource conflicts with Puppeteer's headless Chrome.
  • No monitoring, no alerts, no redundancy. A crash at 3AM is discovered at 8AM.
  • BTC/USD analysis fires at 3AM Philippine time = laptop must stay on overnight, every night.
AWS Deployment Architecture
AWS EC2 t3.small ($15–20/month)
├── PM2 process manager
│   └── phantom-trader (24/7)
├── CloudWatch Logs
│   └── audit_log.csv → S3 daily backup
├── SNS Notifications
│   └── Kill switch → SMS alert
└── Elastic IP
    └── Stable connection to Alpaca API

With AWS Startup Credits, Phantom Trader moves from a bedroom experiment to a production-grade system with the infrastructure professional algorithmic traders rely on — at a cost that doesn't burn through trading capital.

Get In Touch

Questions about the system architecture, collaboration opportunities, or AWS infrastructure decisions? Reach out directly.

Send a Message