075572a01c1276c429687fccef002483af1284f2
Replace the Executor logging placeholder with real buy/sell methods on the Alpaca class that place market orders via createOrder and return the fill price. Strategies now receive their capital amount directly and place orders themselves. Bot accepts StrategyAllocation[] to decouple capital allocation from strategy definition. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
- The Bot waits for market open via the Alpaca clock API
- It runs all registered Strategies concurrently, each with its own capital allocation
- Each strategy uses Indicators to evaluate market conditions and returns buy/sell Signals
- The Executor processes the signals
- 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
Languages
TypeScript
98.5%
JavaScript
1.1%
Shell
0.2%
Dockerfile
0.2%