Trailing Llama

Sign up to your account
๐Ÿค– Spam check โ€” please solve: What is 8 + 4?

๐Ÿฆ™ How Trailing Llama works

Trailing Llama is an automated trading harness for your Alpaca account โ€” works with both paper (fake money) and live (real money) accounts, selected per-account when you register your keys. It watches a list of symbols and decides when to enter / exit based on simple-moving-average (SMA) crossovers, with server-side trailing stops managed at Alpaca.

The strategy in one paragraph

For each watchlist symbol, the bot computes a fast SMA (default 10 periods) and a slow SMA (default 30 periods) on 1-minute bars. When the fast SMA crosses above the slow SMA by a configurable threshold, the bot buys. When the fast SMA crosses below, it sells. A small neutral zone (default 2.5%) suppresses whipsaw signals.

Trailing stops

Every new position gets a 10% trailing stop placed at Alpaca server-side as a trailing_stop order, GTC. Alpaca tracks the high-water mark tick-by-tick and fires the stop without the bot needing to be running. Once a position's unrealized gain crosses +10%, the bot cancels the loose stop and replaces it with a tighter 5% trail to lock in gains.

Additional guardrails

Getting your Alpaca keys

For paper trading (recommended for first use):

  1. Sign up free at https://app.alpaca.markets (no funding needed for paper trading).
  2. Confirm your email.
  3. Open the paper dashboard at https://app.alpaca.markets/paper/dashboard/overview.
  4. Click "View" / "Generate New Key" under API Keys.
  5. Copy the Key ID (starts with PK) and the Secret.
  6. In Trailing Llama, scroll to "Add Alpaca account", select Paper, and paste them in.

For LIVE trading (real money โ€” extra confirmation required):

  1. Complete Alpaca's brokerage onboarding (KYC, ID, funding) at https://app.alpaca.markets.
  2. Open the live dashboard at https://app.alpaca.markets/dashboard.
  3. Generate live API Keys (Key ID starts with AK).
  4. An admin must first set the encryption key for live storage: fly secrets set BOT_KEY_ENCRYPTION_KEY=$(node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
  5. In Trailing Llama, scroll to "Add Alpaca account", select LIVE, paste your keys, and type I UNDERSTAND in the confirmation field.
  6. The bot will now place real-money orders on your behalf according to its strategy. You accept full responsibility for the outcomes.

Important: the bot routes to paper-api.alpaca.markets for paper-flagged accounts and api.alpaca.markets for LIVE-flagged accounts. Choosing the wrong type at registration produces a 401. Each account row independently selects its endpoint based on its stored paper flag.

Multi-user model

Each Alpaca paper account UUID maps to exactly one bot user (free-tier Alpaca = one paper account per login). To run two isolated bot users, register two different Alpaca logins. An admin in /admin/users approves each new user's bot before it can trade automated entries.

Dashboard at a glance

โš  Disclaimer โ€” please read

Trailing Llama is a software harness for executing a trading strategy on your Alpaca account (paper or live). It is provided "as-is" with no warranty of any kind, express or implied, including warranties of merchantability, fitness for a particular purpose, or non-infringement.

Not financial advice. The strategy implemented here is for educational and personal use only. Nothing displayed by the bot โ€” including signals, charts, news sentiment, regime indicators, profit / loss numbers, or watchlist suggestions โ€” constitutes investment advice, a solicitation, or a recommendation to buy or sell any security. Past performance does not predict future results.

No liability for trading outcomes. The author and operators of this bot accept no responsibility for any losses, missed gains, incorrect trades, mis-placed stops, failed orders, missed orders, slippage, partial fills, network issues, software bugs, or any other consequences arising from use of this software. Markets are inherently risky; automated trading adds operational risk on top. You agree to indemnify and hold harmless the bot's authors and operators from any claims arising from your use.

Real-money (LIVE) trading: enhanced acknowledgment. If you have registered a live Alpaca account, every order the bot places executes on actual markets with real cash. Strategy bugs, network failures, missed stops, or adverse market conditions can result in real financial losses, potentially exceeding deposits in margin accounts. By selecting the LIVE option and typing "I UNDERSTAND" during registration, you acknowledge these risks and accept full responsibility for all resulting trades. The bot will not consult you before executing automated trades.

Tax, wash-sale, and reporting are your responsibility. Any tax indicators shown (including the 31-day loss blocklist and wash-sale warnings) are courtesy displays only โ€” not tax advice and not a substitute for proper record-keeping. The bot does no tax withholding, no IRS or state reporting, no cost-basis adjustments beyond display, no wash-sale loss disallowance calculations, and no Form 1099 preparation. Consult a qualified tax professional for your specific situation. Your Alpaca account's official 1099 from Alpaca Securities LLC is the authoritative tax document โ€” not anything displayed by this bot.

Your Alpaca Customer Agreement governs your account. All actual trading, custody of assets, order routing, settlement (T+1/T+2), margin lending, day-trading rules (FINRA pattern-day-trader), account restrictions, account funding, withdrawals, and dispute resolution are subject to the terms you agreed to with Alpaca Securities LLC and any affiliates. The bot is not a broker, custodian, or fiduciary. Refer to your Alpaca Customer Agreement and the disclosures at alpaca.markets/disclosures for the authoritative rules. In the event of any conflict between this bot's behavior and your Alpaca agreement, your Alpaca agreement governs.

Operational note on key storage. Paper-account API keys are stored in the bot's database. Live-account keys are encrypted at rest with AES-256-GCM (requires BOT_KEY_ENCRYPTION_KEY set as a deployment secret). Treat any API key as sensitive โ€” anyone with the key + secret can trade on the account.