Skip to content

Maiga-AI/io-net-hackathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Maiga.ai Trade Analysis API

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.

Features

  • ⚑ 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

Project Structure

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

Quick Start

Prerequisitesq. /

  • Node.js 18+
  • npm or yarn
  • io.net IO Intelligent API key (for AI analysis)

Installation

  1. Clone the repository:
git clone <repository-url>
cd io-net-hackathon
  1. Install dependencies:
npm install
  1. Set up environment variables:
# Create .env file
echo "IO_NET_SECRET_KEY=your_io_intelligent_api_key_here" > .env
  1. Start development server:
npm run dev

The server will start on http://localhost:3000

Available Scripts

  • npm run dev - Start development server with hot reload
  • npm run build - Build for production
  • npm start - Start production server
  • npm test - Run tests
  • npm run lint - Run ESLint
  • npm run lint:fix - Fix ESLint issues

API Endpoints

Root

  • GET / - Welcome message and API info

Trade Analysis

  • POST /api/trade-analysis - Generate comprehensive trade analysis

API Documentation

Visit http://localhost:3000/api/docs for interactive API documentation powered by Swagger UI.

Supported Cryptocurrencies

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)

Example Usage

Generate Trade Analysis

curl -X POST http://localhost:3000/api/trade-analysis \
  -H "Content-Type: application/json" \
  -d '{"token": "bitcoin"}'

Response Format

{
  "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
  }
}

Technical Indicators

The API calculates and analyzes the following technical indicators:

Bollinger Bands

  • Period: 20 days
  • Standard Deviation: 2
  • Usage: Identifies overbought/oversold conditions and volatility

RSI (Relative Strength Index)

  • Period: 14 days
  • Usage: Measures momentum and identifies overbought/oversold conditions

MACD (Moving Average Convergence Divergence)

  • Fast Period: 12 days
  • Slow Period: 26 days
  • Signal Period: 9 days
  • Usage: Identifies trend changes and momentum shifts

Chart Generation

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

AI Analysis

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

Development

TypeScript Configuration

The project uses strict TypeScript configuration with:

  • ES2022 target
  • Strict type checking
  • Source maps for debugging
  • Declaration files generation

Code Quality

  • ESLint with TypeScript rules
  • Jest for testing with comprehensive test coverage
  • Type-safe development throughout

Environment Variables

Create a .env file for environment-specific configuration:

IO_NET_SECRET_KEY=your_io_intelligent_api_key_here
NODE_ENV=development
PORT=3000

Testing

Run tests with:

npm test

Run tests with coverage:

npm test -- --coverage

The test suite includes:

  • Input validation tests
  • Error handling tests
  • API response format tests
  • External API integration tests

Production

Build the project:

npm run build

Start production server:

npm start

Dependencies

Core Dependencies

  • 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

Development Dependencies

  • typescript - TypeScript compiler
  • jest & ts-jest - Testing framework
  • eslint - Code linting
  • tsx - TypeScript execution for development

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run linting and tests
  6. Submit a pull request

License

MIT License - see LICENSE file for details

About

Built for the io.net hackathon by maiga.ai. This project demonstrates modern API development practices with real-time cryptocurrency analysis capabilities.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors