Skip to main content
SIH-Grade Research Build

Sovereign-AMM

A high-frequency algorithmic market maker for physical microgrids. Treats the central battery as a deterministic exchange, not a predictor.

Project Overview

Sovereign-AMM models a physical microgrid as a financial limit-order exchange. The central battery acts as the automated market maker, continuously quoting bid and ask prices for energy (kWh) using deterministic closed-form mathematics — no machine learning in the pricing path.

The engine runs at 10 Hz, emitting a WebSocket tick stream consumed by a Next.js dashboard in real time. Every trade is appended to an immutable event log; the order book and battery SoC are projections derived from that log, never independently mutated.

Key Technologies

GLFT Bounded-Inventory Quoting

Guéant-Lehalle-Fernandez-Tapia asymptotic market-making model with inventory-skewed bid/ask quotes. Inventory is normalised to [-1, +1] and hard walls suppress quotes when SoC hits floor/ceiling.

delta_bid(q) = base + ((2q+1)/2) × spreaddelta_ask(q) = base − ((2q−1)/2) × spread

Rainflow Battery Wear Cost

Streaming 3-point rainflow stack identifies charge/discharge cycles and computes marginal degradation cost per kWh of throughput at depth-of-discharge d. Added to the ask price only.

C_deg(d) = C_capex / (2 × N_cycles(d) × E_nominal × η)N_cycles(d) = N₀ × d^(−β) (Wöhler)

PTDF Grid Screening

Power Transfer Distribution Factor screening enforces transmission line flow constraints. Trades that would breach any line limit are rejected before they hit the order book.

f = PTDF @ p_injectionreject if |f + ΔPTDF × dP| > f_max × margin

Architecture

Event-Sourced Ledger

State lives in an append-only event log. Order book and SoC are pure projections — never independently mutated.

L2 Order Book

Price-time priority limit order book with PTDF screening. AMM quotes inserted as maker orders each tick.

WebSocket 10 Hz Stream

FastAPI backend pushes market snapshots 10 times per second. Frontend Zustand store consumes ticks with shallow equality guards.

RAG Explainability Sidecar

Retrieval-augmented generation sidecar lets operators ask plain-English questions about live pricing decisions.

Micro-Price Reference

GLFT quotes reference the micro-price (volume-weighted mid) rather than the naive mid to reduce adverse selection.

Integer Micro-Units

All ledger accounting uses integer micro-units (1 unit = 1e-6 kWh or INR). Floats only in the pricing math layer.

Technology Stack

Engine

Python 3.11

NumPy

pytest

Backend

FastAPI

WebSockets

Uvicorn

Frontend

Next.js 14

TypeScript

Tailwind

Charts

Recharts

Zustand

Vitest