Skip to content

Aryanak47/trade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

Claude AI Futures Trading System

Firefox_Screenshot_2025-08-28T04-01-19 083Z Firefox_Screenshot_2025-08-28T16-31-01 463Z

A sophisticated full-stack futures trading analysis platform powered by Claude AI, providing real-time market data, technical analysis, and intelligent fundamental analysis for futures contracts.

πŸš€ Features

Market Data & Analysis

  • Real-time Quotes: Live pricing for Crude Oil (CL=F), Gold (GC=F), and S&P 500 E-mini (ES=F)
  • Interactive Charts: Candlestick charts with multiple timeframes and intervals
  • Technical Analysis: RSI, MACD, EMA indicators with support/resistance levels
  • Risk Management: Automated stop-loss and take-profit calculations

Claude AI Integration

  • Fundamental Analysis: AI-powered market analysis with bias determination
  • Smart Caching: 15-minute cache system to optimize API costs
  • Real-time Insights: Market drivers, catalysts, and risk factors
  • Web Search Enhanced: Optional web search for latest market conditions

Professional UI

  • Dark Theme: Modern, professional trading interface
  • Unified Dashboard: Combined market data and analysis in one view
  • Responsive Design: Works on desktop and mobile devices
  • Real-time Updates: Live data streaming with WebSocket support

πŸ›  Technology Stack

Backend

  • Node.js with Express.js framework
  • PostgreSQL database for data persistence
  • Yahoo Finance API for real-time market data
  • Claude AI API (Anthropic) for fundamental analysis
  • WebSocket for real-time updates
  • Docker containerization support

Frontend

  • React 18 with modern hooks
  • Material-UI (MUI) for professional components
  • Recharts for interactive financial charts
  • Axios for API communication
  • React Router for navigation

Key Libraries

{
  "backend": {
    "express": "^4.18.2",
    "yahoo-finance2": "^2.11.3",
    "@anthropic-ai/sdk": "^0.17.1",
    "pg": "^8.11.3",
    "ws": "^8.14.2"
  },
  "frontend": {
    "@mui/material": "^5.14.18",
    "recharts": "^2.8.0",
    "axios": "^1.6.0"
  }
}

πŸ“¦ Installation

Prerequisites

  • Node.js 18+ and npm
  • PostgreSQL 12+
  • Claude AI API key from Anthropic

Clone Repository

git clone <repository-url>
cd trading-system

Backend Setup

cd backend-node
npm install

# Environment Configuration
cp .env.example .env
# Edit .env with your database and API credentials:
# DATABASE_URL=postgresql://user:password@localhost:5432/trading_db
# ANTHROPIC_API_KEY=your_claude_api_key

Frontend Setup

cd ../frontend
npm install

# Environment Configuration
cp .env.example .env
# Edit .env:
# REACT_APP_API_URL=http://localhost:8001/api/v1

Database Setup

# Create PostgreSQL database
createdb trading_db

# Run migrations (auto-created on first startup)
cd backend-node
npm run dev

πŸš€ Running the Application

Development Mode

# Terminal 1 - Backend
cd backend-node
npm run dev

# Terminal 2 - Frontend  
cd frontend
npm start

Production Mode

# Backend
cd backend-node
npm run build
npm start

# Frontend
cd frontend
npm run build
serve -s build

Docker Deployment

# Full stack with Docker Compose
docker-compose up -d

πŸ“Š API Endpoints

Market Data

GET  /api/v1/market/quotes          # Get multiple quotes
GET  /api/v1/market/price/:symbol   # Get single quote
GET  /api/v1/market/historical/:symbol  # Historical data
GET  /api/v1/market/contracts       # Available contracts

Analysis

GET  /api/v1/analysis/technical/:symbol     # Technical analysis
GET  /api/v1/analysis/claude/:symbol/cached # Cached Claude analysis
POST /api/v1/analysis/claude/:symbol/generate # Fresh Claude analysis
POST /api/v1/analysis/claude/:symbol/enhanced # Enhanced with web search
POST /api/v1/analysis/claude/:symbol/selected-articles # Analyze user-selected articles

News & Articles

GET  /api/v1/news/                     # Get recent news with importance scoring
GET  /api/v1/news/symbol/:symbol       # Get symbol-specific news
POST /api/v1/news/refresh              # Force refresh news from RSS feeds

System

GET  /health                        # Health check
GET  /api/v1/system/status         # System status

🎯 Usage Guide

1. Market & Analysis Page

  • View real-time price charts with technical indicators
  • Toggle between different timeframes (1d, 7d, 30d, 90d)
  • Monitor current quotes with price changes
  • Access technical analysis with RSI, MACD, support/resistance

2. Advanced Claude AI Analysis

  • Manual Analysis Trigger: Click "Load News & Analysis" to fetch latest articles
  • Selected Articles Analysis: Analyze only chosen articles for targeted insights
  • Market Bias Detection: AI determines Bullish/Bearish/Neutral stance with confidence levels
  • Key Data Points: Extract specific metrics and trading ranges from news
  • Risk Assessment: Identify potential risk factors and market catalysts
  • Detailed Reasoning: Claude explains its analysis logic and market interpretation
  • Token Efficiency: Smart article selection reduces analysis costs significantly

3. Trading Signals

  • Monitor generated trading signals
  • Track signal performance and accuracy
  • Set up custom alert notifications

4. Smart News Analysis & Article Selection

  • Intelligent Article Ranking: Articles auto-sorted by importance score (CRITICAL/HIGH/MEDIUM/LOW)
  • Manual Article Selection: Choose specific articles for Claude AI analysis with checkboxes
  • Real-time Token Estimation: See token usage before analysis (8,000 token limit protection)
  • Clickable Headlines: Direct links to original news sources
  • Sentiment Analysis: Visual sentiment indicators with color-coded scoring
  • Source Credibility: Premium sources (Bloomberg, Reuters) ranked higher
  • Breaking News Detection: "BREAKING", "URGENT" keywords boost importance
  • Cost Optimization: Only analyze selected articles, reducing API costs by up to 90%

πŸ”§ Configuration

Environment Variables

Backend (.env)

# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/trading_db
DB_POOL_SIZE=10

# Claude AI
ANTHROPIC_API_KEY=your_anthropic_api_key

# Server
PORT=8001
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000

# Cache
REDIS_URL=redis://localhost:6379  # Optional
CACHE_TTL=900  # 15 minutes

Frontend (.env)

REACT_APP_API_URL=http://localhost:8001/api/v1
REACT_APP_WS_URL=ws://localhost:8001
REACT_APP_ENV=development

Supported Contracts

{
  'CL=F': 'Crude Oil WTI Futures',
  'GC=F': 'Gold Futures', 
  'ES=F': 'S&P 500 E-mini Futures'
}

πŸ” Security Features

  • API Key Management: Secure handling of Claude AI credentials
  • CORS Protection: Configurable origin restrictions
  • Input Validation: Comprehensive data sanitization
  • Rate Limiting: Built-in API rate limit management
  • Error Handling: Graceful failure with fallback data

πŸ“ˆ Performance Optimizations

Caching Strategy

  • 15-minute Claude analysis cache - Reduces API costs by 90%
  • Smart Article Selection - User-controlled analysis reduces unnecessary API calls
  • Importance-based News Ranking - Focus on high-value content first
  • Database connection pooling - Efficient resource usage
  • WebSocket connections - Real-time updates without polling

Scheduler & Market Hours

  • Market Hours: 9:30 AM - 4:00 PM Eastern Time, Monday-Friday
  • Price Updates: Every hour during market hours
  • News Updates: Every hour (RSS feeds from Bloomberg, CNBC, Reuters)
  • Claude Analysis: Every hour during market hours with fresh data
  • Health Checks: Every 2 hours

Cost Management

  • User-Controlled Analysis - Manual article selection prevents unnecessary API calls
  • Token Limit Protection - Real-time validation prevents exceeding 8,000 token limits
  • Efficient Article Filtering - Importance scoring focuses on high-value content
  • Smart Caching - Database-based caching with intelligent expiry
  • Fallback mechanisms - Graceful degradation when APIs are unavailable

πŸ§ͺ Testing

Backend Tests

cd backend-node
npm test
npm run test:coverage

Frontend Tests

cd frontend
npm test
npm run test:coverage

Integration Tests

npm run test:integration

πŸš€ Deployment

Production Checklist

  • Set NODE_ENV=production
  • Configure production database
  • Set up SSL certificates
  • Configure reverse proxy (nginx)
  • Set up monitoring and logging
  • Configure backup strategies

Docker Production

# docker-compose.prod.yml
version: '3.8'
services:
  app:
    image: claude-trading:latest
    environment:
      - NODE_ENV=production
      - DATABASE_URL=${DATABASE_URL}
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Code Style

  • Use ESLint and Prettier for consistent formatting
  • Follow semantic commit messages
  • Write tests for new features
  • Update documentation for API changes

πŸ™ Acknowledgments

  • Anthropic for Claude AI API
  • Yahoo Finance for market data
  • Material-UI for React components
  • PostgreSQL for reliable data storage

πŸ”„ Recent Updates

v1.1.0 (Latest) - Smart News Analysis

  • βœ… Intelligent Article Selection - Choose specific articles for Claude analysis
  • βœ… Importance-Based Ranking - CRITICAL/HIGH/MEDIUM/LOW scoring system
  • βœ… Real-time Token Estimation - Prevent API limit overages with live token counting
  • βœ… Manual Analysis Control - User-driven analysis reduces unnecessary API costs
  • βœ… Enhanced Sentiment Display - Visual sentiment indicators with color coding
  • βœ… Clickable News Headlines - Direct links to original article sources
  • βœ… Source Credibility Scoring - Premium sources ranked higher automatically
  • βœ… Breaking News Detection - Urgent keywords boost article importance

v1.0.0 (Previous)

  • βœ… Unified Market & Analysis page
  • βœ… Real-time technical analysis with Yahoo Finance data
  • βœ… Claude AI fundamental analysis with smart caching
  • βœ… Professional dark theme UI
  • βœ… WebSocket real-time updates
  • βœ… Docker containerization support

Coming Soon

  • πŸ“Š Advanced charting with drawing tools
  • πŸ”” Real-time alerts and notifications
  • πŸ“± Mobile app companion
  • πŸ€– Enhanced AI with multi-model support
  • πŸ“ˆ Portfolio tracking and management
  • 🎯 Custom article filtering and search

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published