# abhiraj212024/inter-iit-backtester architecture

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

- Interactive diagram: https://gitdiagram.com/abhiraj212024/inter-iit-backtester
- Repository: https://github.com/abhiraj212024/inter-iit-backtester

## Overview

This repository is a quantitative strategy evaluation framework with daily multi-asset (Track A) and one-second microstructure (Track B) backtests. The principal workflow is: configure and launch a run, load a participant strategy, stream market bars through its callback, enforce risk limits and simulate next-bar execution, then report performance and diagnostics. The README documents both tracks and the result artifacts. Some backtester internals are omitted from the excerpts, so uncertain internal calls are not asserted.

Main entry points: [`backtester.py`](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py) (Backtest engine), [`src/engine.py`](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/src/engine.py) (Participant strategy), [`strategy_base.py`](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py) (Strategy context), [`run_backtest.py`](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/run_backtest.py) (CLI runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runner["Run setup"]
  node_cli["CLI runner<br/>[run_backtest.py]"]
  node_config["Run configuration<br/>[config.yaml]"]
  node_market_data["Market datasets"]
end

subgraph group_strategy["Strategy interface"]
  node_participant_strategy["Participant strategy<br/>[engine.py]"]
  node_strategy_contract["Strategy API<br/>[strategy_base.py]"]
  node_bar_views["Bar views<br/>[strategy_base.py]"]
  node_context["Strategy context<br/>[strategy_base.py]"]
end

subgraph group_simulation["Backtest simulation"]
  node_backtester["Backtest engine<br/>[backtester.py]"]
  node_track_a["Track A loop<br/>[backtester.py]"]
  node_track_b["Track B loop<br/>[backtester.py]"]
  node_rule_guard["Risk guard<br/>[backtester.py]"]
  node_ledger["Accounting ledger<br/>[backtester.py]"]
  node_execution["Order execution<br/>[backtester.py]"]
  node_valuation["Portfolio valuation<br/>[backtester.py]"]
end

subgraph group_results["Evaluation results"]
  node_metrics["Performance metrics<br/>[backtester.py]"]
  node_summary["Summary metrics<br/>[backtester.py]"]
  node_trade_log["Trade log<br/>[backtester.py]"]
  node_tearsheet["Performance tearsheet<br/>[backtester.py]"]
end

node_participant(("Participant"))

node_participant -->|"launches"| node_cli
node_cli -->|"reads"| node_config
node_cli -->|"loads"| node_participant_strategy
node_cli -->|"runs"| node_backtester
node_market_data -->|"supplies bars"| node_backtester
node_backtester -->|"dispatches"| node_track_a
node_backtester -->|"dispatches"| node_track_b
node_track_a -->|"calls per step"| node_participant_strategy
node_track_b -->|"calls per step"| node_participant_strategy
node_track_a -->|"builds bars"| node_bar_views
node_track_b -->|"reuses view"| node_bar_views
node_track_a -->|"updates state"| node_context
node_track_b -->|"updates state"| node_context
node_participant_strategy -->|"implements"| node_strategy_contract
node_participant_strategy -->|"sets allocations"| node_context
node_strategy_contract -->|"defines interface"| node_bar_views
node_context -->|"queues weights"| node_track_a
node_context -->|"queues weights"| node_track_b
node_track_a -.->|"checks limits"| node_rule_guard
node_track_b -.->|"checks limits"| node_rule_guard
node_track_a -.->|"submits targets"| node_ledger
node_track_b -.->|"submits targets"| node_ledger
node_ledger -->|"fills orders"| node_execution
node_ledger -->|"marks holdings"| node_valuation
node_backtester -->|"calculates"| node_metrics
node_metrics -->|"reads trades"| node_ledger
node_backtester -->|"writes"| node_summary
node_backtester -->|"writes"| node_trade_log
node_backtester -->|"generates"| node_tearsheet

click node_cli "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/run_backtest.py"
click node_config "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/config.yaml"
click node_participant_strategy "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/src/engine.py"
click node_strategy_contract "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py"
click node_bar_views "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py"
click node_context "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py"
click node_backtester "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_track_a "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_track_b "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_rule_guard "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_ledger "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_execution "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_valuation "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_metrics "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_summary "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_trade_log "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py"
click node_tearsheet "https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.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_cli,node_config,node_market_data toneBlue
class node_participant_strategy,node_strategy_contract,node_bar_views,node_context toneAmber
class node_backtester,node_track_a,node_track_b,node_rule_guard,node_ledger,node_execution,node_valuation toneMint
class node_metrics,node_summary,node_trade_log,node_tearsheet toneRose
class node_participant toneIndigo
```

## Components

### Run setup

- [CLI runner](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/run_backtest.py): `run_backtest.py`
- [Run configuration](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/config.yaml): `config.yaml`
- **Market datasets**

### Strategy interface

- [Participant strategy](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/src/engine.py): `src/engine.py`
- [Strategy API](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py): `strategy_base.py`
- [Bar views](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py): `strategy_base.py`
- [Strategy context](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/strategy_base.py): `strategy_base.py`

### Backtest simulation

- [Backtest engine](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Track A loop](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Track B loop](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Risk guard](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Accounting ledger](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Order execution](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Portfolio valuation](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`

### Evaluation results

- [Performance metrics](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Summary metrics](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Trade log](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`
- [Performance tearsheet](https://github.com/abhiraj212024/inter-iit-backtester/blob/main/backtester.py): `backtester.py`

### Other components

- **Participant**

## Connections

- Participant → CLI runner: launches (evidence: `README.md`)
- CLI runner → Run configuration: reads (evidence: `run_backtest.py`)
- CLI runner → Participant strategy: loads (evidence: `run_backtest.py`)
- CLI runner → Backtest engine: runs (evidence: `run_backtest.py`)
- Market datasets → Backtest engine: supplies bars (evidence: `README.md`)
- Backtest engine → Track A loop: dispatches (evidence: `backtester.py`)
- Backtest engine → Track B loop: dispatches (evidence: `backtester.py`)
- Track A loop → Participant strategy: calls per step (evidence: `backtester.py`)
- Track B loop → Participant strategy: calls per step (evidence: `backtester.py`)
- Track A loop → Bar views: builds bars (evidence: `backtester.py`)
- Track B loop → Bar views: reuses view (evidence: `backtester.py`)
- Track A loop → Strategy context: updates state (evidence: `backtester.py`)
- Track B loop → Strategy context: updates state (evidence: `backtester.py`)
- Participant strategy → Strategy API: implements (evidence: `src/engine.py`)
- Participant strategy → Strategy context: sets allocations (evidence: `src/engine.py`)
- Strategy API → Bar views: defines interface (evidence: `strategy_base.py`)
- Strategy context → Track A loop: queues weights (evidence: `strategy_base.py`)
- Strategy context → Track B loop: queues weights (evidence: `strategy_base.py`)
- Track A loop → Risk guard: checks limits (evidence: `backtester.py`)
- Track B loop → Risk guard: checks limits (evidence: `backtester.py`)
- Track A loop → Accounting ledger: submits targets (evidence: `backtester.py`)
- Track B loop → Accounting ledger: submits targets (evidence: `backtester.py`)
- Accounting ledger → Order execution: fills orders (evidence: `backtester.py`)
- Accounting ledger → Portfolio valuation: marks holdings (evidence: `backtester.py`)
- Backtest engine → Performance metrics: calculates (evidence: `backtester.py`)
- Performance metrics → Accounting ledger: reads trades (evidence: `backtester.py`)
- Backtest engine → Summary metrics: writes (evidence: `README.md`)
- Backtest engine → Trade log: writes (evidence: `README.md`)
- Backtest engine → Performance tearsheet: generates (evidence: `README.md`)
