What is Apex Automated Trade Systems?

Apex Automated Trade Systems is a self-hosted automated trading system that runs on a cloud server you own. It connects to your Alpaca brokerage account and executes a systematic gap-and-go strategy every trading day — no manual intervention required.

The system is made up of independent modules (screener, position monitor, sector rotation engine, etc.) that run as background services and communicate through a shared PostgreSQL database. A web dashboard lets you monitor positions, view performance analytics, and adjust configuration.

Apex Automated Trade Systems is not financial advice. All trading involves risk. See the Risk Disclaimer.

System Requirements

ComponentMinimumRecommended
VPS / Droplet1 vCPU / 1 GB RAM2 vCPU / 2 GB RAM
OSUbuntu 22.04 LTSUbuntu 24.04 LTS
Disk20 GB SSD40 GB SSD
Node.jsv18+v20 LTS
PostgreSQLv14+v16
BrokerageAlpaca paper accountAlpaca live account
LicenseActive Apex Automated Trade Systems license
DigitalOcean's $6/mo Basic Droplet (1 vCPU, 1 GB RAM) is sufficient for the Starter tier. Upgrade to the $12/mo droplet for Pro or Elite.

Installation Guide

The setup wizard on the success page walks you through every step after purchase. For manual setup:

1. Provision a server

Create a Ubuntu 22.04+ droplet on DigitalOcean (or any VPS). Enable IPv4. Note the IP address.

2. SSH in and install dependencies

bash
ssh root@YOUR_SERVER_IP
apt update && apt upgrade -y
apt install -y nodejs npm postgresql postgresql-contrib git curl
npm install -g pm2

3. Clone and install

bash
git clone https://github.com/Apex-Ai-Trading/apex-ai-trade.git /opt/apex
cd /opt/apex
npm install

4. Configure environment

bash
cp .env.example .env
nano .env   # fill in ALPACA_KEY, ALPACA_SECRET, LICENSE_KEY, DB_URL

5. Initialize the database

bash
npm run db:migrate
npm run db:seed

6. Start all services

bash
pm2 start ecosystem.config.js
pm2 save
pm2 startup   # follow the printed command to auto-start on reboot
The dashboard will be available at http://YOUR_SERVER_IP:3000 once services are running.

Connecting Alpaca

Apex Automated Trade Systems uses the Alpaca Markets API for order routing. Paper and live accounts use different key sets.

Getting your API keys

Log in to app.alpaca.markets → Your Account → API Keys → Generate New Key. Store both the key ID and secret immediately — the secret is only shown once.

.env VariableDescription
ALPACA_KEY_IDYour Alpaca API key ID (paper or live)
ALPACA_SECRET_KEYYour Alpaca secret key
ALPACA_PAPERtrue for paper trading, false for live
ALPACA_BASE_URLhttps://paper-api.alpaca.markets or https://api.alpaca.markets
The system defaults to paper trading (ALPACA_PAPER=true). Switching to live trading puts real money at risk — do this only after validating paper performance.

Modules

Position Monitor

The position monitor runs continuously during market hours, tracking all open positions against configured stop-loss levels. It fires hard stops, trailing stops, and time-based exits based on your configuration.

FeatureDescription
Hard stopCloses position if loss exceeds HARD_STOP_PCT
Trailing stopLocks in profit as price rises; fires if reversal exceeds TRAIL_PCT
Time stopExits position if held past MAX_HOLD_MINUTES
EOD exitCloses all positions before market close (configurable)

Morning Screener

Runs at 09:00 ET, before market open. Scans the full universe of US equities for gap candidates using pre-market data from Alpaca. Outputs a ranked list of candidates scored by relative volume, gap size, sector alignment, and momentum.

Results are stored in the screener_results table and visible on the dashboard Screener tab.

Sector Rotation

Pro

Analyzes ETF flows and relative strength across 11 GICS sectors (XLK, XLF, XLE, XLV, etc.) to determine which sectors are in regime. The strategy engine uses this data to weight candidates — stocks in bullish sectors receive a score boost; stocks in bearish sectors are penalized or excluded.

Early Mover

Pro

Pre-market module (08:00–09:25 ET) that identifies high-conviction gap candidates before the screener runs. Sends a Telegram alert with top picks and their key metrics so you can review before the session starts.

Strategy Engine

The core execution module. After the screener runs, the strategy engine takes the ranked list, applies sector weighting and risk filters, determines position sizes, and submits orders to Alpaca at your configured entry time.

ParameterDescription
ENTRY_TIMETime to submit opening orders (ET)
MAX_POSITIONSMaximum concurrent open positions
POSITION_SIZE_PCTPosition size as % of account equity
MIN_GAP_PCTMinimum pre-market gap to qualify a candidate
MIN_RVOLMinimum relative volume multiplier to qualify

Options Strategy

Elite

The options strategy layer adds Greeks-aware options trading on top of the core equity strategy. It screens for high-IV opportunities, selects contracts based on delta and DTE targets, and manages exits via theta decay or stop-loss triggers.

ParameterDescription
OPTIONS_ENABLEDEnable options trading layer
TARGET_DELTATarget delta for contract selection
MAX_DTEMaximum days to expiration at entry
MIN_IV_RANKMinimum IV rank to qualify a symbol
Options trading carries additional risk versus equities. Ensure you have options trading enabled on your brokerage account before activating this module.

Crypto Strategy

Elite

The crypto module extends the strategy engine to cover crypto assets available on Alpaca (BTC, ETH, and others). It runs a parallel screener for crypto pairs and applies gap-and-momentum logic adapted for 24/7 markets — with configurable weekend behavior.

ParameterDescription
CRYPTO_ENABLEDEnable crypto trading module
CRYPTO_SYMBOLSComma-separated symbols to monitor
CRYPTO_POSITION_PCTPosition size as % of equity (per crypto position)
CRYPTO_WEEKENDAllow entries on Saturday/Sunday

Risk Management

Risk circuit breakers halt all new entries if daily drawdown limits are hit, preventing the system from compounding losses during bad market conditions.

VariableDescription
MAX_DAILY_LOSS_PCTHalt new entries if daily P&L falls below this threshold
MAX_OPEN_RISK_PCTMaximum total open risk across all positions
HARD_STOP_PCTHard stop per position (closes immediately on breach)
TRAIL_PCTTrailing stop distance once position is in profit

Analytics & Reports

Pro

The analytics module generates end-of-day performance summaries: equity curve, win rate, average win/loss ratio, expectancy, drawdown metrics, and sector performance breakdown. Reports are stored in the database and accessible from the Analytics tab.

Weekly summary reports can be sent via Telegram or email — configure REPORT_CHANNEL in your .env.

Configuration

.env Reference

All configuration lives in /opt/apex/.env. After editing, restart services with pm2 restart all.

bash
# ── License ─────────────────────────────────────────
LICENSE_KEY=apex_xxxxxxxxxxxxxxxxxxxx

# ── Alpaca ───────────────────────────────────────────
ALPACA_KEY_ID=PKxxxxxxxxxxxxxxxx
ALPACA_SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ALPACA_PAPER=true
ALPACA_BASE_URL=https://paper-api.alpaca.markets

# ── Database ─────────────────────────────────────────
DATABASE_URL=postgresql://apex:password@localhost:5432/apex

# ── Strategy (configured at install) ─────────────────
MAX_POSITIONS=
POSITION_SIZE_PCT=
ENTRY_TIME=
MIN_GAP_PCT=
MIN_RVOL=

# ── Risk (configured at install) ─────────────────────
MAX_DAILY_LOSS_PCT=
HARD_STOP_PCT=
TRAIL_PCT=

# ── Notifications ─────────────────────────────────────
TELEGRAM_TOKEN=
TELEGRAM_CHAT_ID=
EMAIL_FROM=
EMAIL_TO=

Stop Categories

Four stop types are applied in priority order:

Stop TypeTriggerPriority
Hard stopLoss ≥ HARD_STOP_PCT1 — immediate
Circuit breakerDaily loss ≥ MAX_DAILY_LOSS_PCT2 — halts new entries
Trailing stopPrice reversal ≥ TRAIL_PCT from peak3 — profit protection
Time stopPosition age ≥ MAX_HOLD_MINUTES4 — end-of-day

Risk Parameters

Position sizing uses a fixed fractional approach: each position is sized at POSITION_SIZE_PCT × account_equity. Your specific sizing parameters are set during installation and can be adjusted in .env at any time.

High position sizing magnifies both gains and losses. Understand your per-trade risk before increasing above your initial configuration.

Telegram Notifications

Set up a Telegram bot to receive trade alerts, daily summaries, and circuit breaker notifications.

1. Create a bot

Message @BotFather on Telegram → /newbot → follow prompts → copy the token.

2. Get your chat ID

Send any message to your new bot, then visit:

bash
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates

Copy the chat.id from the JSON response.

3. Add to .env

bash
TELEGRAM_TOKEN=1234567890:ABCDefghIJKlmnoPQRstuvwXYZ
TELEGRAM_CHAT_ID=987654321

Troubleshooting

Common Errors

ErrorLikely CauseFix
License validation failedKey cancelled or server IP changedCheck license status; re-activate if needed
ALPACA_AUTH_ERRORInvalid or expired API keysRegenerate keys in Alpaca dashboard
connection refused :5432PostgreSQL not runningsudo systemctl start postgresql
No candidates foundPre-market data unavailableCheck market hours; verify Alpaca data subscription
pm2 process crashedUnhandled exception in modulepm2 logs apex — check stack trace

Restarting the Service

bash
# Restart all services
pm2 restart all

# Restart a single module
pm2 restart apex-screener

# View running processes
pm2 list

# Full stop and start
pm2 stop all && pm2 start ecosystem.config.js

Checking Logs

bash
# Tail all logs
pm2 logs

# Tail a specific service
pm2 logs apex-strategy

# View last 200 lines
pm2 logs --lines 200

# Logs are also stored in
~/.pm2/logs/
The dashboard's Logs tab streams live output from all pm2 processes — no SSH needed for routine monitoring.

Account & Billing

Managing Your License

Your license key is delivered to your email immediately after purchase and shown on the success page. It is tied to one server (by machine ID) and validates every 23 hours.

To move your license to a new server: deactivate from the old server's dashboard → activate on the new server using the same key. You can do this once per 24-hour period.

Upgrading Tiers

Upgrades take effect immediately and are prorated for the remainder of the billing period. To upgrade:

Email [email protected] with your license key and desired tier — we'll send a Stripe upgrade link. Self-service upgrade portal coming soon.

Cancellation

Cancel any time via the Stripe customer portal (link in your receipt email). Your license remains active until the end of the current billing period. No partial refunds.

After cancellation, the software will stop running when the license next attempts validation. Your server, database, and trade history remain intact — you just can't run new trades.