# clintjohnsn/rl-trader architecture

> Architecture diagram of the GitHub repository clintjohnsn/rl-trader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/clintjohnsn/rl-trader
- Repository: https://github.com/clintjohnsn/rl-trader

## Overview

##### Project type and purpose
- This is a research‐oriented codebase supporting a Masters dissertation on stock trading using Group‐Agent Deep Reinforcement Learning (GARL).
- It implements a custom OpenAI Gym environment, several RL strategies (GARL, DQN, PPO, A2C) and an ARIMA baseline, plus data ingestion, backtesting and performance analysis.

##### (inferred) file structure
- Top‐level:
- Dissertation.pdf (write-up)
- README.md (project overview)
- LICENSE
- data/ (data ingestion & feature engineering)
- env/ (OpenAI Gym trading environment)
- agents/ (GARL implementation + single‐agent RL wrappers)
- baselines/ (ARIMA, buy-and-hold)
- backtest/ (simulation engine)
- analysis/ (performance metrics, plotting)
- config/ (hyperparameters, experiment specs)

##### README insights
- Core components: custom Gym environment, GARL strategy, two baseline strategies, data from Nasdaq-100 enriched with technical indicators, backtesting framework, performance analysis.
- External dependencies: OpenAI Gym, RL libraries (e.g., Stable Baselines), time‐series libraries (pandas, statsmodels).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    DataSource["Raw Market Data"]:::data
    DataIngestion["Data Ingestion & Feature Engineering"]:::data

    %% Environment / Training
    TradingEnv["Trading Environment\n(OpenAI Gym)"]:::env

    %% Strategy Modules
    subgraph "Strategy Modules"
        GARL["GARL Group-Agent Trainer"]:::strategy
        RL["Single-Agent RL\n(DQN, PPO, A2C)"]:::strategy
        ARIMA["ARIMA Baseline"]:::strategy
    end

    %% Backtesting and Analysis
    Backtesting["Backtesting Engine"]:::env
    Performance["Performance Analysis & Reporting"]:::analysis
    FinalReport["Final Report\n(plots, tables, Dissertation.pdf)"]:::analysis

    %% Data Flow
    DataSource -->|"raw CSV / API"| DataIngestion
    DataIngestion -->|"pandas.DataFrame"| TradingEnv

    %% Environment and Strategies Interaction
    TradingEnv <-->|"Gym.reset()/Gym.step()"| GARL
    TradingEnv <-->|"Gym.reset()/Gym.step()"| RL
    TradingEnv <-->|"Gym.reset()/Gym.step()"| ARIMA

    %% Strategy Outputs to Backtesting
    GARL -->|"actions, rewards"| Backtesting
    RL -->|"actions, rewards"| Backtesting
    ARIMA -->|"predictions"| Backtesting

    %% Backtesting to Analysis & Reporting
    Backtesting -->|"results (trades, pnl)"| Performance
    Performance -->|"analysis & plots"| FinalReport

    %% Legend
    subgraph "Legend"
        L1["Data Layer"]:::data
        L2["Environment/Training"]:::env
        L3["Strategies"]:::strategy
        L4["Analysis/Reporting"]:::analysis
    end

    %% Styles
    classDef data fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef env fill:#d4edda,stroke:#333,stroke-width:1px
    classDef strategy fill:#ffe5cc,stroke:#333,stroke-width:1px
    classDef analysis fill:#e5ccff,stroke:#333,stroke-width:1px
```
