Skip to content

Repository files navigation

Futu AI Trading System

An automated investment tool integrating Futu Securities API with local LLM (Ollama) for intelligent portfolio management.

Features

  • AI-Powered Analysis: Leverage local LLM for financial report and news sentiment analysis
  • Automated Trading: Execute trades based on AI insights and predefined rules
  • Risk Management: Position limits, stop-loss protection, and portfolio balancing
  • Dual Mode Support: Paper trading (simulation) and real trading modes
  • News Monitoring: RSS feed integration for market news tracking

Prerequisites

  1. Python 3.9+
  2. Futu OpenD: Download and install from Futu OpenAPI
  3. Ollama: Install from ollama.ai
  4. AI Model: 根据你的硬件选择
    # 笔记本用户(推荐)
    ollama pull qwen2.5:7b
    
    # 服务器用户
    ollama pull qwen2.5:14b
    
    # 更多选择请参考 MODEL_GUIDE.md

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd Quant_Alpha
  2. Create virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure environment variables:

    cp .env.example .env
    # Edit .env with your configuration

Configuration

Trading Mode

  • SIMULATION: Paper trading with virtual portfolio (recommended for testing)
  • REAL: Live trading with real money (use with caution)

Edit .env file:

TRADING_MODE=SIMULATION  # Change to REAL for live trading

AI Model Selection

Choose the right model for your hardware:

# 笔记本用户(推荐)
MODEL_PRESET=balanced  # qwen2.5:7b, 4GB RAM

# 服务器用户
MODEL_PRESET=performance  # qwen2.5:14b, 8GB RAM

# 低配置设备
MODEL_PRESET=lightweight  # qwen2.5:3b, 2GB RAM

📖 详细的模型选择指南: MODEL_GUIDE.md

🔧 快速切换工具:

python scripts/switch_model.py --list  # 查看所有配置
python scripts/switch_model.py --set balanced  # 切换配置

Watchlist

Add stock codes to monitor (HK market format):

WATCHLIST=00700,09988,01299,03690

Investment Parameters

Adjust risk parameters in .env:

  • MAX_POSITION_SIZE: Maximum position size per stock (default: 15%)
  • INITIAL_POSITION: Initial position size for new buys (default: 5%)
  • STOP_LOSS: Stop loss threshold (default: 20%)

Usage

方式1: Alpha Arena 交易展示界面 🚀 ⭐NEW⭐

全新赛博朋克风格交易界面,灵感来自 nof1.ai,为您的量化交易提供酷炫的可视化体验:

# 一键启动 Alpha Arena
./start_alpha_arena.sh

# 或直接运行 Flask 后访问
python app.py

然后访问: http://localhost:9999/arena

Alpha Arena 特点:

  • 🎮 赛博朋克终端风格设计
  • 📈 实时价格滚动条
  • 💹 交互式账户价值图表
  • 🔥 动态交易历史展示
  • 🤖 AI 模型状态监控
  • ⚡ 流畅的动画效果
  • 🌈 荧光主题配色
  • 📊 多维度性能排行榜

详见 ALPHA_ARENA_GUIDE.md 查看完整使用说明。

方式2: CoreUI 专业Web界面 🎨

专业级管理界面,基于 CoreUI Bootstrap Admin Template(12.1k stars)开发:

# 启动 CoreUI 界面
./start_web_coreui.sh

# 或直接运行
python app.py

然后访问: http://localhost:9999

CoreUI界面特点:

  • ✨ 现代化专业设计
  • 📊 实时行情数据显示
  • 💰 富途模拟账户集成
  • 📰 自动财经新闻聚合
  • ⚡ 流畅的交互体验
  • 📱 完美响应式布局
  • 🎨 基于Bootstrap 5
  • 🚀 Flask后端API

详见 COREUI_GUIDE.md 查看完整使用说明。

方式3: 命令行运行

Start FutuOpenD

  1. Launch FutuOpenD application
  2. Login with your Futu account
  3. Enable API access in settings

Run the Trading System

python main.py

The system will:

  • Connect to Futu OpenD and Ollama
  • Run daily analysis after market close (16:30 HKT)
  • Generate weekly reports (Monday 09:00)
  • Log all decisions and trades

Manual Analysis

You can trigger manual analysis by modifying main.py or creating a CLI interface.

System Architecture

├── config/          # Configuration management
├── core/            # Trading logic and AI analysis
├── data/            # Data collection (Futu API, news)
├── utils/           # Logging and notifications
└── main.py          # Application entry point

Safety Features

  • Position Limits: Prevents over-concentration in single stocks
  • Stop Loss: Automatic exit on excessive losses
  • AI Score Thresholds: Only trades high-confidence signals
  • Audit Logging: Complete transaction history
  • Confirmation Prompts: Manual approval for real trading mode

Risk Disclaimer

⚠️ IMPORTANT WARNING ⚠️

This software is for educational and research purposes. Trading stocks involves substantial risk of loss.

  • Always test in SIMULATION mode first
  • Never invest more than you can afford to lose
  • Past performance does not guarantee future results
  • The AI analysis is not financial advice
  • Monitor the system regularly

Troubleshooting

Connection Issues

  • Ensure FutuOpenD is running and logged in
  • Check FUTU_IP and FUTU_PORT in .env
  • Verify API access is enabled in FutuOpenD settings

Ollama Issues

  • Verify Ollama is running: ollama list
  • Check model is downloaded: ollama pull qwen2.5:14b
  • Test connection: curl http://localhost:11434/api/tags

Trading Errors

  • Check logs in logs/ directory
  • Verify sufficient buying power
  • Ensure market is open during trading hours

License

MIT License - See LICENSE file for details

Contributing

Contributions welcome! Please open issues or submit pull requests.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages