# marketcalls/openchart architecture

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

- Interactive diagram: https://gitdiagram.com/marketcalls/openchart
- Repository: https://github.com/marketcalls/openchart

## Overview

OpenChart is a Python client for NSE India market data. The main workflow accepts a symbol, segment, date range, and interval; searches NSE for the symbol’s token and metadata; requests historical chart data; then converts the response into an indexed OHLCV DataFrame. Callers with a known token can bypass symbol search. The library also exposes symbol search and supported segment/timeframe lists. The graph reflects the sampled runtime source and README; the NSE endpoints are external services.

Main entry points: [`openchart/core.py`](https://github.com/marketcalls/openchart/blob/master/openchart/core.py) (Historical lookup), [`openchart/utils.py`](https://github.com/marketcalls/openchart/blob/master/openchart/utils.py) (OHLCV formatter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client API"]
  node_nse_data["NSEData client<br/>[core.py]"]
  node_capabilities["Segments and timeframes<br/>[core.py]"]
end

subgraph group_retrieval["Symbol and Data Retrieval"]
  node_cookie_bootstrap["Cookie bootstrap<br/>[core.py]"]
  node_symbol_search["Symbol search<br/>[core.py]"]
  node_historical_lookup["Historical lookup<br/>[core.py]"]
  node_direct_lookup["Direct-token lookup<br/>[core.py]"]
  node_chart_request["Chart data request<br/>[core.py]"]
end

subgraph group_formatting["Data Formatting"]
  node_ohlcv_processor["OHLCV formatter<br/>[utils.py]"]
end

node_user(("Python caller"))
node_nse_search_api["NSE symbol API"]
node_nse_chart_api["NSE chart API"]
node_nse_site["NSE website"]
node_ohlcv_data["OHLCV DataFrame"]

node_user -->|"uses"| node_nse_data
node_nse_data -->|"lists"| node_capabilities
node_symbol_search -->|"ensures cookies"| node_cookie_bootstrap
node_historical_lookup -->|"ensures cookies"| node_cookie_bootstrap
node_direct_lookup -->|"ensures cookies"| node_cookie_bootstrap
node_historical_lookup -->|"resolves symbol"| node_symbol_search
node_symbol_search -->|"posts search"| node_nse_search_api
node_cookie_bootstrap -->|"gets cookies"| node_nse_site
node_historical_lookup -->|"fetches data"| node_chart_request
node_direct_lookup -->|"fetches data"| node_chart_request
node_chart_request -->|"posts request"| node_nse_chart_api
node_chart_request -->|"formats response"| node_ohlcv_processor
node_ohlcv_processor -->|"returns frame"| node_ohlcv_data
node_user -->|"searches symbols"| node_symbol_search
node_user -->|"requests history"| node_historical_lookup
node_user -->|"requests by token"| node_direct_lookup

click node_nse_data "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_capabilities "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_cookie_bootstrap "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_symbol_search "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_historical_lookup "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_direct_lookup "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_chart_request "https://github.com/marketcalls/openchart/blob/master/openchart/core.py"
click node_ohlcv_processor "https://github.com/marketcalls/openchart/blob/master/openchart/utils.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_nse_data,node_capabilities toneBlue
class node_cookie_bootstrap,node_symbol_search,node_historical_lookup,node_direct_lookup,node_chart_request toneAmber
class node_ohlcv_processor,node_nse_search_api,node_nse_chart_api toneMint
class node_user,node_nse_site,node_ohlcv_data toneIndigo
```

## Components

### Client API

- [NSEData client](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`
- [Segments and timeframes](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`

### Symbol and Data Retrieval

- [Cookie bootstrap](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`
- [Symbol search](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`
- [Historical lookup](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`
- [Direct-token lookup](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`
- [Chart data request](https://github.com/marketcalls/openchart/blob/master/openchart/core.py): `openchart/core.py`

### Data Formatting

- [OHLCV formatter](https://github.com/marketcalls/openchart/blob/master/openchart/utils.py): `openchart/utils.py`

### Other components

- **Python caller**
- **NSE symbol API**
- **NSE chart API**
- **NSE website**
- **OHLCV DataFrame**

## Connections

- Python caller → NSEData client: uses (evidence: `README.md`)
- NSEData client → Segments and timeframes: lists (evidence: `README.md`)
- Symbol search → Cookie bootstrap: ensures cookies (evidence: `openchart/core.py`)
- Historical lookup → Cookie bootstrap: ensures cookies (evidence: `openchart/core.py`)
- Direct-token lookup → Cookie bootstrap: ensures cookies (evidence: `openchart/core.py`)
- Historical lookup → Symbol search: resolves symbol (evidence: `openchart/core.py`)
- Symbol search → NSE symbol API: posts search (evidence: `openchart/core.py`)
- Cookie bootstrap → NSE website: gets cookies (evidence: `openchart/core.py`)
- Historical lookup → Chart data request: fetches data (evidence: `openchart/core.py`)
- Direct-token lookup → Chart data request: fetches data (evidence: `openchart/core.py`)
- Chart data request → NSE chart API: posts request (evidence: `openchart/core.py`)
- Chart data request → OHLCV formatter: formats response (evidence: `openchart/core.py`)
- OHLCV formatter → OHLCV DataFrame: returns frame (evidence: `openchart/utils.py`)
- Python caller → Symbol search: searches symbols (evidence: `README.md`)
- Python caller → Historical lookup: requests history (evidence: `README.md`)
- Python caller → Direct-token lookup: requests by token (evidence: `README.md`)
