A high-performance Fastify API for cryptocurrency trade analysis, featuring technical indicators, chart generation, and AI-powered market insights. Built for the io.net hackathon.
- β‘ Fastify - High-performance web framework
- π· TypeScript - Type-safe development
- π Technical Analysis - Bollinger Bands, RSI, MACD indicators
- π Chart Generation - Dynamic chart creation with Chart.js
- π€ AI Analysis - io.net IO Intelligent-powered market insights with Trump-style personality
- π CoinGecko Integration - Real-time cryptocurrency market data
- π Swagger/OpenAPI - Auto-generated API documentation
- π‘οΈ Security - Helmet for security headers
- π CORS - Cross-origin resource sharing
- π§ͺ Testing - Jest with TypeScript support
- π Linting - ESLint with TypeScript rules
- π Hot Reload - Development with tsx
src/
βββ index.ts # Main application entry point
βββ routes/ # Route handlers
β βββ tradeAnalysis.ts # Trade analysis endpoints
βββ types/ # TypeScript type definitions
β βββ index.ts # OHLCV interface
βββ utils/ # Utility functions
β βββ index.ts # Utility exports
β βββ fetchOHLCVFromCoinGecko.ts # CoinGecko API integration
β βββ calculateBollingerBands.ts # Bollinger Bands calculation
β βββ calculateRSI.ts # RSI calculation
β βββ calculateMACD.ts # MACD calculation
β βββ generateChartBase64.ts # Chart generation
β βββ generateAnalysisText.ts # AI analysis generation
βββ __tests__/ # Test files
βββ tradeAnalysis.test.ts # Trade analysis route tests
- Node.js 18+
- npm or yarn
- io.net IO Intelligent API key (for AI analysis)
- Clone the repository:
git clone <repository-url>
cd io-net-hackathon- Install dependencies:
npm install- Set up environment variables:
# Create .env file
echo "IO_NET_SECRET_KEY=your_io_intelligent_api_key_here" > .env- Start development server:
npm run devThe server will start on http://localhost:3000
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm start- Start production servernpm test- Run testsnpm run lint- Run ESLintnpm run lint:fix- Fix ESLint issues
GET /- Welcome message and API info
POST /api/trade-analysis- Generate comprehensive trade analysis
Visit http://localhost:3000/api/docs for interactive API documentation powered by Swagger UI.
The API supports the following tokens (case-insensitive):
- BTC (Bitcoin)
- ETH (Ethereum)
- BNB (Binance Coin)
- SOL (Solana)
- XRP (Ripple)
- ADA (Cardano)
- DOGE (Dogecoin)
- TRX (Tron)
curl -X POST http://localhost:3000/api/trade-analysis \
-H "Content-Type: application/json" \
-d '{"token": "bitcoin"}'{
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"text": "BITCOIN IS ABSOLUTELY BULLISH! The MACD CROSS is showing incredible momentum...",
"json": {
"sentiment": "BULLISH",
"confidence": 8,
"entry": 45000,
"target": 48000,
"stopLoss": 43000
}
}The API calculates and analyzes the following technical indicators:
- Period: 20 days
- Standard Deviation: 2
- Usage: Identifies overbought/oversold conditions and volatility
- Period: 14 days
- Usage: Measures momentum and identifies overbought/oversold conditions
- Fast Period: 12 days
- Slow Period: 26 days
- Signal Period: 9 days
- Usage: Identifies trend changes and momentum shifts
The API generates comprehensive charts using Chart.js with:
- Price candlesticks
- Bollinger Bands (upper, middle, lower)
- RSI indicator
- MACD (line, signal, histogram)
- Interactive tooltips
- Multiple Y-axes for different indicators
The AI analysis feature uses io.net IO Intelligent's Llama-3.3-70B-Instruct model to provide:
- Market sentiment analysis (BULLISH/BEARISH/NEUTRAL)
- Technical indicator interpretation
- Trading signals with entry/target/stop-loss levels
- Confidence scores (1-10 scale)
- Trump-style charismatic and confident personality
The project uses strict TypeScript configuration with:
- ES2022 target
- Strict type checking
- Source maps for debugging
- Declaration files generation
- ESLint with TypeScript rules
- Jest for testing with comprehensive test coverage
- Type-safe development throughout
Create a .env file for environment-specific configuration:
IO_NET_SECRET_KEY=your_io_intelligent_api_key_here
NODE_ENV=development
PORT=3000Run tests with:
npm testRun tests with coverage:
npm test -- --coverageThe test suite includes:
- Input validation tests
- Error handling tests
- API response format tests
- External API integration tests
Build the project:
npm run buildStart production server:
npm start- fastify - Web framework
- axios - HTTP client for CoinGecko API
- technicalindicators - Technical analysis calculations
- chart.js & chartjs-node-canvas - Chart generation
- io-intelligent - AI analysis integration
- canvas - Chart rendering
- typescript - TypeScript compiler
- jest & ts-jest - Testing framework
- eslint - Code linting
- tsx - TypeScript execution for development
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run linting and tests
- Submit a pull request
MIT License - see LICENSE file for details
Built for the io.net hackathon by maiga.ai. This project demonstrates modern API development practices with real-time cryptocurrency analysis capabilities.