# nicolassinott/imc_prosperity architecture

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

- Interactive diagram: https://gitdiagram.com/nicolassinott/imc_prosperity
- Repository: https://github.com/nicolassinott/imc_prosperity

## Overview

1. This repository is a quantitative trading bot project for the IMC Prosperity competition. The runtime architecture is centered on a single exchange-facing trader entrypoint that receives market state from IMC and returns orders each tick.

2. The core execution boundary is the IMC challenge framework. `datamodel.py` defines the shared data structures used at that boundary, such as the market state, listings, order books, trades, and observations. All strategy code depends on these types.

3. `trader.py` is the main bot entrypoint used by the competition harness. It is the place where the active strategy is wired together and where per-tick decisions are made from the incoming state to outgoing orders.

4. The round-specific files (`round1_trader.py` through `round5_trader.py`) separate strategy logic by competition phase and product set. Each file encodes a different trading model tailored to the instruments introduced in that round.

5. The trading logic is mostly signal-driven and stateless across rounds, but each strategy maintains short-term history internally where needed. Examples from the README include:
   - mean-reversion around a fixed anchor for PEARLS,
   - EMA-based trading for BANANAS,
   - spread/z-score arbitrage for COCONUTS vs PINA_COLADAS,
   - seasonal/time-based logic for BERRIES,
   - signal trading from DOLPHIN_SIGHTINGS for DIVING_GEAR,
   - basket/component spread trading for PICNIC_BASKET.

6. The data flow during execution is: IMC simulator sends market snapshot and observations → `datamodel.py` structures it → strategy code computes indicators such as EMA, spread, z-score, or derivative thresholds → orders are emitted back to the simulator. This is a closed loop with no external database or service dependency shown in the repo.

7. The notebooks under `notebooks/` are the research and analysis layer, not the live trading layer. They appear to be used for exploratory data analysis, parameter selection, and post-run result analysis for individual rounds and strategies.

8. `manual_trade_r1.py` is a separate utility for hands-on or ad hoc trading/testing for round 1. It likely exists as a lightweight experiment harness distinct from the automated competition bot.

9. The `img/` directory contains charts and screenshots that support the strategy write-up in the README. These assets document observed patterns such as spreads, seasonality, and signal thresholds, but they do not affect runtime behavior.

10. Architecturally, the repo is split into two main concerns: strategy research/validation and live execution. The notebooks and plots feed insight into the round trader scripts; the trader scripts and datamodel form the deployable bot that interfaces with the IMC platform.

11. For diagramming, the key nodes are: IMC challenge environment, `datamodel.py`, `trader.py` as the active entrypoint, round-specific strategy modules as internal decision engines, and notebooks as offline analytics inputs. The main boundary is between offline analysis and online order generation.

Main entry points: [`datamodel.py`](https://github.com/nicolassinott/imc_prosperity/blob/main/datamodel.py) (Data model), [`trader.py`](https://github.com/nicolassinott/imc_prosperity/blob/main/trader.py) (Main trader), [`round3_trader.py`](https://github.com/nicolassinott/imc_prosperity/blob/main/round3_trader.py) (Round 3), [`round2_trader.py`](https://github.com/nicolassinott/imc_prosperity/blob/main/round2_trader.py) (Round 2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_live["Live trading"]
  node_datamodel["Data model<br/>shared types<br/>[datamodel.py]"]
  node_trader["Main trader<br/>entrypoint<br/>[trader.py]"]
  node_r1["Round 1<br/>strategy module<br/>[round1_trader.py]"]
  node_r2["Round 2<br/>strategy module<br/>[round2_trader.py]"]
  node_r3["Round 3<br/>strategy module<br/>[round3_trader.py]"]
  node_r4["Round 4<br/>strategy module<br/>[round4_trader.py]"]
  node_r5["Round 5<br/>strategy module<br/>[round5_trader.py]"]
  node_manual["Manual trade<br/>ad hoc harness<br/>[manual_trade_r1.py]"]
end

subgraph group_research["Research"]
  node_notebooks1["Round 1 notebook<br/>analysis notebook"]
  node_notebooks2["Round 2 notebook<br/>analysis notebook"]
  node_notebooks3["Results analysis<br/>analysis notebook"]
  node_notebooks4["Round 3 notebook<br/>analysis notebook"]
  node_notebooks5["Berries notebook<br/>analysis notebook"]
  node_notebooks6["Diving gear<br/>analysis notebook"]
  node_notebooks7["Dolphins notebook<br/>analysis notebook"]
  node_notebooks8["Round 4 notebook<br/>analysis notebook"]
  node_notebooks9["Round 5 EDA<br/>analysis notebook"]
  node_notebooks10["Round 5 results<br/>analysis notebook"]
  node_notebooks11["Optimized coconuts<br/>analysis notebook"]
  node_notebooks12["Final report<br/>analysis notebook"]
end

node_imc{{"IMC harness<br/>external simulator"}}

node_imc -->|"state snapshot"| node_datamodel
node_datamodel -->|"input types"| node_trader
node_trader -->|"round 1 logic"| node_r1
node_trader -->|"round 2 logic"| node_r2
node_trader -->|"round 3 logic"| node_r3
node_trader -->|"round 4 logic"| node_r4
node_trader -->|"round 5 logic"| node_r5
node_r1 -->|"orders"| node_datamodel
node_r2 -->|"orders"| node_datamodel
node_r3 -->|"orders"| node_datamodel
node_r4 -->|"orders"| node_datamodel
node_r5 -->|"orders"| node_datamodel
node_manual -->|"test harness"| node_datamodel
node_notebooks1 -.->|"research input"| node_r1
node_notebooks2 -.->|"research input"| node_r2
node_notebooks3 -.->|"evaluation"| node_r1
node_notebooks3 -.->|"evaluation"| node_r2
node_notebooks4 -.->|"research input"| node_r3
node_notebooks5 -.->|"research input"| node_r3
node_notebooks6 -.->|"research input"| node_r3
node_notebooks7 -.->|"research input"| node_r3
node_notebooks8 -.->|"research input"| node_r4
node_notebooks9 -.->|"research input"| node_r5
node_notebooks10 -.->|"evaluation"| node_r5
node_notebooks11 -.->|"optimization"| node_r2
node_notebooks12 -.->|"summary"| node_trader

click node_datamodel "https://github.com/nicolassinott/imc_prosperity/blob/main/datamodel.py"
click node_trader "https://github.com/nicolassinott/imc_prosperity/blob/main/trader.py"
click node_r1 "https://github.com/nicolassinott/imc_prosperity/blob/main/round1_trader.py"
click node_r2 "https://github.com/nicolassinott/imc_prosperity/blob/main/round2_trader.py"
click node_r3 "https://github.com/nicolassinott/imc_prosperity/blob/main/round3_trader.py"
click node_r4 "https://github.com/nicolassinott/imc_prosperity/blob/main/round4_trader.py"
click node_r5 "https://github.com/nicolassinott/imc_prosperity/blob/main/round5_trader.py"
click node_manual "https://github.com/nicolassinott/imc_prosperity/blob/main/manual_trade_r1.py"
click node_notebooks1 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/01-round1-bananas_pears.ipynb"
click node_notebooks2 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/02-round2-coconuts_pinacolada.ipynb"
click node_notebooks3 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/03-results_analyser.ipynb"
click node_notebooks4 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/04-round3-mayberries.ipynb"
click node_notebooks5 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/05-round3-berries.ipynb"
click node_notebooks6 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/05-round3-diving_gear.ipynb"
click node_notebooks7 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/06-round3-dolphins.ipynb"
click node_notebooks8 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/07-round4-picniq.ipynb"
click node_notebooks9 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/08-round5-eda.ipynb"
click node_notebooks10 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/09-round5-analysing_results.ipynb"
click node_notebooks11 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/10-coconuts_pina_coladas_optimized.ipynb"
click node_notebooks12 "https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/11-final_report.ipynb"

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_datamodel,node_trader,node_r1,node_r2,node_r3,node_r4,node_r5,node_manual toneBlue
class node_notebooks1,node_notebooks2,node_notebooks3,node_notebooks4,node_notebooks5,node_notebooks6,node_notebooks7,node_notebooks8,node_notebooks9,node_notebooks10,node_notebooks11,node_notebooks12 toneAmber
class node_imc toneNeutral
```

## Components

### Live trading

Deployable bot that runs inside the IMC Prosperity competition loop.

- [Data model](https://github.com/nicolassinott/imc_prosperity/blob/main/datamodel.py): shared types · Defines the market state, listings, order books, trades, and observations passed across the IMC boundary. · `datamodel.py`
- [Main trader](https://github.com/nicolassinott/imc_prosperity/blob/main/trader.py): entrypoint · Competition entrypoint that wires the active strategy and produces orders per tick. · `trader.py`
- [Round 1](https://github.com/nicolassinott/imc_prosperity/blob/main/round1_trader.py): strategy module · Round-specific logic for early products such as PEARLS and BANANAS. · `round1_trader.py`
- [Round 2](https://github.com/nicolassinott/imc_prosperity/blob/main/round2_trader.py): strategy module · Round-specific logic for the coconuts and pina coladas spread setup. · `round2_trader.py`
- [Round 3](https://github.com/nicolassinott/imc_prosperity/blob/main/round3_trader.py): strategy module · Round-specific logic for berries and dolphin-driven products. · `round3_trader.py`
- [Round 4](https://github.com/nicolassinott/imc_prosperity/blob/main/round4_trader.py): strategy module · Round-specific logic for basket and component trading. · `round4_trader.py`
- [Round 5](https://github.com/nicolassinott/imc_prosperity/blob/main/round5_trader.py): strategy module · Late-round strategy logic and final competition refinements. · `round5_trader.py`
- [Manual trade](https://github.com/nicolassinott/imc_prosperity/blob/main/manual_trade_r1.py): ad hoc harness · Lightweight utility for hands-on or experimental round 1 trading. · `manual_trade_r1.py`

### Research

Offline analysis and strategy development artifacts.

- [Round 1 notebook](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/01-round1-bananas_pears.ipynb): analysis notebook · Offline exploration for bananas and pears strategy development. · `notebooks/01-round1-bananas_pears.ipynb`
- [Round 2 notebook](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/02-round2-coconuts_pinacolada.ipynb): analysis notebook · Offline exploration for the coconuts and pina coladas spread. · `notebooks/02-round2-coconuts_pinacolada.ipynb`
- [Results analysis](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/03-results_analyser.ipynb): analysis notebook · General post-run result analysis and evaluation. · `notebooks/03-results_analyser.ipynb`
- [Round 3 notebook](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/04-round3-mayberries.ipynb): analysis notebook · Offline exploration for mayberries and seasonality-driven trading. · `notebooks/04-round3-mayberries.ipynb`
- [Berries notebook](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/05-round3-berries.ipynb): analysis notebook · Offline exploration for berries seasonal behavior and timing. · `notebooks/05-round3-berries.ipynb`
- [Diving gear](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/05-round3-diving_gear.ipynb): analysis notebook · Offline exploration for dolphin-signal trading in diving gear. · `notebooks/05-round3-diving_gear.ipynb`
- [Dolphins notebook](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/06-round3-dolphins.ipynb): analysis notebook · Offline exploration for dolphin sightings as a trading signal. · `notebooks/06-round3-dolphins.ipynb`
- [Round 4 notebook](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/07-round4-picniq.ipynb): analysis notebook · Offline exploration for picnic basket relative-value trading. · `notebooks/07-round4-picniq.ipynb`
- [Round 5 EDA](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/08-round5-eda.ipynb): analysis notebook · Late-stage exploratory data analysis and feature inspection. · `notebooks/08-round5-eda.ipynb`
- [Round 5 results](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/09-round5-analysing_results.ipynb): analysis notebook · Post-run evaluation and tuning for the final round. · `notebooks/09-round5-analysing_results.ipynb`
- [Optimized coconuts](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/10-coconuts_pina_coladas_optimized.ipynb): analysis notebook · Parameter tuning and optimization for the coconuts and pina coladas strategy. · `notebooks/10-coconuts_pina_coladas_optimized.ipynb`
- [Final report](https://github.com/nicolassinott/imc_prosperity/blob/main/notebooks/11-final_report.ipynb): analysis notebook · Summary notebook consolidating findings and final strategy narrative. · `notebooks/11-final_report.ipynb`

### Other components

- **IMC harness**: external simulator · Competition runtime that sends market state and receives orders each tick.

## Connections

- IMC harness → Data model: state snapshot · IMC provides the market state through shared data structures.
- Data model → Main trader: input types · The entrypoint consumes the shared market and observation types.
- Main trader → Round 1: round 1 logic · Main entrypoint can wire in the round-specific strategy.
- Main trader → Round 2: round 2 logic · Main entrypoint can wire in the round-specific strategy.
- Main trader → Round 3: round 3 logic · Main entrypoint can wire in the round-specific strategy.
- Main trader → Round 4: round 4 logic · Main entrypoint can wire in the round-specific strategy.
- Main trader → Round 5: round 5 logic · Main entrypoint can wire in the round-specific strategy.
- Round 1 → Data model: orders · Strategies compute orders from the current market state.
- Round 2 → Data model: orders · Strategies compute orders from the current market state.
- Round 3 → Data model: orders · Strategies compute orders from the current market state.
- Round 4 → Data model: orders · Strategies compute orders from the current market state.
- Round 5 → Data model: orders · Strategies compute orders from the current market state.
- Manual trade → Data model: test harness · Ad hoc round 1 trading uses the same core market types.
- Round 1 notebook → Round 1: research input · Offline analysis informs the round 1 strategy.
- Round 2 notebook → Round 2: research input · Offline analysis informs the round 2 strategy.
- Results analysis → Round 1: evaluation · Shared results analysis supports strategy tuning.
- Results analysis → Round 2: evaluation · Shared results analysis supports strategy tuning.
- Round 3 notebook → Round 3: research input · Offline analysis informs the round 3 strategy.
- Berries notebook → Round 3: research input · Offline analysis informs the round 3 strategy.
- Diving gear → Round 3: research input · Offline analysis informs the round 3 strategy.
- Dolphins notebook → Round 3: research input · Offline analysis informs the round 3 strategy.
- Round 4 notebook → Round 4: research input · Offline analysis informs the round 4 strategy.
- Round 5 EDA → Round 5: research input · Offline analysis informs the round 5 strategy.
- Round 5 results → Round 5: evaluation · Post-run analysis informs late-round tuning.
- Optimized coconuts → Round 2: optimization · Parameter optimization supports the round 2 spread strategy.
- Final report → Main trader: summary · Final write-up consolidates the live architecture and findings.
