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 trading 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.

Multi-Broker Setup

Apex supports Alpaca Markets and Tradier simultaneously. You designate one as your Primary broker — all new buy signals route there. The other runs in monitor-only mode, winding down existing positions without opening new ones. You can switch primary at any time from the dashboard.

BrokerEquitiesOptionsCryptoPaper Trading
Alpaca
Tradier✓ (sandbox)

Connecting a broker

Go to Account Settings in your dashboard. Each broker has its own credentials section:

  • Alpaca — enter your Key ID and Secret Key from app.alpaca.markets → API Keys. Select Paper or Live.
  • Tradier — enter your Access Token and Account Number from tradier.com → API Access. Select Sandbox or Live.

Click Save and Test Connection for each broker, then restart the service to activate.

Switching your primary broker

In the Active Broker card, click Set as Primary on the broker you want to switch to. This will:

  • Cancel all open orders on the outgoing broker
  • Set the outgoing broker to monitor-only (existing positions wind down naturally)
  • Route all new buy signals to the new primary broker
A service restart is required after switching primary broker for the change to take full effect.

Resetting Account State

If you're switching to a new brokerage account, use Reset Account State in the Danger Zone on the Account page to clear out everything tied to the old one, so nothing carries over.

What gets cleared

  • All trade history
  • Exit rules and tracked positions (stop-loss / trailing-stop settings)
  • Weekly goal, performance stats, equity history, and benchmark comparison

Not affected: your risk profile, module toggles, license, dashboard login, and notification settings. This also does not change your API keys or close any positions at the broker — it only clears Apex's own records.

How to do it

  • Click Reset Account State… and review the preview — it shows exactly what will be cleared before anything happens
  • Enter your new broker API keys elsewhere on the Account page (this can be done before or after the reset — order doesn't matter)
  • Type the confirmation phrase and re-enter your dashboard password
  • Restart the trading service once, after both the reset and the new keys are in place
Restart only once, at the end. The service doesn't pick up new API keys or the cleared state until it restarts — restarting in between saving new keys and running the reset (or vice versa) can reconnect on the wrong account first.
If you still have open positions, the reset will ask you to confirm — closing them out first is recommended, since resetting removes their stop-loss and trailing-stop tracking immediately.

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 trade candidates using pre-market data from Alpaca. Outputs a ranked candidate list based on the system's proprietary scoring model.

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 sector data to weight and filter the candidate list.

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 processes the ranked list, applies configured 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_PCTEntry filter threshold — set at install
MIN_RVOLVolume filter threshold — set at install

Options Strategy

Elite

The options strategy layer adds options trading on top of the core equity strategy. It screens for qualified opportunities, selects contracts based on your configured parameters, and manages exits automatically.

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 the system's trading 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

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.