# iemanshuman/neuro-hedge architecture

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

- Interactive diagram: https://gitdiagram.com/iemanshuman/neuro-hedge
- Repository: https://github.com/iemanshuman/neuro-hedge

## Overview

Neuro-Hedge is a Python framework for training and evaluating transaction-cost-aware option hedges with guided DDPG. Training simulates market paths in a hedging environment, uses Black–Scholes delta actions during teacher forcing, and updates an actor–critic from replayed experience. Evaluation compares the trained policy with a Black–Scholes baseline and summarizes P&L and trading costs. The graph follows the sampled entry points and explicit README capabilities; unsampled implementation details are omitted.

Main entry points: [`ddpg_agent.py`](https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py) (DDPG agent), [`train.py`](https://github.com/iemanshuman/neuro-hedge/blob/main/train.py) (Training loop), [`evaluate.py`](https://github.com/iemanshuman/neuro-hedge/blob/main/evaluate.py) (Evaluation workflow), [`hedging_env.py`](https://github.com/iemanshuman/neuro-hedge/blob/main/hedging_env.py) (Hedging environment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training and evaluation"]
  node_trainer["Training loop<br/>[train.py]"]
  node_evaluator["Evaluation workflow<br/>[evaluate.py]"]
  node_results["Performance results<br/>[evaluate.py]"]
  node_weights[("Agent checkpoints")]
end

subgraph group_market["Market and hedging"]
  node_environment["Hedging environment<br/>[hedging_env.py]"]
  node_simulator["GBM simulator"]
  node_option["Call option pricing<br/>[black_scholes.py]"]
  node_baseline["BS hedge baseline<br/>[black_scholes.py]"]
end

subgraph group_learning["DDPG learning"]
  node_agent["DDPG agent<br/>[ddpg_agent.py]"]
  node_actor["Actor network<br/>[ddpg_agent.py]"]
  node_critic["Critic network<br/>[ddpg_agent.py]"]
  node_replay[("Replay buffer<br/>[ddpg_agent.py]")]
  node_noise["OU exploration noise<br/>[ddpg_agent.py]"]
end

node_trainer -->|"creates and steps"| node_environment
node_trainer -->|"creates and updates"| node_agent
node_trainer -->|"stores experience"| node_replay
node_trainer -->|"gets teacher delta"| node_environment
node_trainer -->|"saves checkpoints"| node_weights
node_environment -->|"simulates paths"| node_simulator
node_environment -->|"prices and settles"| node_option
node_agent -->|"selects actions"| node_actor
node_agent -->|"evaluates actions"| node_critic
node_agent -->|"samples updates"| node_replay
node_agent -->|"adds exploration"| node_noise
node_evaluator -->|"creates and steps"| node_environment
node_evaluator -->|"creates and queries"| node_agent
node_evaluator -->|"creates and queries"| node_baseline
node_evaluator -->|"loads checkpoint"| node_weights
node_evaluator -->|"summarizes performance"| node_results

click node_trainer "https://github.com/iemanshuman/neuro-hedge/blob/main/train.py"
click node_evaluator "https://github.com/iemanshuman/neuro-hedge/blob/main/evaluate.py"
click node_results "https://github.com/iemanshuman/neuro-hedge/blob/main/evaluate.py"
click node_weights "https://github.com/iemanshuman/neuro-hedge/blob/main/neuro_hedge_agent_checkpoint_5000_actor.pth"
click node_environment "https://github.com/iemanshuman/neuro-hedge/blob/main/hedging_env.py"
click node_simulator "https://github.com/iemanshuman/neuro-hedge/blob/main/market_simulator.py"
click node_option "https://github.com/iemanshuman/neuro-hedge/blob/main/black_scholes.py"
click node_baseline "https://github.com/iemanshuman/neuro-hedge/blob/main/black_scholes.py"
click node_agent "https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py"
click node_actor "https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py"
click node_critic "https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py"
click node_replay "https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py"
click node_noise "https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.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_trainer,node_evaluator,node_results,node_weights toneBlue
class node_environment,node_simulator,node_option,node_baseline toneAmber
class node_agent,node_actor,node_critic,node_replay,node_noise toneMint
```

## Components

### Training and evaluation

- [Training loop](https://github.com/iemanshuman/neuro-hedge/blob/main/train.py): `train.py`
- [Evaluation workflow](https://github.com/iemanshuman/neuro-hedge/blob/main/evaluate.py): `evaluate.py`
- [Performance results](https://github.com/iemanshuman/neuro-hedge/blob/main/evaluate.py): `evaluate.py`
- [Agent checkpoints](https://github.com/iemanshuman/neuro-hedge/blob/main/neuro_hedge_agent_checkpoint_5000_actor.pth): `neuro_hedge_agent_checkpoint_5000_actor.pth`

### Market and hedging

- [Hedging environment](https://github.com/iemanshuman/neuro-hedge/blob/main/hedging_env.py): `hedging_env.py`
- [GBM simulator](https://github.com/iemanshuman/neuro-hedge/blob/main/market_simulator.py): `market_simulator.py`
- [Call option pricing](https://github.com/iemanshuman/neuro-hedge/blob/main/black_scholes.py): `black_scholes.py`
- [BS hedge baseline](https://github.com/iemanshuman/neuro-hedge/blob/main/black_scholes.py): `black_scholes.py`

### DDPG learning

- [DDPG agent](https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py): `ddpg_agent.py`
- [Actor network](https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py): `ddpg_agent.py`
- [Critic network](https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py): `ddpg_agent.py`
- [Replay buffer](https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py): `ddpg_agent.py`
- [OU exploration noise](https://github.com/iemanshuman/neuro-hedge/blob/main/ddpg_agent.py): `ddpg_agent.py`

## Connections

- Training loop → Hedging environment: creates and steps (evidence: `train.py`)
- Training loop → DDPG agent: creates and updates (evidence: `train.py`)
- Training loop → Replay buffer: stores experience (evidence: `train.py`)
- Training loop → Hedging environment: gets teacher delta (evidence: `train.py`)
- Training loop → Agent checkpoints: saves checkpoints (evidence: `train.py`)
- Hedging environment → GBM simulator: simulates paths (evidence: `hedging_env.py`)
- Hedging environment → Call option pricing: prices and settles (evidence: `hedging_env.py`)
- DDPG agent → Actor network: selects actions (evidence: `ddpg_agent.py`)
- DDPG agent → Critic network: evaluates actions (evidence: `ddpg_agent.py`)
- DDPG agent → Replay buffer: samples updates (evidence: `ddpg_agent.py`)
- DDPG agent → OU exploration noise: adds exploration (evidence: `ddpg_agent.py`)
- Evaluation workflow → Hedging environment: creates and steps (evidence: `evaluate.py`)
- Evaluation workflow → DDPG agent: creates and queries (evidence: `evaluate.py`)
- Evaluation workflow → BS hedge baseline: creates and queries (evidence: `evaluate.py`)
- Evaluation workflow → Agent checkpoints: loads checkpoint (evidence: `evaluate.py`)
- Evaluation workflow → Performance results: summarizes performance (evidence: `evaluate.py`)
