Skip to content

heichenya/nebulaeye

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NebulaEye Icon

πŸš€ NebulaEye

Crypto Multi-Factor Prediction & Intelligent Trading Alert System


🧠 1. Project Overview

NebulaEye is a quantitative decision support system designed for crypto traders. It automates market data collection, performs multi-factor analysis using a continuous scoring engine, integrates AI models for interpretation, and provides actionable trading advice.

Key Features:

  • Multi-Token Analysis: Supports BTC, ETH, and more.
  • Multi-Channel Notifications: Real-time alerts via Lark Bot (Feishu) and Telegram.
  • AI-Powered Insights: Integrates OpenAI/DeepSeek for natural language analysis.
  • Dual Position Modes: Supports both Spot and Futures trading.
  • Continuous Scoring: Uses non-linear functions to map indicators to granular scores (no more hard thresholds).
  • Macro-Aware: Dynamically adjusts scores based on S&P 500 and DXY performance.
  • Hybrid Strategy: Combines Quant signals with AI reasoning for robust decision-making.

🧩 2. Features

Feature Status Description
Multi-Token Support βœ… Supports BTC/USDT, ETH/USDT, and more.
Lark & Telegram Alerts βœ… Formatted interactive cards with icons and emojis.
Dashboard βœ… Streamlit-based UI for configuration and visualization.
Position Tracking & Simulation βœ… Track manual/auto positions in DB; trading engine runs in simulation/backtest modes (sim_spot, sim_future).
Continuous Scoring βœ… Granular scoring for RSI, Bollinger, Funding, etc.
Macro Integration βœ… Continuous score modifier based on SPX/DXY.
AI Analysis βœ… GPT-4o/DeepSeek integration for trading advice.
Hybrid Simulation βœ… Paper trading system tracking Quant, AI, and Hybrid strategies.
Layered Optimization βœ… 3-stage optimization: Weights β†’ Macro β†’ Thresholds.
Backtesting System βœ… Simulate strategy on historical data with detailed metrics.

πŸ“Š 3. Analysis Logic & Indicators

NebulaEye uses a Continuous Scoring Engine that maps 11 data factors to a normalized score range [-100, +100]. Unlike traditional threshold-based systems, it uses linear/non-linear functions to capture subtle market shifts.

πŸ”Ή Crypto Environment (Micro Factors)

  1. RSI (Relative Strength Index):
    • Logic: Continuous mapping. <30 (Oversold) β†’ Positive Score; >70 (Overbought) β†’ Negative Score.
  2. Bollinger Bands:
    • Logic: Uses %B. Price near Lower Band β†’ Bullish; Near Upper Band β†’ Bearish.
  3. Funding Rate:
    • Logic: High positive rate β†’ Bearish (Overcrowded Longs); Negative rate β†’ Bullish (Short Squeeze potential).
  4. Open Interest (OI) Change:
    • Logic: Rising OI + Rising Price β†’ Bullish; Rising OI + Falling Price β†’ Bearish.
  5. Long/Short Ratio (Global):
    • Logic: Contrarian indicator. High ratio (>1.5) β†’ Bearish; Low ratio (<0.8) β†’ Bullish.
  6. Top Trader Long/Short Ratio:
    • Logic: Smart money follower. High ratio β†’ Bullish.
  7. Taker Buy/Sell Ratio:
    • Logic: Volume aggression. >1.0 β†’ Bullish; <1.0 β†’ Bearish.
  8. Order Book Imbalance:
    • Logic: Bid/Ask volume ratio. >1.0 β†’ Buy Pressure; <1.0 β†’ Sell Pressure.
  9. MACD:
    • Logic: Histogram strength and crossover direction.
  10. Fear & Greed Index:
    • Logic: Extreme Fear (<20) β†’ Bullish (Buy the dip); Extreme Greed (>80) β†’ Bearish.

πŸ”Ή Macro Environment (Macro Factor)

  1. Macro Modifier (SPX/DXY):
    • Logic: Continuous multiplier based on S&P 500 daily change.
    • Formula: Score = Base_Score * (1.0 + SPX_Change% * 0.5)
    • Effect: Amplifies signals when macro aligns; dampens signals when macro diverges.

β™ŸοΈ 4. Strategy & Simulation

NebulaEye employs a Hybrid Decision System that combines rigorous quantitative analysis with flexible AI reasoning.

πŸ€– Hybrid Strategy

  1. Quant Signal: Generated by the Scoring Engine (e.g., "Bearish" with score -35).
  2. AI Signal: Generated by LLM analysis of news, sentiment, and technicals (e.g., "Neutral" due to conflicting signals).
  3. Hybrid Decision:
    • Strong Buy/Sell: When Quant and AI align (e.g., both Bullish).
    • Watch/Light: When one is Bullish and the other Neutral.
    • Conflict: When signals oppose (e.g., Quant Bullish, AI Bearish) β†’ System holds or reduces risk.

πŸ’Ό Simulation Engine

The system runs a continuous paper trading simulation to validate strategies:

  • Quant Portfolio: Trades solely based on score thresholds.
  • AI Portfolio: Trades based on LLM recommendations.
  • Hybrid Portfolio: Trades based on the combined decision matrix.
  • Performance Tracking: Real-time PnL, win rate, and drawdown tracking for all three portfolios.

🎯 5. Optimization System

To avoid overfitting, NebulaEye uses a Layered Decoupling optimization strategy:

Stage 1: Core Weights (Micro)

  • Goal: Find the best factor weights (RSI, Funding, etc.) to capture market relative strength.
  • Method: Genetic Algorithm / Grid Search.
  • Constraint: Macro disabled, thresholds fixed.

Stage 2: Macro Calibration (Macro)

  • Goal: Filter out systemic risk (e.g., SPX crashes).
  • Method: Optimize macro_modifier parameters to minimize Max Drawdown during historical crashes.
  • Constraint: Weights locked.

Stage 3: Threshold Tuning (Execution)

  • Goal: Determine the optimal Entry/Exit scores.
  • Method: Analyze score distribution to find the "sweet spots" for high-probability trades.
  • Constraint: Weights and Macro locked.

πŸ› οΈ 6. Installation & Usage

Prerequisites

  • Python 3.12+
  • Docker & Docker Compose (Optional)

πŸš€ Quick Start (Using Makefile)

  1. Install dependencies

    make install
  2. Configuration

    • Create .env and add your keys: OPENAI_API_KEY, optional OPENAI_BASE_URL, LARK_WEBHOOK_URL, TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, BINANCE_API_KEY, BINANCE_API_SECRET.
    • Edit config/config.yaml to customize parameters (see config section).
  3. Run the Application

    # Start the main analysis scheduler
    make run
    
    # Start the Streamlit Dashboard
    make dashboard

🐳 7. Development & Docker

Environment Setup

# Create .env (see env vars in Quick Start / Config)
touch .env
# Then add OPENAI_API_KEY=..., LARK_WEBHOOK_URL=..., etc.

Docker Commands

make docker-up      # Start containers
make docker-logs    # View logs
make docker-down    # Stop containers
make docker-build   # (Re)build image

πŸ§ͺ Optimization & Testing

# 1. Optimize Factor Weights (Stage 1)
make optimize-weight
make optimize-weight-30d     # Full 30d run

# 2. Optimize Macro Parameters (Stage 2)
make optimize-macro
make optimize-macro-30d      # Longer window

# 3. Optimize Thresholds (Stage 3)
make optimize-thresholds
make optimize-thresholds-30d

# Run Backtest
make backtest
make backtest-30d

# Simulation management CLI (reset/list/view versions)
python -m src.simulation.manage_simulation list
python -m src.simulation.manage_simulation reset --name v2 --type future --capital 15000
python -m src.simulation.manage_simulation view --token BTC/USDT

βš™οΈ 8. Configuration

The system is configurable via config/config.yaml and .env. Environment variables override YAML for keys: OPENAI_API_KEY, OPENAI_BASE_URL, LARK_WEBHOOK_URL, TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, BINANCE_API_KEY, BINANCE_API_SECRET.

Backtesting shares the analysis.simulation block (capital, leverage, thresholds, fees, hybrid rules) so you configure once for both simulation and historical runs.

# System
language: zh

# Position mode (simulation only)
position_type: sim_future      # sim_spot | sim_future
position:
  mode: manual                 # manual | auto (auto only syncs balances; no live trading)
  api:
    key: ""
    secret: ""

# Market Data
market_data:
  source: binance
  symbols:
    - BTC/USDT
  timeframe: 30m

# Analysis
analysis:
  weights:
    rsi: 0.0
    bollinger: 1.0
    fear_greed: 0.5
    funding: 1.0
    orderbook: 0.0
    macd: 0.0
    long_short_ratio: 0.0
    taker_buy_sell_ratio: 0.0
    top_trader_long_short_ratio: 0.5
    open_interest_change: 0.0
  macro:
    enabled: true
    bearish_threshold: -2.0
    bullish_threshold: 1.0
    bearish_multiplier: 0.3
    bullish_multiplier: 1.2
  simulation:
    initial_capital: 10000.0
    leverage: 10.0
    entry_threshold: 50.0
    exit_threshold: 20.0
    risk_management_enabled: true
    stop_loss_pct: 10.0
    take_profit_pct: 10.0
    trading_fee_pct: 0.05
    hybrid_rules:
      bullish_bullish: strong_buy
      bullish_neutral: watch_light
      bullish_bearish: conflict
      neutral_bullish: neutral
      neutral_neutral: neutral
      neutral_bearish: neutral
      bearish_bullish: conflict
      bearish_neutral: watch_light
      bearish_bearish: strong_sell

# AI
ai:
  enabled: true
  model: deepseek-r1
  api_key: ""
  base_url: https://api.deepseek.com/v1

# Notifications
notification:
  lark:
    enabled: true
    webhook_url: ""
    interval_minutes: 0
    dnd_mode:
      enabled: false
      start_time: "01:00"
      end_time: "07:00"
  telegram:
    enabled: false
    bot_token: ""
    chat_id: ""
    interval_minutes: 0
    dnd_mode:
      enabled: false
      start_time: "01:00"
      end_time: "07:00"

# Scheduler
schedule:
  interval_minutes: 30
  run_on_start: true

# Token Icons
token_icons:
  BTC/USDT: https://cryptologos.cc/logos/thumbs/bitcoin.png?v=040

⚠️ Disclaimer

This software is for educational and research purposes only. It does not constitute financial advice. Cryptocurrency trading involves high risk. Please trade responsibly.


πŸ“„ License

MIT License

About

NebulaEye is a sophisticated quantitative trading system that fuses traditional technical analysis with modern AI. It moves beyond binary buy/sell signals by using continuous factor scoring and LLM-based sentiment analysis to navigate complex crypto markets.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages