# colochampre/bar-magnifier-estimator architecture

> Architecture diagram of the GitHub repository colochampre/bar-magnifier-estimator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/colochampre/bar-magnifier-estimator
- Repository: https://github.com/colochampre/bar-magnifier-estimator
- Video tour (about a minute): https://gitdiagram.com/colochampre/bar-magnifier-estimator/video

## Overview

bar-magnifier-estimator parses TradingView trade exports, aligns them to exchange data, validates exit rules against the chart-timeframe results, then replays at finer resolutions to estimate magnifier-equivalent and more realistic outcomes. It also supports calibration against a known magnifier run, funding-cost measurement, shared-capital portfolio simulations, and formatted reports. Replay orchestration and portfolio internals are sampled; several estimate and provider details are only documented or partially excerpted, so uncertain internal links are omitted.

Main entry points: [`bme/candles.py`](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/candles.py) (Candle Providers), [`bme/estimate.py`](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/estimate.py) (Estimate Runner), [`bme/tradingview.py`](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/tradingview.py) (Trade Parser), [`bme/engine.py`](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/engine.py) (Replay Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Trade Inputs"]
  node_tradingview["Trade Parser<br/>[tradingview.py]"]
end

subgraph group_market["Market Data"]
  node_candles["Candle Providers<br/>[candles.py]"]
  node_cache[("Market Data Cache<br/>[candles.py]")]
end

subgraph group_replay["Replay And Estimates"]
  node_rules["Exit Rules<br/>[rules.py]"]
  node_engine["Replay Engine<br/>[engine.py]"]
  node_estimate["Estimate Runner<br/>[estimate.py]"]
  node_result["Replay Results<br/>[estimate.py]"]
end

subgraph group_analysis["Portfolio And Reports"]
  node_portfolio["Pool Simulation<br/>[portfolio.py]"]
  node_report["Result Reports<br/>[report.py]"]
end

node_trader(("Strategy Tester User"))
node_export["Trade Export"]
node_exchange(("Exchange APIs"))

node_trader -->|"exports trades"| node_export
node_export -->|"reads CSV"| node_tradingview
node_tradingview -->|"checks fills"| node_candles
node_tradingview -->|"provides trades"| node_estimate
node_candles -->|"fetches candles"| node_exchange
node_candles -->|"reads/writes"| node_cache
node_candles -->|"returns candles"| node_tradingview
node_estimate -->|"loads series"| node_candles
node_estimate -->|"replays trades"| node_engine
node_engine -->|"reads windows"| node_candles
node_engine -->|"checks exits"| node_rules
node_estimate -->|"builds results"| node_result
node_estimate -.->|"supplies trade results"| node_portfolio
node_estimate -.->|"loads funding rates"| node_candles
node_candles -.->|"fetches funding"| node_exchange
node_result -->|"formats metrics"| node_report
node_portfolio -->|"formats runs"| node_report

click node_tradingview "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/tradingview.py"
click node_candles "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/candles.py"
click node_cache "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/candles.py"
click node_rules "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/rules.py"
click node_engine "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/engine.py"
click node_estimate "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/estimate.py"
click node_result "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/estimate.py"
click node_portfolio "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/portfolio.py"
click node_report "https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/report.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_tradingview,node_trader toneBlue
class node_candles,node_cache toneAmber
class node_rules,node_engine,node_estimate,node_result,node_exchange toneMint
class node_portfolio,node_report toneRose
class node_export toneIndigo
```

## Components

### Trade Inputs

- [Trade Parser](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/tradingview.py): `bme/tradingview.py`

### Market Data

- [Candle Providers](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/candles.py): `bme/candles.py`
- [Market Data Cache](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/candles.py): `bme/candles.py`

### Replay And Estimates

- [Exit Rules](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/rules.py): `bme/rules.py`
- [Replay Engine](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/engine.py): `bme/engine.py`
- [Estimate Runner](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/estimate.py): `bme/estimate.py`
- [Replay Results](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/estimate.py): `bme/estimate.py`

### Portfolio And Reports

- [Pool Simulation](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/portfolio.py): `bme/portfolio.py`
- [Result Reports](https://github.com/colochampre/bar-magnifier-estimator/blob/main/bme/report.py): `bme/report.py`

### Other components

- **Strategy Tester User**
- **Trade Export**
- **Exchange APIs**

## Connections

- Strategy Tester User → Trade Export: exports trades
- Trade Export → Trade Parser: reads CSV
- Trade Parser → Candle Providers: checks fills
- Trade Parser → Estimate Runner: provides trades
- Candle Providers → Exchange APIs: fetches candles
- Candle Providers → Market Data Cache: reads/writes
- Candle Providers → Trade Parser: returns candles
- Estimate Runner → Candle Providers: loads series
- Estimate Runner → Replay Engine: replays trades
- Replay Engine → Candle Providers: reads windows
- Replay Engine → Exit Rules: checks exits
- Estimate Runner → Replay Results: builds results
- Estimate Runner → Pool Simulation: supplies trade results
- Estimate Runner → Candle Providers: loads funding rates
- Candle Providers → Exchange APIs: fetches funding
- Replay Results → Result Reports: formats metrics
- Pool Simulation → Result Reports: formats runs
