-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implemented a crypto trading system #92
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
download crypto data, create a crypto trading server (with float amount), and fix some bugs
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 implements a cryptocurrency trading system by adding support for crypto trading alongside the existing stock trading functionality. The system uses the Bitwise 10 index to represent mainstream cryptocurrencies and includes all necessary infrastructure for crypto trading operations.
Key Changes:
- Added crypto trading agent
BaseAgentCryptowith support for cryptocurrency trading operations - Implemented crypto-specific trading tools (
tool_crypto_trade.py) withbuy_cryptoandsell_cryptofunctions - Extended price data infrastructure to support cryptocurrency symbols with
-USDTsuffix
Reviewed Changes
Copilot reviewed 13 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
data/crypto/coin/daily_prices_LTC.json |
Added historical price data for Litecoin (LTC) cryptocurrency |
data/crypto/coin/daily_prices_LINK.json |
Added historical price data for Chainlink (LINK) cryptocurrency |
configs/default_crypto_config.json |
Created configuration file for crypto trading agent with model settings and initial parameters |
agent_tools/tool_trade.py |
Enhanced stock trading functions with improved amount validation and explicit market type detection |
agent_tools/tool_get_price_local.py |
Extended price lookup to support crypto symbols ending with -USDT |
agent_tools/tool_crypto_trade.py |
Implemented new crypto trading tools with buy_crypto and sell_crypto functions |
agent_tools/start_mcp_services.py |
Improved MCP service initialization with absolute paths and added crypto trading service |
agent/base_agent_crypto/base_agent_crypto.py |
Created base crypto trading agent class with trading session management and position tracking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Context manager for file-based lock to serialize position updates per signature.""" | ||
| class _Lock: | ||
| def __init__(self, name: str): | ||
| base_dir = Path(project_root) / "data" / "agent_data" / name |
Copilot
AI
Nov 8, 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 _position_lock function uses hardcoded path 'agent_data' but should use the LOG_PATH configuration value to match where position files are actually stored. This creates a mismatch where locks are created in 'agent_data' but positions may be stored in 'agent_data_crypto' or other paths.
| base_dir = Path(project_root) / "data" / "agent_data" / name | |
| log_path = get_config_value("LOG_PATH", "agent_data") | |
| base_dir = Path(project_root) / "data" / log_path / name |
| if log_path.startswith("./data/"): | ||
| log_path = log_path[7:] # Remove "./data/" prefix |
Copilot
AI
Nov 8, 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 path prefix removal logic is duplicated in both buy_crypto and sell_crypto functions. Consider extracting this into a helper function to reduce code duplication and improve maintainability.
| if openai_base_url == None: | ||
| self.openai_base_url = os.getenv("OPENAI_API_BASE") | ||
| else: | ||
| self.openai_base_url = openai_base_url | ||
| if openai_api_key == None: |
Copilot
AI
Nov 8, 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.
Use is None instead of == None for None comparisons. This applies to both lines 174 and 178.
| if openai_base_url == None: | |
| self.openai_base_url = os.getenv("OPENAI_API_BASE") | |
| else: | |
| self.openai_base_url = openai_base_url | |
| if openai_api_key == None: | |
| if openai_base_url is None: | |
| self.openai_base_url = os.getenv("OPENAI_API_BASE") | |
| else: | |
| self.openai_base_url = openai_base_url | |
| if openai_api_key is None: |
Add:
agent_tools/tool_crypto_trade.pyAI-Trader/data/agent_data_crypto/*: fixed symbol suffixes by appending-USDT; adopted bitwise10to represent mainstream currenciesAI-Trader/prompts/agent_prompt_crypto.pyAI-Trader/agent/base_agent_crypto/base_agent_crypto.pyis the crypto trading agent BaseAgentCryptoChange:
AI-Trader/agent_tools/start_mcp_services.pyto improve robustness of script path resolution