-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add Crypto Trading Support with Multi-Environment Configs #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive cryptocurrency trading capabilities to the AI-Trader system with multi-environment support and advanced infrastructure.
Key Changes:
- Multi-environment detection and configuration system for local, VPS, Codespaces, and Docker deployments
- Real-time API cost tracking with budget management across GitHub Models (free), Anthropic Claude, and OpenAI
- Complete cryptocurrency trading agent supporting ByBit, Binance, Coinbase, and Kraken exchanges with derivatives/spot trading
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 31 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/environment_detector.py | Automatic runtime environment detection with platform-specific configurations |
| tools/cost_tracker.py | Real-time API cost tracking with per-provider monitoring and budget alerts |
| scripts/start_crypto_vps.sh | VPS production deployment script for 24/7 live trading |
| scripts/start_crypto_local.sh | Local development startup script with testnet mode |
| scripts/start_crypto_codespaces.sh | GitHub Codespaces-specific startup automation |
| scripts/deploy_oracle_vps.sh | Automated Oracle Cloud VPS deployment and initial setup |
| prompts/agent_prompt_crypto.py | Specialized crypto trading prompts with 24/7 market awareness |
| data/merge_crypto_jsonl.py | Utility to merge individual crypto JSON files into unified JSONL format |
| configs/crypto_config_vps.json | VPS production configuration with live trading settings |
| configs/crypto_config_local.json | Local development configuration with testnet defaults |
| configs/crypto_config_codespaces.json | GitHub Codespaces-optimized configuration |
| agent_tools/tool_get_price_crypto.py | MCP tool for real-time and historical crypto price queries |
| agent_tools/tool_crypto_exchange.py | Multi-exchange integration with unified API for trading operations |
| agent/providers/ai_provider_manager.py | Multi-provider AI API manager with automatic failover and rate limiting |
| agent/providers/init.py | Provider module initialization |
| agent/base_agent_crypto/base_agent_crypto.py | Advanced cryptocurrency trading agent with 24/7 support and multi-timeframe analysis |
| agent/base_agent_crypto/init.py | Crypto agent module initialization |
Comments suppressed due to low confidence (1)
tools/environment_detector.py:43
- Except block directly handles BaseException.
except:
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return "local" | ||
|
|
||
|
|
||
| def get_environment_config(env: Optional[str] = None) -> Dict[str, any]: |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type hint uses lowercase any instead of the proper Any type from typing. This should be Dict[str, Any] with Any imported from the typing module.
| product = f.read().strip().lower() | ||
| if any(cloud in product for cloud in ["google", "amazon", "azure", "oracle", "digitalocean"]): | ||
| return "vps" | ||
| except: |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bare except clause without specifying an exception type is a bad practice. This should catch specific exceptions like IOError or FileNotFoundError to avoid silently catching unexpected errors like KeyboardInterrupt or SystemExit.
| except: | |
| except (FileNotFoundError, PermissionError, OSError): |
| export $(cat .env | grep -v '^#' | xargs) | ||
|
|
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command is vulnerable to command injection if the .env file contains malicious content. Consider using set -a; source .env; set +a or a safer method to load environment variables that doesn't execute arbitrary code through xargs.
| export $(cat .env | grep -v '^#' | xargs) | |
| set -a | |
| source .env | |
| set +a |
|
|
||
| "performance_monitoring": { | ||
| "enabled": true, | ||
| "alert_email": "feherg78@example.com", |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The email address "feherg78@example.com" uses the "@example.com" domain which is a reserved domain for examples. This should be replaced with a real email address or made configurable via environment variables for production use.
| "alert_email": "feherg78@example.com", | |
| "alert_email": "${ALERT_EMAIL}", |
| dt = candle['datetime'] | ||
| time_series[dt] = { | ||
| 'open': candle['open'], | ||
| 'high': candle['high'], | ||
| 'low': candle['low'], | ||
| 'close': candle['close'], | ||
| 'volume': candle['volume'] |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function assumes that each candle dictionary has the keys 'datetime', 'open', 'high', 'low', 'close', and 'volume'. If any of these keys are missing, the code will raise a KeyError. Consider adding validation or using .get() with defaults for better error handling.
| dt = candle['datetime'] | |
| time_series[dt] = { | |
| 'open': candle['open'], | |
| 'high': candle['high'], | |
| 'low': candle['low'], | |
| 'close': candle['close'], | |
| 'volume': candle['volume'] | |
| dt = candle.get('datetime') | |
| if dt is None: | |
| continue # skip candles without datetime | |
| time_series[dt] = { | |
| 'open': candle.get('open', None), | |
| 'high': candle.get('high', None), | |
| 'low': candle.get('low', None), | |
| 'close': candle.get('close', None), | |
| 'volume': candle.get('volume', None) |
| from typing import List, Dict, Any | ||
|
|
||
|
|
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Dict' is not used.
Import of 'List' is not used.
Import of 'Any' is not used.
| from typing import List, Dict, Any |
|
|
||
| import os | ||
| import time | ||
| from typing import Dict, List, Optional, Any |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Any' is not used.
| from typing import Dict, List, Optional, Any | |
| from typing import Dict, List, Optional |
| import os | ||
| import time | ||
| from typing import Dict, List, Optional, Any | ||
| from datetime import datetime |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'datetime' is not used.
| from datetime import datetime |
|
|
||
| import json | ||
| import os | ||
| from typing import Dict, List, Optional, Any |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'List' is not used.
Import of 'Optional' is not used.
| from typing import Dict, List, Optional, Any | |
| from typing import Dict, Any |
| product = f.read().strip().lower() | ||
| if any(cloud in product for cloud in ["google", "amazon", "azure", "oracle", "digitalocean"]): | ||
| return "vps" | ||
| except: |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'except' clause does nothing but pass and there is no explanatory comment.
| except: | |
| except (FileNotFoundError, PermissionError, OSError): | |
| # It's normal for this file to be missing or unreadable on many systems. | |
| # In that case, we simply cannot detect a cloud provider here. |
π Feature: Crypto Trading Support
This PR adds comprehensive cryptocurrency trading capabilities to AI-Trader with support for multiple deployment environments.
β¨ What's New
π€ Crypto Trading Agent
BaseAgentCrypto- Specialized agent for crypto marketsπ§ New Tools
tool_crypto_exchange.py- Exchange API integration (CCXT-based)tool_get_price_crypto.py- Real-time price fetchingcost_tracker.py- API cost monitoring and budget trackingenvironment_detector.py- Auto-detect runtime environmentπ Multi-Environment Support
1. Local Development (
crypto_config_local.json)2. GitHub Codespaces (
crypto_config_codespaces.json)3. VPS Production (
crypto_config_vps.json)π Deployment Scripts
start_crypto_local.sh- Local dev startupstart_crypto_codespaces.sh- Codespaces startupstart_crypto_vps.sh- VPS production startupdeploy_oracle_vps.sh- Automated Oracle Cloud setupπ― AI Provider Management
π Risk Management Features
π° Cost Optimization
π§ͺ Testing
π Before Merging
π Security Notes
.env(gitignored)Ready for review! π