In algorithmic trading, generating a trading signal is only half the battle. The other, often more complex half is execution and getting those 100 lots of NIFTY into the market at a price that doesn't erode your profits or add execution slippages. This is where Blitz Strategy shines, not merely as a rule-based engine, but as a sophisticated execution management framework.
Blitz Strategy is a programmable component developed using C# via the Blitz Strategy Development SDK. While strategy development (defining entry/exit rules) is not the core focus of this article, we will focus on how the Blitz SDK provides robust execution logic for orders. Specifically, we will explore the OrderCommandEx concept and how to integrate price derivation and quantity slicing algorithms to achieve seamless, custom execution.
The Core Problem: From Signal to Execution
| Problem | Description |
|---|---|
| Slippage | Executing at worse prices than expected, especially in volatile markets |
| Market Impact | Your own large order moving the price against you |
| Rejection Risk | Insufficient liquidity at the top of the order book causing partial or failed fills |
Blitz solves these problems by introducing a structured execution abstraction called OrderCommandEx.
Understanding OrderCommandEx ld.
OrderCommandEx is a declarative execution component that encapsulates:
• What instrument to trade
• How to derive the price for each order slice
• How to slice the total quantity into smaller manageable pieces
The Creation Process
To create an OrderCommandEx, you must provide at least three core elements:
csharp
OrderCommandEx cmdEx = new OrderCommandEx(
ivObject, // Instrument (e.g., NIFTY Futures)
priceDerivAlgo, // Price derivation algorithm
quantitySlicerAlgo // Quantity slicing algorithm
);
| Component | Role |
|---|---|
| IVObject | The instrument being traded (NIFTY, BANKNIFTY, or specific stock) |
| PriceDerivationAlgo | Determines at what price each slice should be quoted |
| QuantitySlicerAlgo | Determines how much quantity to send per slice and when |
How the Framework Uses These Algorithms
Once OrderCommandEx is created and linked to an IOrderCommand handle, the Blitz framework automatically invokes your algorithms during execution. These invocations are triggered by real-time market data events of the underlying instrument such as a new tick, a change in the order book, or a trade update. This happens seamlessly without requiring you to write any loops, timers, or event handlers.
You then specify the total quantity you want to achieve:
orderCommand.SetOrderQuantity(100 * lotSize); // 100 lots
Execution Commands Reference
The IOrderCommand interface provides four intuitive methods for position management:
| Command | Description | Example |
|---|---|---|
| EnterLong() | Achieve a long position for the set order quantity. If already long, maintains or adjusts to the specified quantity. | orderCommand.EnterLong(0); |
| EnterShort() | Achieve a short position for the set order quantity. If already short, maintains or adjusts accordingly. | orderCommand.EnterShort(0); |
| SetPosition() | Achieve an absolute position (positive = long, negative = short). |
orderCommand.SetPosition(50);// Net 50 lots long |
| GoFlat() | Square off the entire position (bring net position to zero). | orderCommand.GoFlat(); |
Advanced: EnterLong/EnterShort with Reference Price
Strategists can provide a reference price to help the algorithm quote more intelligently:
// Provide a benchmark price (e.g., theoretical fair value, VWAP, or signal price)
double referencePrice = CalculateTheoreticalFairValue();
orderCommand.EnterLong(referencePrice);
The price derivation algorithm can use this reference to:
• Quote closer to fair value
• Avoid chasing prices far from expected entry
1. Calculates the first slice quantity using your QuantitySlicerAlgo
2. Derives the price using your PriceDerivationAlgo
3. Places the order (limit or market based on your algorithm) and modify as new price updated from PriceDerivationAlgo
4. Monitors fill status
5. Repeats steps 1-4 until the desired position of 100 lots is achieved
6. Handles partial fills, rejections, and timeouts gracefully
Why This Matters
| Benefit | Explanation |
|---|---|
| Customization without complexity | You control how prices are derived and how quantity is sliced, while Blitz manages the order lifecycle |
| Reduced market impact | Slicing prevents moving the market against your own large orders |
| Intelligent execution | Algorithms can adapt to volatility, liquidity, and market direction |
| Deterministic risk management | SetPosition and GoFlat commands ensure precise position control |
| C# performance | Being SDK-based, all execution logic runs with native .NET speed |
| Reference price support | Smart quoting based on user-provided benchmarks improves fill quality |
This is the essence of Blitz's design philosophy: it abstracts away the complexity of slicing, pricing, order routing, fill monitoring, and retry logic. You are freed from low-level execution concerns to focus on what truly matters is your trading logic and execution quality.
Signal generation and execution no longer compete for your attention. Instead, they work in perfect harmony, each powerful in its own right, together forming a seamless and intelligent trading system.