An AI-powered autonomous trading bot for Binance Futures that uses Claude AI to analyze market data, execute trades, and manage risk in real-time.
Shark Bot is a sophisticated autonomous cryptocurrency trading system that combines advanced AI reasoning with professional risk management. It continuously monitors multiple cryptocurrency markets, performs technical analysis, and executes trades on Binance Futures (USDT-M) with strict risk controls.
- ๐ค AI-Powered Decision Making: Uses Claude via AWS Bedrock for intelligent market analysis
- ๐ Multi-Currency Trading: Supports BTC, ETH, SOL, BNB, XRP, and DOGE
- โก Real-time Technical Analysis: RSI, MACD, EMA, ATR, Volume analysis, and Open Interest tracking
- ๐ก๏ธ Professional Risk Management: Configurable position sizing, stop-loss requirements, and leverage limits
- ๐ Autonomous Operation: Automated scheduling with configurable execution intervals
- ๐ Performance Tracking: Daily PnL, win rate, and trade history monitoring
- ๐๏ธ Django Admin Dashboard: Full control and monitoring through web interface
- ๐ Observability: Integrated with Langfuse for AI workflow tracing and monitoring
- ๐ฐ News Aggregation: Integrated TrendRadar for real-time crypto news from 35+ platforms
- ๐ณ Docker Support: Easy deployment with Docker Compose
The bot uses a workflow-based architecture built with LlamaIndex:
- Balance Check: Validates account balance and trading capability
- Market Data Collection: Concurrent data gathering for all configured currencies
- Position Aggregation: Consolidates open positions, orders, and daily performance
- AI Analysis & Execution: Claude AI analyzes market conditions and executes trades
- Result Storage: Saves execution results, strategy, and performance metrics
graph TB
subgraph SCHEDULERS["โฐ SCHEDULERS"]
APScheduler["APScheduler<br/>(Ejecuta cada minuto)"]
end
subgraph WORKFLOW["๐ TRADING FUTURES WORKFLOW"]
Start["Inicio"]
CheckBalance["1. Check Balance<br/>(Verifica fondos USDT)"]
CollectData["2. Collect Market Data<br/>(Concurrente para todas las monedas)"]
AggregatePositions["3. Aggregate Positions<br/>(Consolida datos + posiciones abiertas)"]
ExecuteAgent["4. Execute Trading Agent<br/>(Claude AI toma decisiones)"]
SaveResults["5. Save Results<br/>(Guarda en DB)"]
end
subgraph AGENT["๐ค AI AGENT - Claude 4.5 Sonnet"]
SystemPrompt["System Prompt<br/>(Estrategia + Risk Management)"]
AgentTools["Agent Tools"]
ReasoningEngine["Reasoning Engine<br/>(Claude via AWS Bedrock)"]
end
subgraph TOOLS["๐ ๏ธ HERRAMIENTAS DEL AGENTE"]
BinanceTools["Binance Tools"]
PythonTools["Python Tools"]
TrendRadarTools["TrendRadar Tools (MCP)"]
subgraph BinanceToolsList["Binance Trading Functions"]
OpenLong["open_long_position<br/>๐ Abre posiciรณn larga"]
OpenShort["open_short_position<br/>๐ Abre posiciรณn corta"]
ClosePosition["close_position<br/>๐ Cierra posiciรณn"]
end
subgraph PythonToolsList["Python Code Execution"]
ExecutePython["execute_python_code<br/>๐งฎ Cรกlculos matemรกticos"]
end
subgraph TrendRadarToolsList["News Aggregation"]
GetNews["get_news<br/>๐ฐ Noticias de 35+ plataformas"]
end
end
subgraph BINANCE["๐ BINANCE CLIENT"]
BinanceAPI["Binance Futures API"]
MarketData["Market Data<br/>(Precio, RSI, MACD, EMA, ATR)"]
OrderExecution["Order Execution"]
AccountInfo["Account Info"]
end
subgraph DATABASE["๐พ DATABASE (PostgreSQL)"]
TradingExecutions["TradingWorkflowExecution"]
TradingOperations["TradingOperation"]
end
subgraph NEWS["๐ฐ NEWS AGGREGATION"]
TrendRadar["TrendRadar<br/>(35+ plataformas chinas)"]
NewsDB["SQLite DB"]
end
subgraph MONITORING["๐ OBSERVABILITY"]
Langfuse["Langfuse<br/>(AI workflow tracing)"]
DjangoAdmin["Django Admin<br/>(Dashboard)"]
end
%% Flujo principal
APScheduler -->|"Trigger cada minuto"| Start
Start --> CheckBalance
CheckBalance -->|"Balance OK"| CollectData
CollectData -->|"BTC, ETH, SOL, BNB, XRP, DOGE"| AggregatePositions
AggregatePositions -->|"Datos agregados"| ExecuteAgent
ExecuteAgent --> SystemPrompt
SystemPrompt --> ReasoningEngine
ReasoningEngine <-->|"Usa herramientas"| AgentTools
AgentTools --> BinanceTools
AgentTools --> PythonTools
AgentTools --> TrendRadarTools
BinanceTools --> OpenLong
BinanceTools --> OpenShort
BinanceTools --> ClosePosition
PythonTools --> ExecutePython
TrendRadarTools --> GetNews
GetNews -->|"Lee noticias"| NewsDB
OpenLong -->|"Ejecuta orden"| BinanceAPI
OpenShort -->|"Ejecuta orden"| BinanceAPI
ClosePosition -->|"Ejecuta orden"| BinanceAPI
ExecuteAgent -->|"Decisiรณn tomada"| SaveResults
SaveResults --> TradingExecutions
BinanceAPI --> MarketData
BinanceAPI --> OrderExecution
BinanceAPI --> AccountInfo
MarketData -->|"Datos tรฉcnicos"| CollectData
AccountInfo -->|"Balance + Posiciones"| CheckBalance
OrderExecution -->|"Registra operaciรณn"| TradingOperations
TrendRadar -->|"Noticias cripto"| NewsDB
NewsDB -.->|"Contexto adicional"| SystemPrompt
ExecuteAgent -.->|"Trace de workflow"| Langfuse
TradingExecutions -.->|"Visualiza"| DjangoAdmin
TradingOperations -.->|"Visualiza"| DjangoAdmin
- Python 3.12+
- Docker & Docker Compose (recommended)
- Binance account with Futures trading enabled
- AWS account with Bedrock access (Claude)
- Langfuse account (for monitoring)
-
Clone the repository
git clone https://github.com/macacoai/sharkbot.git cd trading -
Copy environment configuration
cp env.local .env
-
Configure environment variables
Edit
.envwith your credentials:# AWS Configuration (for Claude AI via Bedrock) AWS_ACCESS_KEY_ID=your_aws_key AWS_SECRET_ACCESS_KEY=your_aws_secret AWS_DEFAULT_REGION=us-east-1 # Langfuse (AI Observability) LANGFUSE_PUBLIC_KEY=your_langfuse_public_key LANGFUSE_SECRET_KEY=your_langfuse_secret_key LANGFUSE_HOST=https://us.cloud.langfuse.com # Binance Trading Configuration BINANCE_API_KEY=your_binance_api_key BINANCE_API_SECRET=your_binance_api_secret # Database POSTGRES_USER=postgres_user POSTGRES_PASSWORD=postgres_password POSTGRES_DB=app_db
-
Start with Docker Compose (Recommended)
docker-compose up -d
The API will be available at
http://localhost:8099 -
Or run locally
# Install dependencies pip install -r requirements/base.txt # Run migrations python manage.py migrate # Create superuser for admin access python manage.py createsuperuser # Start the server python manage.py runserver
SharkBot integrates with TrendRadar, a news aggregation tool that monitors 35+ platforms for crypto and trading-related news.
What it provides:
- Real-time news aggregation from Chinese platforms (Weibo, Douyin, Baidu, etc.)
- Keyword filtering for crypto/trading topics (BTC, ETH, SOL, etc.)
- SQLite database storage for news data
- Web interface at
http://localhost:8080 - Optional AI analysis via MCP server
Included Services:
trend-radar: Main news crawler servicetrend-radar-mcp: AI analysis service (optional)
Configuration:
- Keywords: Edit
trendradar/config/frequency_words.txt - Settings: Edit
trendradar/config/config.yaml - Data storage:
trendradar/output/(SQLite, TXT, HTML)
Accessing News Data:
From your Python code, you can read the SQLite database:
import sqlite3
from pathlib import Path
# Find the latest database file
output_dir = Path("trendradar/output")
db_files = list(output_dir.glob("**/*.db"))
latest_db = max(db_files, key=lambda p: p.stat().st_mtime)
# Connect and query
conn = sqlite3.connect(latest_db)
cursor = conn.cursor()
cursor.execute("SELECT * FROM news WHERE created_at > datetime('now', '-1 hour')")
recent_news = cursor.fetchall()
## ๐ Usage
### Starting the Trading Bot
The bot can be run in two ways:
#### 1. Manual Execution (for testing)
```bash
python main.pyThis will run a single trading cycle and exit.
The bot includes an APScheduler that runs the trading workflow at configured intervals:
# In your Django app startup (apps/tradings/apps.py)
from apps.tradings.scheduler import start_scheduler
start_scheduler()The scheduler is automatically started when Django loads the tradings app.
- Navigate to
http://localhost:8099/admin - Log in with your superuser credentials
- You can view:
- Trading Workflow Executions: Full history of all bot runs
- Trading Operations: Individual trade records (open/close positions)
- Market data and analysis: Agent reasoning and decisions
Access the HTML dashboard at http://localhost:8099/ (or view index.html) to see:
- Real-time balance and PnL
- Win rate and trade statistics
- Market data with technical indicators
- Open positions
- AI agent analysis and reasoning
The trading strategy is defined in apps/genflows/prompts/trading_futures/trad.txt. You can customize:
- Risk parameters
- Technical indicators
- Trading rules
- Decision-making framework
The system prompt is rendered from templates in apps/genflows/prompts/.
All AI workflow executions are traced in Langfuse, providing:
- Complete conversation history
- Token usage and costs
- Agent reasoning chains
- Tool usage tracking
- Performance metrics
Access your Langfuse dashboard to monitor AI performance.
The admin interface provides:
- Execution history with full market data snapshots
- Trade logs with entry/exit prices and PnL
- Agent responses and strategies
- Error logs and debugging information
- Cryptocurrency trading carries substantial risk
- Past performance does not guarantee future results
- Use at your own risk - this is experimental software
- Never trade with money you can't afford to lose
- The bot can make mistakes - always monitor it
- Market conditions can change rapidly
shark-bot/
โโโ apps/
โ โโโ tradings/ # Trading models, admin, scheduler
โ โโโ genflows/ # AI workflows and agents
โ โ โโโ trading_futures/ # Trading workflow implementation
โ โโโ accounts/ # User management
โโโ config/ # Django configuration
โโโ services/ # External service integrations
โ โโโ binance_client.py # Binance API wrapper
โโโ requirements/ # Python dependencies
โโโ docker-compose.yml # Docker setup
โโโ Dockerfile # Container definition
โโโ main.py # Standalone execution script
TradingFuturesWorkflow: Main workflow orchestratorBinanceClient: Binance API integration with error handlingBinanceTools: MCP tools for AI agent to execute tradesAgent: AI agent configuration and prompt renderingTradingWorkflowExecution: Django model for execution storage
The project uses:
flake8for lintingpre-commithooks for code quality- Django best practices
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with LlamaIndex for AI workflows
- Uses Claude via AWS Bedrock
- Powered by Binance API
- Monitored with Langfuse
- Uses python-binance SDK
- Issues: Please use GitHub Issues for bug reports or feature requests
- Discussions: Use GitHub Discussions for questions and ideas
Que cuando hable te hable de los ultimos registros