|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +A cryptocurrency trading bot supporting multiple exchanges via CCXT. Features multi-pair support, SQLite storage, web dashboard with basic authentication, and profile-based bot management. |
| 8 | + |
| 9 | +## Key Build/Development Commands |
| 10 | + |
| 11 | +### Development |
| 12 | +```bash |
| 13 | +npm install # Install dependencies |
| 14 | +npm run build:prod # Production build with esbuild |
| 15 | +npm start # Build and run in production |
| 16 | +``` |
| 17 | + |
| 18 | +### Testing & Code Quality |
| 19 | + |
| 20 | +- Mocha test framework with ts-node |
| 21 | + |
| 22 | +```bash |
| 23 | +npm test # Run TypeScript tests with mocha |
| 24 | +npm test:js # Run JavaScript tests |
| 25 | +npm run build:tsc # Compile with TypeScript compiler |
| 26 | +``` |
| 27 | + |
| 28 | +## Architecture Overview |
| 29 | + |
| 30 | +### Main Entry Points |
| 31 | +- **index.ts**: CLI entry point using Commander.js |
| 32 | + - `trade` command: Starts the trading bot and web server |
| 33 | + - Supports port override: `npm start -- --port=55555` |
| 34 | + |
| 35 | +### Core Services (src/modules/services.ts) |
| 36 | +Central service registry using dependency injection patterns: |
| 37 | +- **Database**: SQLite with WAL mode, stored in `var/bot.db` |
| 38 | +- **Config**: JSON configuration from `var/conf.json` |
| 39 | + |
| 40 | +### Key Modules |
| 41 | + |
| 42 | +#### Trading / Strategy System |
| 43 | +- **Trade** (src/modules/trade.ts): Main orchestrator, starts BotRunner and webserver |
| 44 | +- Built-in strategies: src/strategy/strategies/ and custom strategies in `var/strategies/` directory |
| 45 | +- Profile Management: Each profile can have multiple bots with different strategies abd exchange credentials using CCXT |
| 46 | +- OHLCV candles: fetched via Websocket, live or via backfill |
| 47 | +- Indicator included via `talib` in `src/utils/indicators.ts |
| 48 | + |
| 49 | +#### Web UI (Express.js + EJS) / Code Structure Conventions |
| 50 | +- **Controllers** (src/controller/): Handle HTTP requests |
| 51 | +- **Views** (views/): EJS templates with layout system `express-ejs-layouts` |
| 52 | +- Tailwind CSS 4 for styling |
| 53 | +- `web/` webserver root with assets |
| 54 | +- **Database** schema in `src/utils/database_schema.ts` with `src/repository` as Database Repository Pattern |
| 55 | +- **.prettierrc**: Code formatting (single quotes, 160 width) |
0 commit comments