# anjaniputra15/prosperity-crushers architecture

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

- Interactive diagram: https://gitdiagram.com/anjaniputra15/prosperity-crushers
- Repository: https://github.com/anjaniputra15/prosperity-crushers

## Overview

##### Project Type and Purpose
- Type: Algorithmic trading research/backtesting framework with deployment and visualization
- Purpose:
– Ingest historical trading data by simulation round
– Provide a modular backtester engine
– Load and execute multiple strategy “plugins”
– Evaluate performance and generate visual reports
– Deploy chosen strategies into the live simulation environment

##### File Structure (Top-Level Components)
- data/
– CSV datasets grouped by simulation round (round1…round5, tutorial)
- backtester/
– Core engine: engine.py, benchmark.py
– Interfaces: algo.py (strategy plugin interface), datamodel.py, log.py
– Tests: test_backtester.py, test_backtester_macarons.py
- deployment/
– Round-specific trader implementations: round1/…/round5/
– Final deployment scripts: final/etf_deployment.py, kelp_deployment.py, etc.
– Shared datamodels: deployment/datamodel.py
- visualiser/
– Visualization scripts: visualiser.py
– Requirements, README for charting and reporting
- Individual contributor folders (Nathan/, Steven/, jack/, kieren/, max/)
– Research notebooks and one-off strategy prototypes

##### README for Insights
- Confirms components: research notes, strategies, backtesting frameworks, evaluation tools

##### Main Components
A. Data Ingestion Layer
– Component: CSV Loader
– Reads data/round*/prices_*.csv and trades_*.csv
B. Backtesting Engine
– engine.py (simulation loop, order matching, P&L calculation)
– datamodel.py (market state, order books, fills)
– algo.py (strategy interface)
– log.py / benchmark.py (performance metrics)
C. Strategy Plugins
– Individual Python modules implementing Algo interface
– Examples: kelp.py, basket_trade.py, resin_10k.py, etc.
– Lives in root or contributor folders but plugged into backtester
D. Deployment Layer
– Round-specific trader.py scripts
– Final production scripts in deployment/final/
– Use deployment/datamodel.py and wrap live order submission logic
E. Visualization & Reporting
– visualiser.py: reads backtester/log output, produces charts, tables
F. Research & Prototyping
– Jupyter notebooks under contributor folders (Nathan/, Steven/, jack/, etc.)
– Feeding new algorithms back into “Strategy Plugins”

##### Relationships and Data Flows
- Data Ingestion → Backtester Engine
- Backtester Engine ↔ Strategy Plugin (calls strategy.on_tick(), sends orders)
- Backtester Engine → Log / Benchmark → Visualization
- Backtester Engine → Deployment Layer (for live sim)
- Research Notebooks → Strategy Plugin (iterative prototyping)

##### Architectural Patterns and Principles
- Plugin architecture (algo.py interface)
- Layered separation: Data / Core engine / Strategy / Deployment / Visualization
- Single Responsibility: each module has a clear domain
- Test coverage for engine and strategy validation

##### Technologies, Frameworks, and Libraries
- Python 3.x
- Jupyter Notebooks for research
- CSV files for data
- pytest or unittest for backtester tests
- Matplotlib / Pandas / Seaborn (implied) for visualiser
- No external database – file-based data store

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        DBCSV(("data/round* CSV files")):::data
        CSVLoader["CSV Loader"]:::data
    end
    DBCSV --> CSVLoader

    %% Backtester Core
    subgraph "Backtester Core"
        Engine["engine.py"]:::core
        DataModel["datamodel.py"]:::core
        AlgoInterface["algo.py"]:::core
        Logger["log.py"]:::core
        Benchmark["benchmark.py"]:::core
    end
    CSVLoader -->|provides data| Engine
    Engine -->|uses state model| DataModel
    Engine -->|calls strategy| AlgoInterface
    Engine -->|records events| Logger
    Engine -->|computes metrics| Benchmark

    %% Backtester Tests
    subgraph "Backtester Tests"
        TestCore["test_backtester.py"]:::core
        TestMacarons["test_backtester_macarons.py"]:::core
    end
    TestCore -.-> Engine
    TestMacarons -.-> Engine

    %% Strategy Plugins
    subgraph "Strategy Plugins"
        Kelp["kelp.py"]:::strategy
        Basket["basket_trade.py"]:::strategy
        Resin["resin_10k.py"]:::strategy
        OtherStrategies["… other strategy modules"]:::strategy
    end
    AlgoInterface -->|implements| Kelp
    AlgoInterface -->|implements| Basket
    AlgoInterface -->|implements| Resin
    AlgoInterface -->|implements| OtherStrategies

    %% Deployment Layer
    subgraph "Deployment Layer"
        SharedDM["deployment/datamodel.py"]:::deploy
        Round1["round1/trader.py"]:::deploy
        Round2a["round2/trader.py"]:::deploy
        Round2b["round2/trader_steven_edit.py"]:::deploy
        Round3a["round3/trader.py"]:::deploy
        Round3b["round3/trader_steven.py"]:::deploy
        Round4["round4/trader.py"]:::deploy
        Round5["round5/trader.py"]:::deploy
        subgraph "Final Production Scripts"
            ETF["etf_deployment.py"]:::deploy
            KelpProd["kelp_deployment.py"]:::deploy
            BasketProd["basket_deployment.py"]:::deploy
            MacaronProd["macaron_deployment.py"]:::deploy
            ResinProd["resin_deployment.py"]:::deploy
            RockProd["rock_deployment.py"]:::deploy
            SquinkProd["squink_deployment.py"]:::deploy
            VolcanicProd["volcanic_deployment.py"]:::deploy
        end
    end
    Engine -->|deploys live| Round1
    Engine --> Round2a
    Engine --> Round2b
    Engine --> Round3a
    Engine --> Round3b
    Engine --> Round4
    Engine --> Round5
    Engine -->|production deploy| ETF
    Engine --> KelpProd
    Engine --> BasketProd
    Engine --> MacaronProd
    Engine --> ResinProd
    Engine --> RockProd
    Engine --> SquinkProd
    Engine --> VolcanicProd
    SharedDM --> Round1
    SharedDM --> Round2a
    SharedDM --> Round2b
    SharedDM --> Round3a
    SharedDM --> Round3b
    SharedDM --> Round4
    SharedDM --> Round5
    SharedDM --> ETF

    %% Visualization & Reporting
    subgraph "Visualization & Reporting"
        Visualiser["visualiser.py"]:::vis
        Req["requirements.txt"]:::vis
        Docs["README.md"]:::vis
    end
    Logger --> Visualiser
    Benchmark --> Visualiser

    %% Research & Prototyping
    subgraph "Research & Prototyping"
        Nathan["Nathan/"]:::research
        Steven["Steven/"]:::research
        Jack["jack/"]:::research
        Kieren["kieren/"]:::research
        Max["max/"]:::research
    end
    Nathan -.->|iterative prototyping| AlgoInterface
    Steven -.-> AlgoInterface
    Jack -.-> AlgoInterface
    Kieren -.-> AlgoInterface
    Max -.-> AlgoInterface

    %% Click Events
    click CSVLoader "https://github.com/anjaniputra15/prosperity-crushers/tree/main/data/"
    click Engine "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/engine.py"
    click DataModel "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/datamodel.py"
    click AlgoInterface "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/algo.py"
    click Logger "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/log.py"
    click Benchmark "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/benchmark.py"
    click TestCore "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/test_backtester.py"
    click TestMacarons "https://github.com/anjaniputra15/prosperity-crushers/blob/main/backtester/test_backtester_macarons.py"
    click SharedDM "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/datamodel.py"
    click Round1 "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round1/trader.py"
    click Round2a "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round2/trader.py"
    click Round2b "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round2/trader_steven_edit.py"
    click Round3a "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round3/trader.py"
    click Round3b "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round3/trader_steven.py"
    click Round4 "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round4/trader.py"
    click Round5 "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/round5/trader.py"
    click ETF "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/etf_deployment.py"
    click KelpProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/kelp_deployment.py"
    click BasketProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/basket_deployment.py"
    click MacaronProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/macaron_deployment.py"
    click ResinProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/resin_deployment.py"
    click RockProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/rock_deployment.py"
    click SquinkProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/squink_deployment.py"
    click VolcanicProd "https://github.com/anjaniputra15/prosperity-crushers/blob/main/deployment/final/volcanic_deployment.py"
    click Visualiser "https://github.com/anjaniputra15/prosperity-crushers/blob/main/visualiser/visualiser.py"
    click Req "https://github.com/anjaniputra15/prosperity-crushers/blob/main/visualiser/requirements.txt"
    click Docs "https://github.com/anjaniputra15/prosperity-crushers/blob/main/visualiser/README.md"
    click Nathan "https://github.com/anjaniputra15/prosperity-crushers/tree/main/Nathan/"
    click Steven "https://github.com/anjaniputra15/prosperity-crushers/tree/main/Steven/"
    click Jack "https://github.com/anjaniputra15/prosperity-crushers/tree/main/jack/"
    click Kieren "https://github.com/anjaniputra15/prosperity-crushers/tree/main/kieren/"
    click Max "https://github.com/anjaniputra15/prosperity-crushers/tree/main/max/"

    %% Styles
    classDef data fill:#bbdefb,stroke:#3949ab,color:#0d47a1
    classDef core fill:#c8e6c9,stroke:#2e7d32,color:#1b5e20
    classDef strategy fill:#ffe0b2,stroke:#ef6c00,color:#e65100
    classDef deploy fill:#e1bee7,stroke:#6a1b9a,color:#4a148c
    classDef vis fill:#b2dfdb,stroke:#00695c,color:#004d40
    classDef research fill:#eeeeee,stroke:#757575,color:#424242
```
