# cinar/indicator architecture

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

- Interactive diagram: https://gitdiagram.com/cinar/indicator
- Repository: https://github.com/cinar/indicator

## Overview

Indicator Go is a channel-oriented technical-analysis library with configurable indicators, composable strategies, and a backtesting framework; it also provides commands to run backtests and synchronize market data. The primary research workflow is to provide asset snapshots to a strategy, simulate its actions and outcomes in a backtest, and produce reports. Indicator families and financial valuation utilities are separate library capabilities. Repository, strategy, backtest, and report interactions are supported by the shown source index and excerpts; unsampled indicator-package internals are not inferred.

Main entry points: [`cmd/indicator-backtest/main.go`](https://github.com/cinar/indicator/blob/master/cmd/indicator-backtest/main.go) (Backtest CLI), [`backtest/backtest.go`](https://github.com/cinar/indicator/blob/master/backtest/backtest.go) (Backtest Engine), [`strategy/strategy.go`](https://github.com/cinar/indicator/blob/master/strategy/strategy.go) (Strategies), [`asset`](https://github.com/cinar/indicator/tree/master/asset) (Asset Repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market_data["Market Data"]
  node_sync_cli["Sync CLI<br/>[main.go]"]
  node_repository_factory["Repository Factory"]
  node_asset_repositories["Asset Repositories"]
  node_tiingo["Tiingo Source"]
  node_sync_engine["Asset Sync<br/>[sync.go]"]
  node_snapshots["Market Snapshots<br/>[snapshot.go]"]
end

subgraph group_analysis["Indicators"]
  node_trend["Trend Indicators"]
  node_momentum["Momentum Indicators"]
  node_volatility["Volatility Indicators"]
  node_volume["Volume Indicators"]
  node_valuation["Valuation Functions"]
end

subgraph group_research["Strategy Research"]
  node_backtest_cli["Backtest CLI<br/>[main.go]"]
  node_strategies["Strategies<br/>[strategy.go]"]
  node_strategy_actions["Actions and Outcomes<br/>[action.go]"]
  node_backtest_engine["Backtest Engine<br/>[backtest.go]"]
  node_reports["Backtest Reports<br/>[html_report.go]"]
end

subgraph group_utilities["Library Utilities"]
  node_channel_helpers["Stream Helpers"]
end

node_researcher(("Researcher"))
node_tiingo_service["Tiingo API"]

node_researcher -->|"configures run"| node_backtest_cli
node_backtest_cli -->|"creates source"| node_repository_factory
node_backtest_cli -->|"runs backtest"| node_backtest_engine
node_backtest_cli -->|"selects report"| node_reports
node_backtest_cli -->|"selects strategies"| node_strategies
node_repository_factory -.->|"creates repository"| node_asset_repositories
node_asset_repositories -->|"reads and writes"| node_snapshots
node_sync_cli -->|"creates endpoints"| node_repository_factory
node_sync_cli -->|"runs synchronization"| node_sync_engine
node_sync_engine -.->|"transfers snapshots"| node_asset_repositories
node_tiingo -->|"requests prices"| node_tiingo_service
node_tiingo -->|"decodes prices"| node_snapshots
node_backtest_engine -->|"loads assets"| node_asset_repositories
node_backtest_engine -->|"evaluates strategies"| node_strategies
node_backtest_engine -.->|"writes results"| node_reports
node_strategies -->|"produces actions"| node_strategy_actions
node_strategies -->|"consumes snapshots"| node_snapshots
node_trend -.->|"uses stream operations"| node_channel_helpers
node_momentum -->|"uses stream operations"| node_channel_helpers
node_momentum -->|"uses trend calculations"| node_trend
node_volatility -->|"uses moving averages"| node_trend
node_volume -->|"uses moving averages"| node_trend
node_volume -->|"uses stream operations"| node_channel_helpers

click node_backtest_cli "https://github.com/cinar/indicator/blob/master/cmd/indicator-backtest/main.go"
click node_sync_cli "https://github.com/cinar/indicator/blob/master/cmd/indicator-sync/main.go"
click node_repository_factory "https://github.com/cinar/indicator/blob/master/asset/repository_factory.go"
click node_asset_repositories "https://github.com/cinar/indicator/tree/master/asset"
click node_tiingo "https://github.com/cinar/indicator/blob/master/asset/tiingo_repository.go"
click node_sync_engine "https://github.com/cinar/indicator/blob/master/asset/sync.go"
click node_snapshots "https://github.com/cinar/indicator/blob/master/asset/snapshot.go"
click node_trend "https://github.com/cinar/indicator/tree/master/trend"
click node_momentum "https://github.com/cinar/indicator/tree/master/momentum"
click node_volatility "https://github.com/cinar/indicator/tree/master/volatility"
click node_volume "https://github.com/cinar/indicator/tree/master/volume"
click node_valuation "https://github.com/cinar/indicator/tree/master/valuation"
click node_strategies "https://github.com/cinar/indicator/blob/master/strategy/strategy.go"
click node_strategy_actions "https://github.com/cinar/indicator/blob/master/strategy/action.go"
click node_backtest_engine "https://github.com/cinar/indicator/blob/master/backtest/backtest.go"
click node_reports "https://github.com/cinar/indicator/blob/master/backtest/html_report.go"
click node_channel_helpers "https://github.com/cinar/indicator/tree/master/helper"

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_sync_cli,node_repository_factory,node_asset_repositories,node_tiingo,node_sync_engine,node_snapshots toneBlue
class node_trend,node_momentum,node_volatility,node_volume,node_valuation toneAmber
class node_backtest_cli,node_strategies,node_strategy_actions,node_backtest_engine,node_reports,node_tiingo_service toneMint
class node_channel_helpers toneRose
class node_researcher toneIndigo
```

## Components

### Market Data

- [Sync CLI](https://github.com/cinar/indicator/blob/master/cmd/indicator-sync/main.go): `cmd/indicator-sync/main.go`
- [Repository Factory](https://github.com/cinar/indicator/blob/master/asset/repository_factory.go): `asset/repository_factory.go`
- [Asset Repositories](https://github.com/cinar/indicator/tree/master/asset): `asset`
- [Tiingo Source](https://github.com/cinar/indicator/blob/master/asset/tiingo_repository.go): `asset/tiingo_repository.go`
- [Asset Sync](https://github.com/cinar/indicator/blob/master/asset/sync.go): `asset/sync.go`
- [Market Snapshots](https://github.com/cinar/indicator/blob/master/asset/snapshot.go): `asset/snapshot.go`

### Indicators

- [Trend Indicators](https://github.com/cinar/indicator/tree/master/trend): `trend`
- [Momentum Indicators](https://github.com/cinar/indicator/tree/master/momentum): `momentum`
- [Volatility Indicators](https://github.com/cinar/indicator/tree/master/volatility): `volatility`
- [Volume Indicators](https://github.com/cinar/indicator/tree/master/volume): `volume`
- [Valuation Functions](https://github.com/cinar/indicator/tree/master/valuation): `valuation`

### Strategy Research

- [Backtest CLI](https://github.com/cinar/indicator/blob/master/cmd/indicator-backtest/main.go): `cmd/indicator-backtest/main.go`
- [Strategies](https://github.com/cinar/indicator/blob/master/strategy/strategy.go): `strategy/strategy.go`
- [Actions and Outcomes](https://github.com/cinar/indicator/blob/master/strategy/action.go): `strategy/action.go`
- [Backtest Engine](https://github.com/cinar/indicator/blob/master/backtest/backtest.go): `backtest/backtest.go`
- [Backtest Reports](https://github.com/cinar/indicator/blob/master/backtest/html_report.go): `backtest/html_report.go`

### Library Utilities

- [Stream Helpers](https://github.com/cinar/indicator/tree/master/helper): `helper`

### Other components

- **Researcher**
- **Tiingo API**

## Connections

- Researcher → Backtest CLI: configures run (evidence: `cmd/indicator-backtest/main.go`)
- Backtest CLI → Repository Factory: creates source (evidence: `cmd/indicator-backtest/main.go`)
- Backtest CLI → Backtest Engine: runs backtest (evidence: `cmd/indicator-backtest/main.go`)
- Backtest CLI → Backtest Reports: selects report (evidence: `cmd/indicator-backtest/main.go`)
- Backtest CLI → Strategies: selects strategies
- Repository Factory → Asset Repositories: creates repository (evidence: `asset/repository_factory.go`)
- Asset Repositories → Market Snapshots: reads and writes (evidence: `asset/file_system_repository.go`)
- Sync CLI → Repository Factory: creates endpoints (evidence: `cmd/indicator-sync/main.go`)
- Sync CLI → Asset Sync: runs synchronization (evidence: `cmd/indicator-sync/main.go`)
- Asset Sync → Asset Repositories: transfers snapshots
- Tiingo Source → Tiingo API: requests prices (evidence: `asset/tiingo_repository.go`)
- Tiingo Source → Market Snapshots: decodes prices (evidence: `asset/tiingo_repository.go`)
- Backtest Engine → Asset Repositories: loads assets (evidence: `backtest/backtest.go`)
- Backtest Engine → Strategies: evaluates strategies (evidence: `backtest/backtest.go`)
- Backtest Engine → Backtest Reports: writes results (evidence: `backtest/html_report.go`)
- Strategies → Actions and Outcomes: produces actions (evidence: `strategy/strategy.go`)
- Strategies → Market Snapshots: consumes snapshots (evidence: `strategy/strategy.go`)
- Trend Indicators → Stream Helpers: uses stream operations (evidence: `trend/kama.go`)
- Momentum Indicators → Stream Helpers: uses stream operations (evidence: `momentum/connors_rsi.go`)
- Momentum Indicators → Trend Indicators: uses trend calculations (evidence: `momentum/connors_rsi.go`)
- Volatility Indicators → Trend Indicators: uses moving averages (evidence: `volatility/super_trend.go`)
- Volume Indicators → Trend Indicators: uses moving averages (evidence: `volume/kvo.go`)
- Volume Indicators → Stream Helpers: uses stream operations (evidence: `volume/kvo.go`)
