# proshotv2/gamma-vanna-options-exposure architecture

> Architecture diagram of the GitHub repository proshotv2/gamma-vanna-options-exposure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/proshotv2/gamma-vanna-options-exposure
- Repository: https://github.com/proshotv2/gamma-vanna-options-exposure

## Overview

##### Main Components to Highlight
- External Data Provider: Indicate Tradier’s API as the external service supplying real-time options chain data, quotes, and expiration details.
- API Access and Credential Management: Represent the authentication mechanism (the function to retrieve the OAuth token and base URL), which configures access for both sandbox and production environments.
- Data Retrieval Module: Show the function(s) responsible for making the API calls (e.g., the get_quote function) and parsing responses.
- Calculation Module: Identify the mathematical processing layer where the application computes implied volatility (using the Black-Scholes or Black model), Gamma Exposure, and Vanna Exposure. Include components for:
- Calculating IV (using py_vollib_vectorized functions)
- Gamma Exposure calculation (gamma * OI * 100 * Spot Price^2)
- Vanna Exposure calculation (using vanna computed with inputs such as norm.pdf results and adjustments)
- Dash Web UI Module: Represent the frontend layer created with Dash. This component serves as the presentation layer where the computed exposures and possibly other data are rendered for the user.

##### Architectural Patterns and Design Principles
- Modularity by noting that functions such as get_tradier_credentials, get_quote, calculate_iv, and calculate_vanna provide a clear separation of concerns.

##### Relevant Technologies, Frameworks, and Libraries
- Python – The main programming language.
- Dash Library – For building the interactive web-based dashboard/interface.
- Requests Library – For making HTTP API calls to Tradier.
- Py_vollib_vectorized – For vectorized calculation of implied volatility.
- Standard libraries (math, norm from statistics/ scipy) – Used for mathematical and statistical operations.
- Tradier API – The external data source for market data.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Tradier API"]:::external
    B["API Credentials & Connector"]:::auth
    C["Data Retrieval & Parsing Module"]:::retrieval
    D["Exposure Calculations (IV, Gamma & Vanna)"]:::calc
    E["Dash Web UI"]:::ui
    note1["AUTH token at line 103"]:::note
    note2["ManualEdits for QQQ_Close & NQ_Close (line404-405)"]:::note

    E -->|"triggers_data_pull"| C
    B -->|"supplies_auth"| C
    C -->|"API_calls(Quotes,OptionsChain,Expirations)"| A
    C -->|"feeds_raw_data"| D
    D -->|"renders_results"| E

    B -.-> note1
    D -.-> note2

    click A "https://github.com/proshotv2/gamma-vanna-options-exposure/blob/main/main.py"
    click B "https://github.com/proshotv2/gamma-vanna-options-exposure/blob/main/main.py"
    click C "https://github.com/proshotv2/gamma-vanna-options-exposure/blob/main/main.py"
    click D "https://github.com/proshotv2/gamma-vanna-options-exposure/blob/main/main.py"
    click E "https://github.com/proshotv2/gamma-vanna-options-exposure/blob/main/main.py"

    classDef external fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef auth fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef retrieval fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef calc fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef ui fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef note fill:#e2e3e5,stroke:#6c757d,stroke-width:1px,font-style:italic;
```
