AlgoDevStudio
← Back to Blog
Scalping

Optimizing for Speed

By Senior Quant 4 min read

In scalping, slippage is the silent killer. A strategy that generates 10 points of profit on paper might only net 6 points in reality due to poor execution.

Here, we discuss the practical techniques we use at AlgoDevStudio to minimize latency on Indian exchanges (NSE/BSE).

1. Co-location vs. Virtual Co-location

True co-location (putting your server inside the exchange rack) is expensive and out of reach for most retail traders. However, "Virtual Co-location" is the next best thing. Hosting your execution server in AWS Mumbai (ap-south-1) puts you geographically as close as possible to the NSE servers. We've measured round-trip times of ~2ms from AWS Mumbai to NSE Connect.

2. The "Tick-to-Trade" Loop

Your code structure matters. If you are calculating indicators inside the same loop that handles order placement, you are introducing delay.

We use a producer-consumer model. One process solely consumes tick data and puts it into a queue. Another process consumes from that queue, runs logic, and fires orders. This decouples market data processing from execution logic, ensuring that heavy computations don't block order firing.

3. Limit vs. Market Orders

A common misconception is that Market orders are faster. They guarantee execution but not price. In volatile markets, you can get filled far away from the last traded price.

We prefer Limit Orders placed at Market Aggressiveness (e.g., Buy Limit at LTP + 0.5%). This acts like a market order (it will likely fill instantly) but protects you from "fat finger" spikes where a market order might fill 10% higher.

Chat on Telegram