# Building a Modular AI Trading Agent

By [Wolfcito](https://paragraph.com/@wolfcito-2) · 2025-05-01

---

Modular Architecture of a Web3 AI Trading Agent
===============================================

These days I started the task of creating an AI Agent to help new users with trading. But I ran into a small barrier: I’m not very experienced in trading.So today I’m sharing this technical approach.

Below is the complete architecture of an **AI Trading Agent** for the Web3 ecosystem, built on **Mode Network** and using the **Orderly** APIs. We explore in detail the system’s modules, from data ingestion to order execution and portfolio management. This first installment focuses on **signal generation**, the foundation of the BUY/SELL decision engine.

I already identified this problem: many bots lack solid trading fundamentals. This project prioritizes an approach where quants and builders can collaborate to build truly effective agents in minutes, leveraging Mode Network.

I’d also like to include a critical observation echoed by ecosystem experts like James Ross ([@JRossTreacher](https://x.com/JRossTreacher/status/1917565363639738550)):

[https://x.com/JRossTreacher/status/1917565363639738550](https://x.com/JRossTreacher/status/1917565363639738550)

Trading automation in Web3 represents a unique opportunity: trustless execution, real-time on-chain data access, and AI integration. However, it demands a **modular**, scalable, and secure architecture capable of adapting to different trading styles.

System Design
-------------

I chose a decoupled, functional-module design that allows evolving the system without impacting critical components.

![ccccFunctional-module design](https://storage.googleapis.com/papyrus_images/530b67161f422ca86ff52671209c5395d7acaa3d2597f640cc8f1b19b249f86c.png)

ccccFunctional-module design

**Components:**

*   **A: Data Ingestion** – Oracles, REST/GraphQL APIs, on-chain data.
    
*   **B: Feature Engineering** – Compute SMA, RSI, Momentum, MACD.
    
*   **C: Signal Generation** – Moving average crossover rules, LLM prompts.
    
*   **D: Order Execution** – GOAT SDK / Orderly integration.
    
*   **E: Risk Management** – Stop-loss, exposure control.
    
*   **F: Portfolio Management** – Rebalancing, asset scoring.
    
*   **G: Backtesting** – Simulation with synthetic data on Mode.
    
*   **H: Monitoring** – Logging, key metrics.
    
*   **I: Orchestrator** – Central coordinator, cyclic execution.
    

Current Status and Methodology
------------------------------

I initially believed synthetic data alone would solve everything. But I reached a point where raw feeds required **preprocessing**—normalization, feature extraction—before indicator calculation.

The signal generation module based on classic indicators (such as **SMA crossover**, already implemented) is currently under development. This serves as the basis for later execution and evaluation tests.

### Methodology

*   **Modular PoC:** incremental development by independent modules.
    
*   **Indicators implemented:** SMA crossover, RSI integration in progress.
    
*   **Initial validation:** live price reading, signal generation, and logging.
    
*   **Runtime environment:** TypeScript + Node.js, secure connection via `.env`.
    

Progress Example: SMA Calculation (WIP)
---------------------------------------

    import { sma } from './src/signals';
    const prices = [100, 102, 101, 105, 107, 110];
    console.log('SMA(3):', sma(prices, 3));
    // WIP expected: [101.000, 102.667, 104.333, 107.333]
    

This confirms the moving average works. Next: feed preprocessed data into the trading loop.

Results and Experiments
-----------------------

> ⚠️ **Note:** The full system run has **not yet been performed**. The data below are **design-only placeholders**, not final results.

![Estimated from unit tests under ideal conditions. Full end-to-end run is pending.](https://storage.googleapis.com/papyrus_images/aee17ab2d107bad6d74a9e6d55318a330f82742bf82dfef2656d85dc7e0cf3c8.png)

Estimated from unit tests under ideal conditions. Full end-to-end run is pending.

Conclusion
----------

This project present a robust, extensible architecture for building **Web3 AI Trading Agents**, addressing the “terrible at trading” gap James Ross called out. Development is **actively in progress**: SMA signal and data preprocessing are operational. Next, we’ll integrate execution and complete test runs.

Next Steps
----------

*   🧠 Add an **LLM orchestrator** for adaptive strategies.
    
*   ⚠️ Build an advanced **Risk Management** module.
    
*   📈 Conduct end-to-end tests on Mode & Orderly testnets.
    
*   📊 Deliver a **real-time dashboard**.
    
*   🧪 Introduce **Deep Learning** for dynamic signals.
    

Repository
----------

🚧 _Coming soon. Currently in a private testing environment._

---

*Originally published on [Wolfcito](https://paragraph.com/@wolfcito-2/building-a-modular-ai-trading-agent)*
