Jon 4c2ed5455f Increase fill poll timeout to 2min, always sell after buy
waitForFill now polls 60 times at 2s intervals (2 min total) instead
of 30x1s, and uses retry on the getOrder calls. The strategy wraps
the hold loop in try/finally so if anything fails after a buy, we
still sell the position instead of leaving it orphaned.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 10:46:20 -07:00
2026-02-09 17:06:28 -07:00
2025-02-11 00:24:00 -07:00
2026-02-01 17:51:46 -07:00

fit

A TypeScript trading bot built on the Alpaca paper trading API. It runs pluggable strategies that use indicators to generate buy/sell signals.

How it works

  1. The Bot waits for market open via the Alpaca clock API
  2. It runs all registered Strategies concurrently, each with its own capital allocation
  3. Each strategy uses Indicators to evaluate market conditions and returns buy/sell Signals
  4. The Executor processes the signals
  5. The bot loops hourly, waiting for the next market open

Setup

Requires an Alpaca paper trading account. Create a .env file in the project root:

ALPACA_KEY_ID=your_key_id
ALPACA_SECRET_KEY=your_secret_key

Install dependencies:

npm install

Running

# Build and run
npm run build
npm start

# Development (auto-reload)
npm run dev

# Docker
docker build -t fit .
docker run --env-file .env fit

Testing and linting

npm test
npm run lint

Project structure

src/
  index.ts                  # Entry point, main loop
  alpaca.ts                 # Alpaca API client wrapper
  bot.ts                    # Orchestrator, runs strategies each day
  executor.ts               # Executes signals from strategies
  indicator.ts              # Indicator interface
  strategy.ts               # Strategy/Signal interfaces
  trading.ts                # Utilities (wait, market open, etc.)
  momentum-indicator.ts     # Samples QQQ direction after open
  momentum-strategy.ts      # Trades TQQQ/SQQQ based on momentum
Description
Just a simple stock trading bot, playing around with claude code
Readme 5.3 MiB
Languages
TypeScript 98.5%
JavaScript 1.1%
Shell 0.2%
Dockerfile 0.2%