# chencore/accumulation_radar architecture

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

- Interactive diagram: https://gitdiagram.com/chencore/accumulation_radar
- Repository: https://github.com/chencore/accumulation_radar

## Overview

1. **Project purpose**
   - This is a Python command-line radar for Binance perpetual contracts.
   - It detects “accumulation” setups by combining range-bound price behavior, open interest anomalies, funding rate behavior, market cap, and trend heat, then ranks candidates and alerts via Telegram.

2. **Top-level execution modes**
   - `accumulation_radar.__main__` is the orchestration entrypoint.
   - It supports three workflows: `pool` (daily universe scan), `oi` (hourly opportunity scan), and `full` (both).
   - The repo is therefore organized as a batch analytics pipeline, not a long-running service.

3. **Data acquisition layer**
   - `api.py` is the Binance API wrapper and enforces thread-safe rate limiting.
   - `market.py` aggregates market-facing data: K-lines, 24h stats, funding rates, open interest history, circulating-market-cap estimates, and CoinGecko trending data.
   - External inputs are primarily Binance futures/spot public APIs plus CoinGecko trending; no API key is required.

4. **Universe selection / accumulation pool**
   - `scanner.py` contains the first-stage screen that finds range-bound “accumulation” coins.
   - The README describes this as scanning all USDT perpetuals, applying sideways-range detection over a long lookback, and writing results into a candidate pool.
   - This pool is the boundary between broad market discovery and targeted signal ranking.

5. **Second-stage signal scanning**
   - The hourly `oi` workflow uses the pool plus Binance top markets to look for OI anomalies.
   - The scan focuses on how OI changes relative to price, because “OI up + price flat” is treated as the strongest accumulation clue.
   - This stage narrows the universe from “all contracts” to “interesting contracts only.”

6. **Scoring engine**
   - `strategy.py` implements the repo’s main analytical logic.
   - It produces three ranking views:
     - a short-term squeeze-following strategy,
     - a balanced composite score,
     - a mid/long-term accumulation score.
   - The scoring is continuous rather than threshold-based, so rank ordering changes smoothly instead of jumping at fixed cutoffs.

7. **Signal composition and cross-effects**
   - The scoring model is not just additive; it includes interaction bonuses such as negative funding plus rising OI, or hot trending names overlapping with the accumulation pool.
   - OI direction matters explicitly: rising OI is treated as stronger than falling OI.
   - The architecture is therefore “feature extraction → weighted scoring → cross-signal enhancement.”

8. **Persistence boundary**
   - `db.py` is the storage layer, using SQLite.
   - It likely persists the pool and any scan state or cached results so the daily pool and hourly OI runs can operate independently.
   - This is the only durable local state in the system; the rest is computed from live APIs each run.

9. **Reporting and output**
   - `report.py` turns ranked candidates into a human-readable report.
   - The output is structured into sections like hotness, squeeze-following, composite ranking, accumulation ranking, and “worth watching” notes.
   - Reports can go to stdout or be formatted for Telegram delivery.

10. **Notification boundary**
   - `notify.py` handles Telegram push notifications when `TG_BOT_TOKEN` and `TG_CHAT_ID` are configured.
   - If not configured, the system still functions and prints reports locally.
   - This keeps alert delivery decoupled from signal generation.

11. **Configuration and runtime environment**
   - `config.py` centralizes constants, environment variables, and logging setup.
   - The repo is a lightweight Python 3.8+ application with `requests` as its only material dependency.
   - `.env.example` suggests simple file-based configuration for optional notifications.

12. **End-to-end data flow**
   - Live market data enters through Binance/CoinGecko APIs.
   - `scanner.py` and `market.py` transform raw data into candidate sets and features.
   - `strategy.py` scores those candidates.
   - `report.py` formats the result.
   - `notify.py` optionally pushes it to Telegram, while `db.py` preserves the pool between runs.

Main entry points: [`accumulation_radar/__main__.py`](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/__main__.py) (CLI entry), [`accumulation_radar/strategy.py`](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/strategy.py) (Scoring engine), [`accumulation_radar/config.py`](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/config.py) (Config), [`accumulation_radar/scanner.py`](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/scanner.py) (Universe scan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Pipeline"]
  node_main(("CLI entry<br/>orchestrator<br/>[__main__.py]"))
  node_scanner["Universe scan<br/>screening<br/>[scanner.py]"]
  node_market["Market features<br/>feature ingest<br/>[market.py]"]
  node_strategy["Scoring engine<br/>ranking<br/>[strategy.py]"]
  node_report["Report builder<br/>presentation<br/>[report.py]"]
  node_notify(("Telegram alert<br/>delivery<br/>[notify.py]"))
end

subgraph group_support["Support"]
  node_api["Binance API<br/>client<br/>[api.py]"]
  node_db[("SQLite store<br/>persistence<br/>[db.py]")]
  node_config["Config<br/>[config.py]"]
  node_init(("Package init<br/>[__init__.py]"))
end

node_main -->|"pool workflow"| node_scanner
node_main -->|"oi workflow"| node_market
node_main -->|"score candidates"| node_strategy
node_main -->|"format output"| node_report
node_main -->|"optional alert"| node_notify
node_scanner -->|"fetch markets"| node_api
node_scanner -->|"store pool"| node_db
node_market -->|"fetch data"| node_api
node_strategy -->|"features"| node_market
node_strategy -->|"pool state"| node_db
node_report -->|"rankings"| node_strategy
node_notify -->|"payload"| node_report
node_config -->|"runtime"| node_main
node_config -->|"limits"| node_api
node_config -->|"env vars"| node_notify

click node_main "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/__main__.py"
click node_scanner "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/scanner.py"
click node_market "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/market.py"
click node_strategy "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/strategy.py"
click node_report "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/report.py"
click node_notify "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/notify.py"
click node_api "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/api.py"
click node_db "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/db.py"
click node_config "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/config.py"
click node_init "https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/__init__.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_main,node_scanner,node_market,node_strategy,node_report,node_notify toneBlue
class node_api,node_db,node_config,node_init toneAmber
```

## Components

### Pipeline

Core batch analytics flow from scan to score to report.

- [CLI entry](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/__main__.py): orchestrator · Dispatches pool, oi, and full workflows. · `accumulation_radar/__main__.py`
- [Universe scan](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/scanner.py): screening · Finds range-bound accumulation candidates across USDT perpetuals. · `accumulation_radar/scanner.py`
- [Market features](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/market.py): feature ingest · Aggregates K-lines, stats, funding, OI history, market cap, and trending signals. · `accumulation_radar/market.py`
- [Scoring engine](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/strategy.py): ranking · Computes squeeze, composite, and accumulation scores with interaction bonuses. · `accumulation_radar/strategy.py`
- [Report builder](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/report.py): presentation · Turns ranked candidates into human-readable sections and notes. · `accumulation_radar/report.py`
- [Telegram alert](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/notify.py): delivery · Pushes reports to Telegram when configured, otherwise stays local. · `accumulation_radar/notify.py`

### Support

Shared infrastructure for data access, persistence, config, and delivery.

- [Binance API](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/api.py): client · Thread-safe wrapper for Binance public market data and rate limiting. · `accumulation_radar/api.py`
- [SQLite store](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/db.py): persistence · Persists pool and run state between daily and hourly scans. · `accumulation_radar/db.py`
- [Config](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/config.py): runtime config · Loads constants, environment variables, and logging setup. · `accumulation_radar/config.py`
- [Package init](https://github.com/chencore/accumulation_radar/blob/main/accumulation_radar/__init__.py): package · Defines the application package boundary. · `accumulation_radar/__init__.py`

## Connections

- CLI entry → Universe scan: pool workflow · Runs the daily accumulation universe scan.
- CLI entry → Market features: oi workflow · Collects market features for the hourly signal scan.
- CLI entry → Scoring engine: score candidates · Ranks scanned candidates into strategy views.
- CLI entry → Report builder: format output · Builds the final report from ranked results.
- CLI entry → Telegram alert: optional alert · Sends the report to Telegram when configured.
- Universe scan → Binance API: fetch markets · Pulls Binance data needed for universe screening.
- Universe scan → SQLite store: store pool · Writes accumulation candidates for later hourly scans.
- Market features → Binance API: fetch data · Reads Binance public data and related market inputs.
- Scoring engine → Market features: features · Consumes market-derived features for scoring.
- Scoring engine → SQLite store: pool state · Uses persisted pool and scan state as ranking context.
- Report builder → Scoring engine: rankings · Formats the strategy outputs into report sections.
- Telegram alert → Report builder: payload · Delivers the generated report text.
- Config → CLI entry: runtime · Provides workflow selection and logging configuration.
- Config → Binance API: limits · Supplies shared settings such as rate-limit behavior.
- Config → Telegram alert: env vars · Provides optional Telegram credentials.
