FenixAI_tradingBot
FenixAI_tradingBot copied to clipboard
Fenix Ai Trading Bot with crew ai and ollama
๐ฆ FenixAI Trading Bot v2.0
Autonomous Multi-Agent Cryptocurrency Trading System with Self-Evolving Memory
An advanced trading system powered by multiple specialized AI agents that collaborate to analyze markets, manage risk, and execute trades on Binance Futures. Features ReasoningBank memory system for self-evolving agent capabilities.

๐ Documentation ยท ๐ Quick Start ยท ๐๏ธ Architecture ยท ๐ Changelog ยท ๐ Paper
โ ๏ธ WARNING: This is a BETA project. Fenix is under active development, is not yet profitable, and may not work as expected. Use at your own risk!
๐ฆ A Message from the Creator (v2.0)
Hello, it has been 6 months since I launched the first version of Fenix. I have been on an incredible journey for six months, learning a ton about programming, LLMs, AI papers, and above all, experimenting a lot with Fenix.
I have been doing hundreds of tests with both paper trading and live trading, testing different LLM configurations, different cryptocurrencies, different timeframes, adding and removing more agents, and I have learned a lot. I believe the main advantage of Fenix is that it evolves over time along with LLMs; they are getting smarter and it shows in their trading decisions.
So far, the best performance I have obtained is with large models of over 50b, but the main problem is that they are expensive and difficult to maintain privacy. I think the best option currently between price/privacy and large models is the Ollama cloud models which are expanding more and more, but without a doubt, I believe the best option will be to fine-tune several small models. Right now I am experimenting with that configuration.
But I didn't want to leave you any longer without updates, so this is Version 2.0. It now includes a nice and intuitive local page to make it more accessible to use. Regarding performance, what has improved the most is undoubtedly the Reasoning Bank; it helps agents not to make the same mistakes repeatedly and also to be right more often thanks to remembering. I am also experimenting with the new HOPE model that learns as it is used, but I still don't have a clear result to share.
While I continue investigating and improving Fenix, I hope this new version can be useful to at least one person as inspiration or to test the new limits of trading.
Thank you for taking the time to read my words. I would appreciate it if you leave me a star, a comment in discussion, a contribution, advice, or some change on my BuyMeACoffee page.
Thank you very much, Ganador
โญ Star History
โจ What's New in v2.0
Complete architectural overhaul - Migrated from CrewAI to LangGraph for more robust and flexible agent orchestration.
| Feature | v1.0 (June 2025) | v2.0 (December 2025) |
|---|---|---|
| Orchestration | CrewAI | LangGraph (State Machine) |
| Memory System | Basic TradeMemory | ReasoningBank + LLM-as-Judge |
| Visual Analysis | Static screenshots | Chart Generator + Playwright TradingView Capture |
| LLM Providers | Ollama only | Ollama, MLX, Groq, HuggingFace |
| Frontend | Flask Dashboard | React + Vite + TypeScript |
| Agent Weighting | Static | Dynamic (performance-based) |
| Security | Basic | SecureSecretsManager + Path Validation |
| Real-time | Polling | WebSocket + Socket.IO |
Notable security and developer workflow improvements
- API binds to
127.0.0.1by default to avoid accidental public exposure. To bind to all interfaces intentionally, setALLOW_EXPOSE_API=true. - Demo accounts are not seeded by default; set
CREATE_DEMO_USERS=truefor local development. DEFAULT_DEMO_PASSWORDandDEFAULT_ADMIN_PASSWORDmay be used for local testing; avoid using them in production.- We added
DEVELOPMENT.mdandRELEASE_CHECKLIST.mdto help developers follow the release process and avoid secrets leaks. - Archived internal reports are now in
docs/archives/reports/to reduce root clutter.
๐ง How It Works
FenixAI employs a multi-agent architecture where specialized AI agents collaborate to make trading decisions. The system is built on three core pillars:
- Multi-Agent Collaboration: Specialized agents analyze different aspects of the market
- Self-Evolving Memory: ReasoningBank enables agents to learn from past decisions
- Dynamic Risk Management: Real-time circuit breakers and position sizing
๐งช ReasoningBank: Self-Evolving Agent Memory
FenixAI implements the ReasoningBank architecture based on the research paper "ReasoningBank: Scaling Agent Self-Evolving with Reasoning Memory". This novel memory framework:
- Distills reasoning strategies from successful and failed trading decisions
- Semantic retrieval of relevant historical context during analysis
- LLM-as-Judge evaluates decision quality and provides feedback
- Continuous learning enables agents to improve over time
- Embeddings-based search finds similar market conditions from history
# Example: Agent retrieves relevant context from ReasoningBank
context = reasoning_bank.get_relevant_context(
agent_name="technical_analyst",
current_prompt=market_analysis_prompt,
limit=3
)
# Agent uses historical insights to make better decisions
๐ Visual Analysis System
The Visual Agent supports two modes for chart analysis:
| Mode | Description | Use Case |
|---|---|---|
| Chart Generator | Generates charts with indicators using mplfinance |
Fast, offline, customizable |
| Playwright Capture | Captures TradingView screenshots via browser automation | Real TradingView charts, advanced indicators |
Both modes produce base64-encoded images that are analyzed by vision-capable LLMs (LLaVA, GPT-4V, etc.).

๐ค The Agent Team
| Agent | Responsibility | Inputs | Output |
|---|---|---|---|
| Technical Analyst | RSI, MACD, ADX, SuperTrend, EMA crossovers | OHLCV data, indicators | Signal + confidence |
| Visual Analyst | Chart pattern recognition, support/resistance | Generated charts / TradingView screenshots | Pattern analysis |
| Sentiment Analyst | News, Twitter, Reddit, Fear & Greed Index | Social feeds, news APIs | Market sentiment |
| QABBA Agent | Bollinger Bands, volatility, squeeze detection, OBI, CVD | Microstructure data | Volatility signal |
| Decision Agent | Weighted consensus from all agents | All agent reports | Final trade decision |
| Risk Manager | Circuit breakers, position sizing, drawdown limits | Portfolio state, decision | Approved/vetoed trade |
๐ Agent Workflow
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FENIX AI v2.0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Frontend โโโโโบโ FastAPI + Socket.IO โ โ
โ โ React/Vite โ โ (Real-time) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ TRADING ENGINE โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ LangGraph Orchestrator โ โ โ
โ โ โ (State Machine) โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ โ โ โ โ
โ โ โโโโโโโผโโโโโโ โโโโโโโผโโโโโโ โโโโโโโผโโโโโโ โโโโโโโผโโโโโโ โ โ
โ โ โ Technical โ โ Visual โ โ Sentiment โ โ QABBA โ โ โ
โ โ โ Agent โ โ Agent โ โ Agent โ โ Agent โ โ โ
โ โ โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ โ โ
โ โ โ โ โ โ โ โ
โ โ โโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโ โ โ
โ โ โ Decision Agent + Risk Manager โ โ โ
โ โ โ (Dynamic Weighting + LLM-as-Judge) โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ MEMORY LAYER โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ ReasoningBank โ โ Trade Memory โ โ LLM-as-Judge โ โ โ
โ โ โ (Semantic Search)โ โ (History) โ โ (Self-Evaluation) โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ EXECUTION LAYER โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Binance Client โ โ Order Executor โ โ Market Data โ โ โ
โ โ โ (REST + WS) โ โ (Paper/Live) โ โ (Real-time) โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Key Features
Multi-Agent Collaboration
- ๐ค 6 Specialized Agents working in parallel and sequence
- ๐ Dynamic Weighting based on agent performance history
- ๐ฏ Consensus-Based Decisions with configurable thresholds
Self-Evolving Memory (ReasoningBank)
- ๐ง Semantic Memory Search using embeddings
- ๐ Experience Distillation from successes and failures
- โ๏ธ LLM-as-Judge for decision quality evaluation
- ๐ Continuous Improvement over time
Visual Analysis
- ๐ Chart Generator with mplfinance (RSI, MACD, Bollinger, etc.)
- ๐ผ๏ธ TradingView Capture via Playwright browser automation
- ๐๏ธ Vision LLM Integration (LLaVA, GPT-4V compatible)
Multi-Provider LLM Support
- ๐ฆ Ollama - Local inference with any GGUF model
- ๐ MLX - Apple Silicon optimized (M1/M2/M3)
- โก Groq - Ultra-fast cloud inference
- ๐ค HuggingFace - Serverless inference API
Trading Features
- ๐ Binance Futures integration (testnet & live)
- ๐ก๏ธ Paper Trading mode by default
- โ ๏ธ Circuit Breakers for risk management
- ๐ Multi-Timeframe Analysis support
Real-Time Dashboard
- ๐ React + TypeScript modern frontend
- ๐ WebSocket real-time updates
- ๐ฑ Responsive Design with TailwindCSS
- ๐ Live Charts and agent performance metrics
๐ Quick Start
Prerequisites
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.10+ | 3.11 recommended |
| Node.js | 18+ | For frontend |
| Ollama | Latest | Local LLM inference |
| RAM | 16GB+ | 32GB for larger models |
| GPU | Optional | CUDA for faster inference |
| Apple Silicon | M1/M2/M3 | MLX support for optimized inference |
Optional Services
- Binance Account - For live/testnet trading
- Groq API Key - For cloud LLM inference
- HuggingFace Token - For HF Inference API
- Playwright - For TradingView chart capture
Installation
# Clone the repository
git clone https://github.com/Ganador1/FenixAI_tradingBot.git
cd FenixAI_tradingBot
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# Install dependencies
pip install -e ".[dev,vision,monitoring]"
# Configure environment
cp .env.example .env
# Edit .env with your API keys
# Pull required Ollama models
ollama pull qwen3:8b
Running FenixAI
# Terminal 1: Start the backend with API
python run_fenix.py --api
# Terminal 2: Start the frontend
cd frontend && npm install && npm run client:dev
Access the dashboard at: http://localhost:5173
Note: For safety, the API will bind to 127.0.0.1 by default. To allow external binding, set ALLOW_EXPOSE_API=true.
If you want to enable demo accounts for local development, set CREATE_DEMO_USERS=true and (optionally) DEFAULT_DEMO_PASSWORD to control the demo password. Avoid enabling demo users in production.
๐ Release v2.0 & Security Highlights
- This release improves security defaults: API binds to
127.0.0.1by default, demo users are gated, and secrets scanning is included in the developer workflow. - Please follow
RELEASE_CHECKLIST.mdbefore final releases. Dev-focused run instructions are inDEVELOPMENT.md. - Archived development reports can be found in
docs/archives/reports/. - Demo credentials information moved to:
docs/security/docs/security/DEMO_CREDENTIALS.md.
CLI Options
python run_fenix.py --help
python run_fenix.py # Paper trading (default)
python run_fenix.py --symbol ETHUSDT # Different symbol
python run_fenix.py --timeframe 5m # Different timeframe
python run_fenix.py --no-visual # Disable visual agent
python run_fenix.py --mode live --allow-live # Live trading (โ ๏ธ real money)
๐๏ธ Architecture
Project Structure
FenixAI/
โโโ run_fenix.py # Main entry point
โโโ pyproject.toml # Python project configuration
โโโ package.json # Node.js dependencies (API)
โ
โโโ src/
โ โโโ analysis/ # Technical analysis modules
โ โโโ api/ # FastAPI server & WebSocket
โ โโโ cache/ # Caching utilities
โ โโโ core/ # LangGraph orchestrator
โ โ โโโ langgraph_orchestrator.py
โ โโโ dashboard/ # Trading dashboard backend
โ โโโ inference/ # Multi-provider LLM clients
โ โ โโโ providers/ # Ollama, MLX, Groq, HuggingFace
โ โ โโโ reasoning_judge.py
โ โ โโโ unified_inference_client.py
โ โโโ memory/ # Memory systems
โ โ โโโ reasoning_bank.py # ReasoningBank implementation
โ โ โโโ trade_memory.py # Trade history storage
โ โโโ models/ # Data models & schemas
โ โโโ monitoring/ # System monitoring
โ โโโ pipeline/ # Data processing pipelines
โ โโโ prompts/ # Agent prompt templates
โ โโโ risk/ # Risk management module
โ โโโ services/ # External service integrations
โ โโโ tools/ # Agent tools
โ โ โโโ chart_generator.py # Chart generation with mplfinance
โ โ โโโ chart_generator_playwright.py
โ โ โโโ tradingview_playwright_capture.py
โ โ โโโ fear_greed.py # Fear & Greed Index
โ โ โโโ twitter_scraper.py
โ โ โโโ reddit_scraper.py
โ โโโ trading/ # Trading engine
โ โ โโโ engine.py # Main trading engine
โ โ โโโ binance_client.py # Binance Futures client
โ โ โโโ executor.py # Order execution
โ โโโ utils/ # Utility functions
โ
โโโ config/
โ โโโ fenix.yaml # Main configuration
โ โโโ llm_providers.yaml # LLM provider profiles
โ โโโ settings.py # Environment settings
โ
โโโ frontend/ # React + Vite dashboard
โ โโโ components/ # React components
โ โโโ pages/ # Page components
โ โโโ hooks/ # Custom React hooks
โ โโโ stores/ # State management
โ โโโ providers/ # Context providers
โ
โโโ api/ # Express.js API (optional)
โโโ docs/ # Documentation
โโโ tests/ # Test suite
โโโ scripts/ # Utility scripts
โโโ logs/ # Application logs
Technology Stack
| Layer | Technology | Details |
|---|---|---|
| Orchestration | LangGraph, LangChain | State machine-based agent workflow |
| LLM Inference | Ollama, MLX, Groq, HuggingFace | Multi-provider with automatic fallback |
| Backend | Python 3.10+, FastAPI, Socket.IO | Async REST API + WebSocket |
| Frontend | React 18, Vite, TypeScript, TailwindCSS | Modern SPA with real-time updates |
| Exchange | Binance Futures (ccxt, python-binance) | Testnet & production support |
| Memory | ReasoningBank | Semantic search + embeddings + LLM-as-Judge |
| Visual Tools | mplfinance, Playwright | Chart generation + TradingView capture |
| Database | SQLite | Trade history & reasoning persistence |
| Monitoring | Custom dashboard | System metrics, agent performance |
๐ Configuration
Main Configuration (config/fenix.yaml)
trading:
symbol: BTCUSDT
timeframe: 15m
max_risk_per_trade: 0.02
agents:
enable_technical: true
enable_qabba: true
enable_visual: true # Requires vision model
enable_sentiment: true # Requires news APIs
technical_weight: 0.30
qabba_weight: 0.30
consensus_threshold: 0.65
LLM Provider Profile
You can choose a provider profile in config/llm_providers.yaml or by setting the environment variable LLM_PROFILE. For example, to use the Groq Free profile:
export GROQ_API_KEY=gsk_...
export LLM_PROFILE=groq_free
export LLM_ALLOW_NOOP_STUB=1 # optional -- fallback to noop in dev
If Groq packages (langchain_groq) or local providers (e.g., langchain_ollama) are not installed, Fenix will try the configured fallback provider. If none are available and LLM_ALLOW_NOOP_STUB is 1, the system will initialize a Noop stub so the graph can still run for local testing.
LLM Providers (config/llm_providers.yaml)
active_profile: "all_local" # Options: all_local, mixed_providers, mlx_optimized, all_cloud
all_local:
technical:
provider_type: "ollama_local"
model_name: "qwen3:8b"
temperature: 0.1
Environment Variables
| Variable | Description | Default |
|---|---|---|
BINANCE_API_KEY |
Binance API key | - |
BINANCE_SECRET_KEY |
Binance secret key | - |
LLM_PROFILE |
LLM provider profile to use | all_local |
GROQ_API_KEY |
Groq API key (for cloud inference) | - |
HF_TOKEN |
HuggingFace token | - |
ALLOW_EXPOSE_API |
Allow API to bind to all interfaces | false |
CREATE_DEMO_USERS |
Enable demo user creation | false |
LLM_ALLOW_NOOP_STUB |
Fallback to noop LLM for testing | 0 |
ENABLE_VISUAL_AGENT |
Enable chart analysis agent | true |
ENABLE_SENTIMENT_AGENT |
Enable news/social analysis | true |
๐งช Testing
# Run all tests
pytest
# Run specific test file
pytest tests/test_agents.py -v
# Run with coverage
pytest --cov=src --cov-report=html
# Run integration tests
pytest tests/test_integration.py -v
# Run LangGraph orchestrator tests
pytest tests/test_langgraph_orchestrator.py -v
๐ Documentation
| Document | Description |
|---|---|
| QUICKSTART.md | Getting started guide |
| ARCHITECTURE.md | System architecture |
| AGENTS.md | Agent system documentation |
| API.md | REST API reference |
| CHANGELOG.md | Version history |
| DEVELOPMENT.md | Developer guide |
| CONTRIBUTING.md | Contribution guidelines |
๐ก๏ธ Security Considerations
Trading Safety
| Feature | Description |
|---|---|
| Paper Trading Default | Always starts in paper mode - no real money at risk |
| Live Trading Safeguard | Requires explicit --allow-live flag |
| Circuit Breakers | Automatic trading halt on excessive losses |
| Position Limits | Configurable maximum position sizes |
| Daily Loss Limits | Stop trading when daily loss threshold reached |
Application Security
| Feature | Description |
|---|---|
| API Key Encryption | SecureSecretsManager for encrypted storage |
| Local API Binding | API binds to 127.0.0.1 by default |
| Path Validation | Prevents path traversal attacks |
| Rate Limiting | Respects Binance API limits |
| Demo User Gating | Demo accounts disabled by default |
| Secrets Scanning | Pre-commit hooks for secret detection |
๐ค Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Development Setup
# Install dev dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run linting
ruff check src/
# Run type checking
mypy src/
โ ๏ธ Disclaimer
This software is for educational and research purposes only.
- โ ๏ธ Cryptocurrency trading involves substantial risk of loss
- ๐ Past performance is not indicative of future results
- ๐ธ Never trade with money you cannot afford to lose
- ๐ซ The authors are not responsible for any financial losses
- ๐งช Always test thoroughly on paper trading before considering live trading
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Copyright 2025 Ganador1
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
๐ Acknowledgments
Technologies
- LangGraph - Agent orchestration framework
- Ollama - Local LLM inference
- MLX - Apple Silicon optimized ML framework
- Groq - Ultra-fast LLM inference
- HuggingFace - Model hub and inference
- Binance - Exchange API
- Playwright - Browser automation for TradingView capture
- FastAPI - Modern Python web framework
- React - Frontend framework
- TailwindCSS - Utility-first CSS
- mplfinance - Financial chart generation
๐ Research Papers
- ReasoningBank: "ReasoningBank: Scaling Agent Self-Evolving with Reasoning Memory" - Ouyang et al., 2025
- Core memory architecture enabling agents to learn from past decisions
- Implements semantic retrieval, LLM-as-Judge, and memory-aware test-time scaling
๐ฌ Contact & Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with โค๏ธ by Ganador1
If you find this project useful, please consider giving it a โญ!
โฌ Back to Top