Files
fit/CLAUDE.md
Jon 5e06c06987 Refactor for TDD workflow with Vitest and ESLint
- Move API keys from hardcoded values to .env via dotenv
- Extract business logic into src/trading.ts with dependency injection
- Add typed AlpacaClient interface, replace `any` on Alpaca class
- Add Vitest test suites for trading logic and Alpaca wrapper (14 tests)
- Set up ESLint with @typescript-eslint for linting
- Fix getAsset to pass symbol string directly to SDK
- Fix typo (alpacha -> alpaca), remove unused ws/node-fetch deps
- Update .gitignore for node_modules and .env

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 13:49:31 -07:00

1.5 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

A TypeScript trading bot that monitors the TQQQ ETF via the Alpaca paper trading API. It waits for market open, samples two price quotes one second apart, and logs whether the price moved up or down. It runs in a continuous hourly loop.

Commands

  • Build: npm run build (compiles TypeScript from src/ to dist/)
  • Start: npm start (runs compiled dist/index.js)
  • Dev: npm run dev (runs with ts-node + nodemon for auto-reload)
  • Docker: Standard docker build / docker run using the included Dockerfile (Node 22 base)

There are no tests or linting configured.

Architecture

Two source files with a simple layered design:

  • src/index.ts — Entry point. Contains the main loop (main()runDay()) that waits for market open via the Alpaca clock API, fetches two consecutive TQQQ quotes, compares them, and logs the direction. Utility functions for account balance, asset info, and delays live here too.
  • src/alpaca.ts — Wrapper class around @alpacahq/alpaca-trade-api. Exposes methods for account info, asset lookup, market clock, and price quotes. Uses CommonJS require for the Alpaca SDK (not ES import).

Build Configuration

  • TypeScript target: ES2016, CommonJS modules, strict mode enabled
  • Source/output dirs: src/dist/
  • esModuleInterop is on — mixed import styles are allowed