Skip to content

Conversation

@ducga1998
Copy link

No description provided.

ducga1998 and others added 5 commits October 6, 2025 16:49
… integration

- Implement better error handling for missing data columns
- Refactor data parsing logic to ensure robustness and reliability
- Update related documentation to reflect changes in data handling
- Added placeholders for Binance, Coinbase, Kraken, Glassnode, and Messari API keys in .env.example.
- Updated requirements.txt to include ccxt, glassnode, and python-dotenv libraries.
- Enhanced agent_utils.py and interface.py to incorporate crypto-specific tools and vendor modules for improved functionality.
… cleanup. This includes the implementation summary, migration plan, phase readmes, and various test scripts for crypto agents and backtesting. All associated examples and quick start guides have also been deleted to streamline the repository.
… agents in `tradingagents/agents/analysts/`.

Implemented the `xau_macro_analyst` agent, defining its prompts and integrating tools from the FRED API dataflow.

Implemented the `xau_positioning_analyst` agent, defining its prompts and integrating tools from `cot_data.py` and `etf_flows.py`.

Exposed the new XAU data layer functions as agent tools by importing them in `tradingagents/agents/utils/agent_utils.py`.

Created and verified `tradingagents/xau_config.py` to manage system settings and `tradingagents/graph/xau_graph.py` to define the specialized LangGraph workflow for the XAU agents.

Created and verified `xau_main.py` to serve as the main entry point for initializing and running the `XAUTradingGraph`.
@gemini-code-assist
Copy link

Summary of Changes

Hello @ducga1998, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant new capabilities to the TradingAgents framework by completing the XAU (Gold) trading feature and fully migrating cryptocurrency trading functionalities into a dedicated, modular crypto_trading module. It integrates a wide array of new data sources, including FRED, COT, and Gold ETF data for XAU, and CCXT, Glassnode, and Messari for crypto. Specialized analyst agents are developed for both asset classes, tailored to their unique market dynamics. A comprehensive backtesting framework and a 24/7 paper trading system are implemented for crypto, alongside extensive documentation and updated configurations to support these new features.

Highlights

  • Intent: This pull request significantly expands the TradingAgents framework by introducing comprehensive support for both Gold (XAU) and Cryptocurrency markets. It aims to make the framework feature-complete for XAU trading and to modularize crypto trading capabilities into a dedicated module.
  • Key Changes: The PR introduces a complete XAU (Gold) trading system with specialized data layers, agents, and configuration. All crypto-related code, documentation, and resources have been migrated into a new, dedicated crypto_trading/ module, enhancing modularity and organization. Extensive new data sources are integrated, including FRED, COT, Gold ETF flows for XAU, and CCXT, Glassnode, Messari for crypto. New analyst agents are introduced for both XAU (Macro Analyst, Positioning Analyst) and Crypto (On-Chain Analyst, Crypto Fundamentals Analyst, Crypto Technical Analyst, Crypto News Analyst, Crypto Sentiment Analyst). A full backtesting framework and a 24/7 paper trading engine with dashboard and bot manager are implemented for crypto markets. Configuration files (.env.example, requirements.txt, xau_config.py, crypto_config.py) are updated, and comprehensive documentation is added for both XAU and crypto features.
  • New Features: 1. XAU Trading System: Complete data infrastructure (FRED API, COT Data, ETF Flows, Correlation Tools) and specialized analyst agents (Macro Analyst, Positioning Analyst) for gold trading. 2. Cryptocurrency Trading Module: Dedicated module with multi-exchange data integration (CCXT), on-chain analytics (Glassnode), crypto fundamentals (Messari), five crypto-specific analyst agents, a full backtesting framework, and a 24/7 paper trading engine with dashboard and bot manager. 3. Enhanced Configuration: New API keys for various data providers and exchanges are added to .env.example, and dedicated configuration files (xau_config.py, crypto_config.py) are introduced.
  • Refactoring/Improvements: The entire cryptocurrency trading functionality has been refactored and migrated into a new crypto_trading/ directory, improving modularity and separation of concerns. The agent_utils.py and interface.py files are updated to import and route to the new crypto and XAU-specific tools and vendors, allowing for a unified data abstraction layer across different asset classes.
  • Documentation: Extensive new documentation has been added, including detailed READMEs, quick start guides, design documents, and implementation summaries for both the XAU trading system and the new crypto trading module. This ensures clarity on architecture, usage, installation, and testing for all new features.
  • Testing: New test scripts (test_xau_data_layer.py, test_crypto_data.py, test_crypto_agents.py, test_crypto_backtest.py, test_paper_trading.py) are introduced to validate the functionality of the new XAU data layer, crypto data integrations, crypto-specific agents, crypto backtesting framework, and paper trading engine. Example scripts are also provided to demonstrate usage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a very large pull request that introduces significant new functionality for XAU (Gold) and cryptocurrency trading, including new data layers, specialized agents, a backtesting framework, and a paper trading engine. The documentation and design files are extensive and well-detailed, which is great to see.

My review focuses on ensuring the new code is robust, maintainable, and that the documentation is accurate and helpful for other developers. I've identified several critical issues related to hardcoded paths in documentation and example files, which will prevent others from using the code. I've also found some high-severity issues in the new XAU and paper trading modules, including incomplete placeholder files for a feature marked as 'complete', and some fragile code that could lead to runtime errors.

Overall, this is a massive and impressive contribution. Addressing the issues I've raised will significantly improve the quality, usability, and robustness of these new features.


```bash
# Navigate to project directory
cd /Users/nguyenminhduc/Desktop/TradingAgents

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This setup instruction contains a hardcoded absolute path (/Users/nguyenminhduc/...). This will not work for other users and exposes local file structure.

Please replace it with a generic instruction, for example: cd /path/to/your/TradingAgents.

Suggested change
cd /Users/nguyenminhduc/Desktop/TradingAgents
cd /path/to/your/TradingAgents


Add to your shell profile (`.bashrc`, `.zshrc`, etc.):
```bash
export PYTHONPATH="/Users/nguyenminhduc/Desktop/TradingAgents:$PYTHONPATH"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This setup instruction contains a hardcoded absolute path (/Users/nguyenminhduc/...). This will not work for other users and exposes local file structure.

Please replace it with a generic placeholder like $PATH_TO_TRADING_AGENTS_REPO to instruct users to add their own path.

Suggested change
export PYTHONPATH="/Users/nguyenminhduc/Desktop/TradingAgents:$PYTHONPATH"
export PYTHONPATH="/path/to/your/TradingAgents:$PYTHONPATH"

import os

# Add project root to path
project_root = "/Users/nguyenminhduc/Desktop/TradingAgents"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This code example contains a hardcoded absolute path (/Users/nguyenminhduc/...). This will fail on any other developer's machine and is a security risk as it exposes local file structure.

Please use a relative path calculation to determine the project root dynamically, as is done correctly in the example scripts.

Suggested change
project_root = "/Users/nguyenminhduc/Desktop/TradingAgents"
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) # Adjust relative path as needed


```python
import sys
sys.path.insert(0, '/Users/nguyenminhduc/Desktop/TradingAgents')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This code example contains a hardcoded absolute path (/Users/nguyenminhduc/...). This will fail on any other developer's machine and is a security risk as it exposes local file structure.

Please use a relative path calculation to determine the project root dynamically, or use a placeholder like <path_to_project_root>.

Suggested change
sys.path.insert(0, '/Users/nguyenminhduc/Desktop/TradingAgents')
sys.path.insert(0, '/path/to/your/TradingAgents')


**Solution**: Run from project root:
```bash
cd /Users/nguyenminhduc/Desktop/TradingAgents

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This setup instruction contains a hardcoded absolute path (/Users/nguyenminhduc/...). This will not work for other users and exposes local file structure.

Please replace it with a generic instruction, for example: cd /path/to/your/TradingAgents.

Suggested change
cd /Users/nguyenminhduc/Desktop/TradingAgents
cd /path/to/your/TradingAgents

for order in self.engine.orders:
if order.side.value == "sell" and "P&L:" in order.reason:
# Extract P&L from reason
pnl_str = order.reason.split("P&L: $")[1].split(" ")[0].replace(",", "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Parsing the P&L from the order.reason string is fragile and not a robust design. If the format of the reason string changes in paper_trading_engine.py, this code will break.

A better approach would be to add pnl and pnl_pct fields directly to the PaperOrder dataclass. This would make the data structure more explicit and the code more maintainable.

For example, you could modify PaperOrder like this:

# In paper_trading_engine.py
@dataclass
class PaperOrder:
    # ... existing fields
    pnl: Optional[float] = None
    pnl_pct: Optional[float] = None

Then, when creating the order, you can populate these fields directly, and access them here without parsing strings.


# Calculate P&L
pnl = net_proceeds - (position.entry_price * amount)
pnl_pct = pnl / (position.entry_price * amount)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a potential for a ZeroDivisionError here if position.entry_price or amount is zero. While unlikely for a valid position, adding a check for this edge case would make the code more robust.

Suggested change
pnl_pct = pnl / (position.entry_price * amount)
pnl_pct = 0.0
if position.entry_price * amount != 0:
pnl_pct = pnl / (position.entry_price * amount)

- `trader.py` - Composes reports and makes trading decisions

**4. Risk Management** (`tradingagents/agents/risk_mgmt/`)
- `aggresive_debator.py` - High-risk tolerance perspective

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the filename aggresive_debator.py. It should be aggressive_debator.py.

Correcting this will prevent confusion for developers looking for this file.

Suggested change
- `aggresive_debator.py` - High-risk tolerance perspective
- `aggressive_debator.py` - High-risk tolerance perspective


# Crypto Data Provider Keys
GLASSNODE_API_KEY=glassnode_api_key_placeholder
MESSARI_API_KEY=messari_api_key_placeholder

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's a good practice to end text files with a single newline character. Some tools and systems might have issues processing files that don't end with a newline.

MESSARI_API_KEY=messari_api_key_placeholder

Located in `tradingagents/default_config.py`:

- `results_dir` - Output directory for results (default: `./results`)
- `deep_think_llm` - Model for complex reasoning (default: `o4-mini`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The model name o4-mini seems to be a typo. Other parts of the documentation refer to gpt-4o-mini. Using a consistent and correct model name will avoid confusion for users trying to configure the system.

I'd recommend changing it to gpt-4o-mini for consistency.

Suggested change
- `deep_think_llm` - Model for complex reasoning (default: `o4-mini`)
- `deep_think_llm` - Model for complex reasoning (default: `gpt-4o-mini`)

coderabbitai bot and others added 2 commits October 15, 2025 08:32
Docstrings generation was requested by @ducga1998.

* #2 (comment)

The following files were modified:

* `tradingagents/agents/analysts/xau_macro_analyst.py`
* `tradingagents/agents/analysts/xau_positioning_analyst.py`
* `tradingagents/agents/utils/agent_utils.py`
* `tradingagents/graph/xau_graph.py`
* `xau_main.py`
📝 Add docstrings to `feature-complete-XAU`
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.

1 participant