Case study · IPO Allotment Engine

One day to get every share right. No room for error.

How I helped a SEBI-registered registrar go from a licence to a working IPO platform. My work ran from the algorithms that decide who gets shares to the portal where investors check what they got.

Role
Software Engineer, freelance
Client
Niche Technologies, via JRat's Studio
Timeline
Mar – Oct 2026
Team
Four engineers

India's T+3 listing timeline

  1. T

    6:00 PM

    Bidding closes

  2. T+1

    by 9:30 PMThe crunch

    Validate, reconcile, allot, get exchange approval

  3. T+2

    by 11:00 AM

    Shares credited, refunds released

  4. T+3

    10:00 AM

    Trading begins

01The problem

A licence, a deadline, and no platform.

When a company lists in India, a Registrar & Transfer Agent sits between the issuer, the exchanges, the depositories and the banks. It decides which bids are valid and who gets shares, under three pressures at once.

One working day

Once bidding closes, every bid has to be validated, reconciled and allotted, and the exchange has to approve, all before 9:30 PM the next day.

Millions of bids, many sources

Exchanges, depositories, banks and UPI each send their own files in their own formats. All of them have to reconcile with each other.

No room for error

A single share allotted wrongly is a regulatory event. The output has to match the registrar's sheet exactly.

Two incumbents handle most Indian IPOs, on systems built over decades. Our client held a SEBI Category I registrar licence but had no platform to process an IPO. The goal was to build one, so a new registrar could compete, starting with SME issues.

02What we built

A pipeline from raw bids to allotted shares.

Four engineers built a platform that takes an IPO from closing bell to listing, end to end.

  1. 01

    Ingest

    Exchange bid files, bank and UPI confirmations

  2. 02

    Validate

    20+ checks, each with a stable rejection code

  3. 03

    Reconcile

    Bids matched against blocked funds and depositories

  4. 04

    Allot

    Category quotas, spillover and lotteries

  5. 05

    Approve

    Operators review, accept and finalise, all audited

  6. 06

    Publish

    Settlement outputs and investor status lookup

Under the hood it runs as an event-driven batch pipeline on AWS. Operators work in a separate control plane, and investors get an isolated public read path. My work touched every stage.

03My role

Six layers. I worked in every one.

I led the engine at the heart of the product, built most of the surfaces around it, and wrote in five languages along the way.

repositories
8
commits
233
working days
81
lines of code added
122k
languages
5

Allotment & validation engine

Led

The core of the product: it decides which bids are valid and who receives shares.

  • Created the repository and wrote most of its algorithms: validators, reconciliation, category quotas with spillover, and allotment for every investor category.
  • Wrote a deterministic lottery allocator: a run fails outright if the winners or shares don't add up exactly.
  • Wrote the container entrypoint that every batch job runs on.
  • Designed a rejection-policy framework that makes re-runs during an IPO reproducible.
  • Python
  • Polars
  • RE2
  • Pydantic

Control-plane API

Built

The backbone operators rely on: configuration, access control, and an audit trail regulators can trust.

  • Wrote the service from its first commit, including auth, role-based access and the deploy pipeline.
  • Added a tamper-proof audit trail that hashes every change and that the database itself won't let anyone edit.
  • Built IPO configuration and 8 counterparty registries, with all-or-nothing CSV import.
  • Go
  • Gin
  • PostgreSQL

Operator portal

Built

Where the registrar's team sets up an IPO and watches it run.

  • MFA login, session handling, and logout that applies across every open tab.
  • A Create-IPO form that checks SEBI's allocation limits as operators type.
  • Live monitors for incoming bid files and running jobs.
  • Next.js
  • React
  • Tailwind

Public status portal

Built

The only part investors see, and it has to survive result-day traffic.

  • Sole author of the backend, the frontend and the infrastructure module.
  • Kept separate from the operational database, so investor traffic never reaches the core system.
  • Built it end to end in four days, then wired it into a two-region production setup.
  • Go
  • Next.js
  • DynamoDB
  • OpenTofu

Synthetic data & test oracle

Led

Real IPO data is confidential, so this is how the whole pipeline got tested.

  • Generates a complete, realistic IPO from a single config: exchange, depository and bank files.
  • Injects known errors and predicts what each check should reject, so the pipeline is tested against ground truth.
  • Scales to full-size IPOs with 400k+ applications.
  • Python
  • Polars
  • pytest

Database schema

Contributed

Encodes the domain and enforces the rules that keep decisions safe.

  • Tables for IPO domain entities and their intermediaries.
  • Governance tables for reviewed decisions; the database allows only one accepted version per IPO.
  • PostgreSQL
  • Flyway

04The journey

Eight months, month by month.

How the work unfolded from the first commit to production hardening.

  1. March

    Foundations

    Set up the control API with auth and an immutable audit trail, plus the operator portal's MFA login. Ran the first validation prototypes and benchmarks on 10 million rows.

  2. April – May

    From prototype to engine

    Switched to a linear-time regex engine and prototyped reconciliation. Containerised the engine for batch jobs, wrote about 15 tested validators, and the first version of the test-data generator.

  3. June

    Rebuilt to match the registrar

    Deleted the first allotment engine and rebuilt it to mirror the registrar's sheets. Shipped 8 counterparty registries across the API, the portal and the schema.

  4. July

    Quotas, lotteries, honest test data

    Built a category-quota engine verified on 11 public IPOs and a lottery allocator with audit checks. Added SEBI limit checks to the portal and found the root causes behind the misleading test data.

  5. August

    Facing investors

    Built the public status portal in four days. Fixed allotment edge cases, including deficit winners and anchor exclusion, and added allotment for institutional investors.

  6. September

    Real data

    The readiness exercise on 530k real bids matched the registrar, with mutual-fund allotment identical row for row. Shipped the rejection-policy framework.

  7. October

    Hardening

    Took depository matching from 0 to 99.97% agreement, behind a propose-only, audited apply step. Wired the status portal into production.

05Key decisions

Five calls that shaped the work.

01/Allotment

Match the registrar, not the textbook

3,191

lines deleted to get it right

The problem
My first allotment engine followed SEBI's rules as written, with a seeded lottery and a tidy proportional model. An allotment that disagrees with the registrar by a single share is still wrong.
What I did
I deleted it and rebuilt it to reproduce the registrar's own sheets column by column. That meant spreadsheet-style rounding, a deterministic fix for rounding drift, and winners chosen by exchange-supplied numbers.
What happened
Every run has to add up exactly to the shares on offer, or it stops. Mutual-fund allotment matched the registrar's sheet row for row.

02/Performance

Measure before choosing

10M

rows per benchmark

The problem
Duplicate detection and reconciliation had to finish overnight on IPOs with up to 10 million rows.
What I did
I benchmarked four duplicate-detection strategies on 10M rows instead of picking the fashionable one, and replaced a regex timeout workaround with a linear-time engine.
What happened
The dataframe option came last and a plain external sort won. A vectorised reconciliation prototype handled 10M records in about 5 seconds.

03/Safety

Make the dangerous path impossible

0

automatic promotions, by design

The problem
Moving an investor into the wrong category changes who gets shares, and operators re-run checks many times during an IPO.
What I did
Recategorisation only demotes and only proposes; ambiguous cases go to a person. Changes are applied through a reviewed, audited step, and every re-run starts from a frozen snapshot of earlier rejections.
What happened
The database allows only one accepted version per IPO, and the same inputs always give the same result.

04/Quality

When the test data lied

5

root causes found and fixed

The problem
Bids we generated as invalid were passing the real pipeline as valid.
What I did
I traced five root causes. Some errors were recorded only inside the generator, IDs collided once an IPO passed 130k applications, and replayed random numbers drifted between files. I rebuilt the generator around a single source of truth.
What happened
Its predictions were compared check by check with the real pipeline, and they matched exactly on the core checks.

05/Collaboration

Review as a safety net

99.97%

category agreement

The problem
On real data, depository matching found zero rows at first. Later, a fallback rule wrongly demoted institutional investors.
What I did
I fixed the join. When a teammate's review flagged the fallback, I reproduced it on real data, reverted it, and rebuilt the mapping from the depository's official circular.
What happened
Category agreement reached 99.97%, with no institutional investors wrongly demoted.

06Results

Checked against a real IPO.

530k

real IPO bids run through the platform in a production readiness exercise

The data came from a recent mainboard IPO and is kept anonymous. Matching totals alone was never the bar: every difference from the registrar's independent results had to be explained.

match with the registrar on every validation check exercised
Exact
agreement on final investor category
99.97%
mutual-fund allotment rows identical to the registrar's sheet
38 / 38
institutional investors wrongly demoted after the review fix
0
public IPOs used to verify the quota engine
11

07Stack

The right tool for each layer.

Data & algorithms
PythonPolarsPydanticgoogle-re2pytest
Services
GoGinAWS LambdaAWS Batch
Frontend
Next.jsReactTailwindAmplify
Data stores
PostgreSQLDynamoDBFlyway
Infrastructure
AWSOpenTofuDockerCodeBuild

08Reflection

Where it stands.

In regulated systems, correctness comes more from structure than from clever code.

The real-data exercise proved the validation and allotment logic against an independent registrar. Certification of the full live workflow, including bank execution and some re-run edge cases, is still in progress.

Three things made the difference: reproducing the source of truth exactly, making unsafe actions impossible rather than unlikely, and testing against an oracle that already knows the right answer.

Further reading

Let's work together

Building something that has to be exactly right? Let's talk.