# sanjaykumar3110/market_minds architecture

> Architecture diagram of the GitHub repository sanjaykumar3110/market_minds, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanjaykumar3110/market_minds
- Repository: https://github.com/sanjaykumar3110/market_minds

## Overview

This is a cryptocurrency trading-agent project centered on training a reinforcement-learning policy against historical market data. The main workflow downloads prices, derives indicators, builds a trading environment, trains an agent from environment transitions, and saves model artifacts and trade logs. The README also describes testing on unseen data and performance evaluation; those runtime modules are only partly represented in the sampled source, so their connections are shown cautiously. The tree contains no live-trading or exchange execution integration.

Main entry points: [`main.py`](https://github.com/sanjaykumar3110/market_minds/blob/main/main.py) (Training runner), [`mind/master.py`](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py) (RL agent), [`mind/environment/trade_env.py`](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/trade_env.py) (Trading environment), [`mind/environment/test_env.py`](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/test_env.py) (Testing environment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Market data and features"]
  node_market_source["Yahoo Finance"]
  node_trainer["Training runner<br/>[main.py]"]
  node_indicators["Indicator calculations<br/>[strategy.py]"]
  node_feature_prep["Feature preparation<br/>[main.py]"]
end

subgraph group_simulation["Trading simulation"]
  node_base_env["Environment base<br/>[base_env.py]"]
  node_trade_env["Trading environment<br/>[trade_env.py]"]
  node_train_env["Alternate training environment<br/>[train_env.py]"]
  node_test_env["Testing environment<br/>[test_env.py]"]
  node_strategy_decision["Rule-based decisions<br/>[strategy.py]"]
end

subgraph group_learning["Agent and learning"]
  node_agent["RL agent<br/>[master.py]"]
  node_neural_network["CNN-LSTM model<br/>[master.py]"]
  node_reward["Reward calculation<br/>[master.py]"]
  node_replay["Experience replay<br/>[master.py]"]
end

subgraph group_artifacts["Outputs and evaluation"]
  node_model_files["Model artifacts"]
  node_trade_logs["Training trade logs"]
  node_logger["Log and plot utilities<br/>[logger.py]"]
  node_evaluation["Test and evaluation"]
end

node_operator(("Training operator"))

node_operator -->|"starts training"| node_trainer
node_trainer -->|"downloads prices"| node_market_source
node_trainer -->|"calculates indicators"| node_indicators
node_trainer -->|"aligns features"| node_feature_prep
node_feature_prep -->|"supplies price features"| node_trade_env
node_trainer -->|"creates and steps"| node_trade_env
node_trade_env -->|"inherits from"| node_base_env
node_trade_env -->|"requests strategy action"| node_strategy_decision
node_trainer -->|"selects actions and trains"| node_agent
node_agent -->|"predicts and updates"| node_neural_network
node_agent -->|"stores experiences"| node_replay
node_agent -.->|"not evidenced"| node_reward
node_train_env -->|"uses reward calculator"| node_reward
node_train_env -->|"requests strategy action"| node_strategy_decision
node_trainer -->|"saves and exports"| node_model_files
node_trainer -->|"writes trade CSV"| node_trade_logs
node_logger -->|"writes log files"| node_trade_logs
node_logger -->|"plots log results"| node_evaluation
node_operator -.->|"runs testing"| node_test_env
node_test_env -.->|"loads trained policy"| node_agent
node_test_env -.->|"provides test results"| node_evaluation
node_evaluation -.->|"records test results"| node_trade_logs

click node_trainer "https://github.com/sanjaykumar3110/market_minds/blob/main/main.py"
click node_indicators "https://github.com/sanjaykumar3110/market_minds/blob/main/utils/strategy.py"
click node_feature_prep "https://github.com/sanjaykumar3110/market_minds/blob/main/main.py"
click node_base_env "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/base_env.py"
click node_trade_env "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/trade_env.py"
click node_train_env "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/train_env.py"
click node_test_env "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/test_env.py"
click node_strategy_decision "https://github.com/sanjaykumar3110/market_minds/blob/main/utils/strategy.py"
click node_agent "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py"
click node_neural_network "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py"
click node_reward "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py"
click node_replay "https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py"
click node_logger "https://github.com/sanjaykumar3110/market_minds/blob/main/utils/logger.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_market_source,node_trainer,node_indicators,node_feature_prep toneBlue
class node_base_env,node_trade_env,node_train_env,node_test_env,node_strategy_decision toneAmber
class node_agent,node_neural_network,node_reward,node_replay toneMint
class node_model_files,node_trade_logs,node_logger,node_evaluation toneRose
class node_operator toneIndigo
```

## Components

### Market data and features

- **Yahoo Finance**
- [Training runner](https://github.com/sanjaykumar3110/market_minds/blob/main/main.py): `main.py`
- [Indicator calculations](https://github.com/sanjaykumar3110/market_minds/blob/main/utils/strategy.py): `utils/strategy.py`
- [Feature preparation](https://github.com/sanjaykumar3110/market_minds/blob/main/main.py): `main.py`

### Trading simulation

- [Environment base](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/base_env.py): `mind/environment/base_env.py`
- [Trading environment](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/trade_env.py): `mind/environment/trade_env.py`
- [Alternate training environment](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/train_env.py): `mind/environment/train_env.py`
- [Testing environment](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/environment/test_env.py): `mind/environment/test_env.py`
- [Rule-based decisions](https://github.com/sanjaykumar3110/market_minds/blob/main/utils/strategy.py): `utils/strategy.py`

### Agent and learning

- [RL agent](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py): `mind/master.py`
- [CNN-LSTM model](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py): `mind/master.py`
- [Reward calculation](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py): `mind/master.py`
- [Experience replay](https://github.com/sanjaykumar3110/market_minds/blob/main/mind/master.py): `mind/master.py`

### Outputs and evaluation

- **Model artifacts**
- **Training trade logs**
- [Log and plot utilities](https://github.com/sanjaykumar3110/market_minds/blob/main/utils/logger.py): `utils/logger.py`
- **Test and evaluation**

### Other components

- **Training operator**

## Connections

- Training operator → Training runner: starts training (evidence: `README.md`)
- Training runner → Yahoo Finance: downloads prices (evidence: `main.py`)
- Training runner → Indicator calculations: calculates indicators (evidence: `main.py`)
- Training runner → Feature preparation: aligns features (evidence: `main.py`)
- Feature preparation → Trading environment: supplies price features (evidence: `main.py`)
- Training runner → Trading environment: creates and steps (evidence: `main.py`)
- Trading environment → Environment base: inherits from (evidence: `mind/environment/trade_env.py`)
- Trading environment → Rule-based decisions: requests strategy action (evidence: `mind/environment/trade_env.py`)
- Training runner → RL agent: selects actions and trains (evidence: `main.py`)
- RL agent → CNN-LSTM model: predicts and updates (evidence: `mind/master.py`)
- RL agent → Experience replay: stores experiences (evidence: `mind/master.py`)
- RL agent → Reward calculation: not evidenced (evidence: `mind/master.py`)
- Alternate training environment → Reward calculation: uses reward calculator (evidence: `mind/environment/train_env.py`)
- Alternate training environment → Rule-based decisions: requests strategy action (evidence: `mind/environment/train_env.py`)
- Training runner → Model artifacts: saves and exports (evidence: `main.py`)
- Training runner → Training trade logs: writes trade CSV (evidence: `main.py`)
- Log and plot utilities → Training trade logs: writes log files (evidence: `utils/logger.py`)
- Log and plot utilities → Test and evaluation: plots log results (evidence: `utils/logger.py`)
- Training operator → Testing environment: runs testing (evidence: `README.md`)
- Testing environment → RL agent: loads trained policy
- Testing environment → Test and evaluation: provides test results (evidence: `README.md`)
- Test and evaluation → Training trade logs: records test results (evidence: `README.md`)
