<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aarya Parekh</title>
    <description>The latest articles on DEV Community by Aarya Parekh (@aariiparekh3012).</description>
    <link>https://dev.to/aariiparekh3012</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4089868%2Fa23db6ab-cf55-43f8-99da-4d08ac2e7da9.jpg</url>
      <title>DEV Community: Aarya Parekh</title>
      <link>https://dev.to/aariiparekh3012</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aariiparekh3012"/>
    <language>en</language>
    <item>
      <title>Building a Real-Time Market Microstructure Analyzer for Indian Equities</title>
      <dc:creator>Aarya Parekh</dc:creator>
      <pubDate>Sat, 22 Aug 2026 15:47:23 +0000</pubDate>
      <link>https://dev.to/aariiparekh3012/building-a-real-time-market-microstructure-analyzer-for-indian-equities-30j3</link>
      <guid>https://dev.to/aariiparekh3012/building-a-real-time-market-microstructure-analyzer-for-indian-equities-30j3</guid>
      <description>&lt;p&gt;Financial markets produce enormous amounts of data—but converting raw order-book updates into meaningful liquidity and order-flow signals requires more than displaying prices on a chart.&lt;/p&gt;

&lt;p&gt;I built the Real-Time Market Microstructure Analyzer, an open-source research platform that processes five-level order-book snapshots, calculates market microstructure indicators, and displays the results through an interactive dashboard.&lt;/p&gt;

&lt;p&gt;🔗 &lt;em&gt;Live demo: &lt;a href="https://aariiparekh3012-collab.github.io/quantproject2/" rel="noopener noreferrer"&gt;https://aariiparekh3012-collab.github.io/quantproject2/&lt;/a&gt;&lt;/em&gt;&lt;br&gt;
💻 &lt;em&gt;GitHub: &lt;a href="https://github.com/aariiparekh3012-collab/quantproject2" rel="noopener noreferrer"&gt;https://github.com/aariiparekh3012-collab/quantproject2&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;What is market microstructure?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Market microstructure studies how orders, trades, liquidity, and market participants interact to form prices.&lt;/p&gt;

&lt;p&gt;Rather than looking only at daily closing prices, microstructure analysis examines information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bid and ask prices&lt;/li&gt;
&lt;li&gt;Order-book depth&lt;/li&gt;
&lt;li&gt;Bid–ask spreads&lt;/li&gt;
&lt;li&gt;Order-flow imbalance&lt;/li&gt;
&lt;li&gt;Trading volume&lt;/li&gt;
&lt;li&gt;Price impact&lt;/li&gt;
&lt;li&gt;Execution costs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These measurements can help researchers understand short-term liquidity and trading behaviour.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;What the platform does&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The system accepts five-level order-book snapshots and processes them through a streaming analytics engine.&lt;/p&gt;

&lt;p&gt;It currently provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bid–ask and depth-weighted spread calculations&lt;/li&gt;
&lt;li&gt;Order-flow imbalance across multiple rolling windows&lt;/li&gt;
&lt;li&gt;Session VWAP and deviation bands&lt;/li&gt;
&lt;li&gt;Cumulative signed volume&lt;/li&gt;
&lt;li&gt;Kyle’s lambda price-impact estimates&lt;/li&gt;
&lt;li&gt;Amihud illiquidity estimates&lt;/li&gt;
&lt;li&gt;Roll spread estimates&lt;/li&gt;
&lt;li&gt;Rolling anomaly detection&lt;/li&gt;
&lt;li&gt;OFI strategy backtesting&lt;/li&gt;
&lt;li&gt;TWAP and replay-VWAP execution simulation&lt;/li&gt;
&lt;li&gt;FastAPI REST and WebSocket endpoints&lt;/li&gt;
&lt;li&gt;A React-based analytics dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The repository also includes an offline demonstration using embedded synthetic data for five NSE-listed equities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RELIANCE&lt;/li&gt;
&lt;li&gt;TCS&lt;/li&gt;
&lt;li&gt;HDFCBANK&lt;/li&gt;
&lt;li&gt;INFY&lt;/li&gt;
&lt;li&gt;ICICIBANK&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  System architecture
&lt;/h2&gt;

&lt;p&gt;The project has four main layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data ingestion&lt;/strong&gt;&lt;br&gt;
Generates deterministic synthetic order-book data or accepts data through an experimental brokerage adapter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Analytics engine&lt;/strong&gt;&lt;br&gt;
Calculates spread, liquidity, order-flow, VWAP, volume, price-impact, and anomaly signals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API layer&lt;/strong&gt;&lt;br&gt;
Publishes market data, analytics, and alerts using FastAPI and WebSockets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Frontend dashboard&lt;/strong&gt;&lt;br&gt;
Displays the order book, price behaviour, VWAP, spread, OFI, cumulative delta, and statistical alerts.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each incoming snapshot is normalised and passed through the analytics engine. Stateful modules retain rolling windows and online aggregates between updates.&lt;/p&gt;
&lt;h2&gt;
  
  
  Core analytics
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Order-flow imbalance
&lt;/h3&gt;

&lt;p&gt;Order-flow imbalance, or OFI, measures changes in supply and demand at the best bid and ask.&lt;br&gt;
The platform calculates event-level OFI and aggregates it over rolling 60-second, 300-second, and 900-second windows.&lt;br&gt;
This helps identify whether recent order-book activity has been dominated by buying or selling pressure.&lt;/p&gt;
&lt;h3&gt;
  
  
  Spread and liquidity
&lt;/h3&gt;

&lt;p&gt;The spread module calculates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quoted spread&lt;/li&gt;
&lt;li&gt;Relative spread&lt;/li&gt;
&lt;li&gt;Depth-weighted spread&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system also includes Kyle’s lambda, Amihud illiquidity, and Roll spread estimators to examine different aspects of liquidity and price impact.&lt;/p&gt;
&lt;h3&gt;
  
  
  VWAP and volume
&lt;/h3&gt;

&lt;p&gt;Session VWAP is calculated through online running sums and resets at the trading-day boundary.&lt;br&gt;
The volume module uses tick-rule classification to estimate signed volume, create price-level volume profiles, and maintain cumulative delta.&lt;/p&gt;
&lt;h3&gt;
  
  
  Anomaly detection
&lt;/h3&gt;

&lt;p&gt;The platform monitors spread, volume, and OFI using rolling z-scores.&lt;br&gt;
When a metric crosses the configured threshold—three standard deviations by default—the engine generates an alert.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building for reproducibility
&lt;/h2&gt;

&lt;p&gt;One of my priorities was ensuring that another developer could reproduce the same research workflow.&lt;/p&gt;

&lt;p&gt;The synthetic market-data generator therefore uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A local seeded random-number generator&lt;/li&gt;
&lt;li&gt;A fixed clock&lt;/li&gt;
&lt;li&gt;A configurable number of ticks&lt;/li&gt;
&lt;li&gt;Deterministic symbol-level output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python scripts/generate_sample_data.py &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--ticks-per-symbol&lt;/span&gt; 1000 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--seed&lt;/span&gt; 42
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the same configuration and seed produces the same snapshots and analytics records.&lt;/p&gt;

&lt;p&gt;The project also includes automated tests, linting, coverage checks, frontend build validation, and reproducibility smoke tests through GitHub Actions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Backtesting and execution simulation
&lt;/h2&gt;

&lt;p&gt;The repository includes an OFI-based directional backtester with configurable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Entry and exit thresholds&lt;/li&gt;
&lt;li&gt;Lookback period&lt;/li&gt;
&lt;li&gt;Transaction costs&lt;/li&gt;
&lt;li&gt;Position size&lt;/li&gt;
&lt;li&gt;Initial capital&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It reports trade-level profit and loss, maximum drawdown, profit factor, win rate, and an unannualised completed-trade return statistic.&lt;/p&gt;

&lt;p&gt;The execution simulator compares TWAP with an ex-post replay-VWAP schedule. It walks the available order-book levels and reports fill quantities, slippage, and implementation shortfall.&lt;br&gt;
These components test the research pipeline—not the existence of a profitable trading strategy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Engineering challenges
&lt;/h2&gt;

&lt;p&gt;Developing the project involved fixing several issues that commonly arise in real-time analytical systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inconsistent timestamp fields between the backend and frontend&lt;/li&gt;
&lt;li&gt;Incorrect data types in tick classification&lt;/li&gt;
&lt;li&gt;Expensive repeated scans of rolling windows&lt;/li&gt;
&lt;li&gt;Missing-data failures in statistical estimators&lt;/li&gt;
&lt;li&gt;Transaction-cost reconciliation in backtesting&lt;/li&gt;
&lt;li&gt;WebSocket protocol differences between HTTP and HTTPS&lt;/li&gt;
&lt;li&gt;Reproducibility problems caused by global randomness and wall-clock timestamps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rolling OFI and anomaly modules were redesigned using queues and running aggregates so that processing work remains bounded as the session history grows.&lt;/p&gt;
&lt;h2&gt;
  
  
  Running the project locally
&lt;/h2&gt;

&lt;p&gt;Clone the repository and start the backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/aariiparekh3012-collab/quantproject2.git
&lt;span class="nb"&gt;cd &lt;/span&gt;quantproject2

python &lt;span class="nt"&gt;-m&lt;/span&gt; venv .venv
&lt;span class="nb"&gt;source&lt;/span&gt; .venv/bin/activate

pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env

uvicorn backend.api.main:app &lt;span class="nt"&gt;--reload&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then start the React dashboard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;frontend
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backend will be available at &lt;code&gt;http://localhost:8000&lt;/code&gt;, while the dashboard will run at &lt;code&gt;http://localhost:5173&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, the self-contained offline demo can be opened directly from &lt;code&gt;demo/index.html&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current limitations
&lt;/h2&gt;

&lt;p&gt;The current version uses deterministic synthetic data for its validated workflow.&lt;br&gt;
An Angel One SmartAPI adapter exists in the repository, but it remains experimental and is not a completed production data connector.&lt;/p&gt;

&lt;p&gt;Similarly, results produced from synthetic or replayed data validate the software pipeline—not predictive power, profitability, or exchange-feed correctness. Those claims would require licensed historical data and proper out-of-sample testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;This project helped me connect quantitative-finance theory with practical software engineering.&lt;br&gt;
The most important lesson was that implementing a formula is only one part of building a research platform. Reproducibility, testing, data consistency, computational efficiency, and honest documentation are equally important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;Future improvements may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Completing and validating live-data integration&lt;/li&gt;
&lt;li&gt;Adding reconnect and subscription-recovery logic&lt;/li&gt;
&lt;li&gt;Testing with licensed historical order-book data&lt;/li&gt;
&lt;li&gt;Expanding the backtesting framework&lt;/li&gt;
&lt;li&gt;Introducing additional execution models&lt;/li&gt;
&lt;li&gt;Adding more dashboard controls and research visualisations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are interested in quantitative finance, market microstructure, Python, or streaming analytics, feel free to explore the repository and share your feedback.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This project is intended for research and educational purposes and does not constitute investment advice.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>fintech</category>
      <category>react</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
