Skip to content

Conversation

@Dennis-yxchen
Copy link
Collaborator

Add:

  • agent_tools/tool_crypto_trade.py
  • AI-Trader/data/agent_data_crypto/*: fixed symbol suffixes by appending -USDT; adopted bitwise 10 to represent mainstream currencies
  • AI-Trader/prompts/agent_prompt_crypto.py
  • AI-Trader/agent/base_agent_crypto/base_agent_crypto.py is the crypto trading agent BaseAgentCrypto

Change:

  • Updated AI-Trader/agent_tools/start_mcp_services.py to improve robustness of script path resolution

@Dennis-yxchen Dennis-yxchen requested a review from Copilot November 8, 2025 11:35
Copy link

Copilot AI left a 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 BaseAgentCrypto with support for cryptocurrency trading operations
  • Implemented crypto-specific trading tools (tool_crypto_trade.py) with buy_crypto and sell_crypto functions
  • Extended price data infrastructure to support cryptocurrency symbols with -USDT suffix

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
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +160
if log_path.startswith("./data/"):
log_path = log_path[7:] # Remove "./data/" prefix
Copy link

Copilot AI Nov 8, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +174 to +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:
Copy link

Copilot AI Nov 8, 2025

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.

Suggested change
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:

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants