Skip to content

Market Data Event

BlitzTrader's API empowers your strategy by providing real-time market data, encompassing both Level-I and Level-II data. Level-I data includes best bid and offer quotes for tradable securities, offering a snapshot of current market prices. On the other hand, Level-II data delves deeper, revealing the highest bid prices, lowest ask prices, and corresponding sizes from various market participants for a specific security. This granular Level-II data is invaluable to traders as it sheds light on the buying and selling pressure behind individual securities.

Before delving into the utilization of Blitz API for handling market data events and accessing price information, it's essential to grasp some fundamental market-related price terminologies.

Market Depth

Market depth, a component of Level-II data, offers insights into the supply and demand dynamics of a stock across different price levels. It serves as a crucial indicator of market sentiment, providing traders with a comprehensive view of the market's liquidity and potential price movements. Essentially, market depth displays the cumulative volume of orders at each price level, revealing the depth of the market's liquidity profile. This information is dynamic, continuously updating to reflect new orders entering the market and existing orders being executed or withdrawn. In essence, market depth provides traders with a comprehensive overview of current market activity, empowering them to make informed decisions based on the prevailing supply and demand dynamics.

Following is the snapshot of HINDZINC Securities up to 5 level depths. In market depth information, you can see a summary of all orders that are currently in the market. The information is continuously updated as new orders arrive and existing orders are filled or being pulled from the market.

HINDZINC

Bid AND Ask

Let's illustrate the concept of 5-level market depth using an example of a fictional stock, XYZ Inc. Suppose XYZ Inc. is currently trading at $100 per share. The 5-level market depth for XYZ Inc. would display the following information:

Bid Prices (Buy Orders):

Level 1 Bid Price: $99.95 (100 shares)
Level 2 Bid Price: $99.90 (200 shares)|
Level 3 Bid Price: $99.85 (150 shares)
Level 4 Bid Price: $99.80 (300 shares)
Level 5 Bid Price: $99.75 (100 shares)

Ask Prices (Sell Orders):

Level 1 Ask Price: $100.05 (50 shares)
Level 2 Ask Price: $100.10 (100 shares)
Level 3 Ask Price: $100.15 (150 shares)
Level 4 Ask Price: $100.20 (200 shares)|
Level 5 Ask Price: $100.25 (100 shares)

Here's what this information reveals:

Bid Prices (Buy Orders):

These are the prices at which buyers are willing to purchase shares of XYZ Inc. stock. The bid prices are arranged from the highest bid price (Level 1) to the lowest bid price (Level 5). For example, at Level 1, buyers are willing to buy 100 shares of XYZ Inc. at $99.95 per share.

Ask Prices (Sell Orders):

These are the prices at which sellers are willing to sell shares of XYZ Inc. stock. The ask prices are arranged from the lowest ask price (Level 1) to the highest ask price (Level 5). For example, at Level 1, sellers are offering to sell 50 shares of XYZ Inc. at $100.05 per share.

Bid and Ask prices:

Bid and Ask prices play a fundamental role in the dynamics of the financial markets. The bid price represents the highest price that a buyer is willing to pay for a security at a given moment, while the ask price denotes the lowest price at which a seller is willing to sell. Essentially, the bid reflects the demand side of the market, while the ask represents the supply side. When referring to bids, it indicates the quantity of shares that buyers want to purchase at a specified maximum price. Conversely, asks signify the quantity of shares available for sale at a minimum price. The bid price is also known as the "buy" price, whereas the ask price is referred to as the "sell" or "offer" price.

Trades occur when the bid and ask prices converge, either by the bid price being raised to meet the ask price or vice versa. This convergence marks the point at which a transaction takes place between a buyer and a seller. Throughout regular market trading hours, bid prices typically remain lower than ask prices, resulting in what is known as a "price spread." Understanding bid and ask prices is essential for traders as they navigate the markets, enabling them to assess the current supply and demand dynamics and make informed decisions regarding buying and selling securities.

Bid-Ask Spread:

Spread, in the context of trading, refers to the variance between the highest bid price and the lowest ask price for a particular security. It essentially represents the gap between what buyers are willing to pay and what sellers are asking for. In highly liquid markets, where trading volumes are high, the bid-ask spread tends to be narrow. This indicates that there is a broad consensus among market participants regarding the fair value of the security. Conversely, in less liquid markets or during periods of low trading activity, the spread tends to widen. This widening occurs because there may be fewer buyers and sellers in the market, leading to discrepancies in pricing perceptions.

A narrow spread is advantageous for traders as it reduces transaction costs, allowing them to enter and exit positions more efficiently. On the other hand, a wide spread can erode potential profits, especially for short-term traders, as it implies a larger price differential between buying and selling. Understanding and monitoring the bid-ask spread is crucial for traders as it provides valuable insights into market liquidity and pricing dynamics. By analyzing the spread, traders can gauge market sentiment, identify potential trading opportunities, and make informed decisions about when to execute trades.

BID price

Tick Size

Tick size refers to the minimum allowable price movement for a particular financial instrument in a trading market. It serves as the smallest increment by which the price of equity, future, or other exchange-traded asset can change. In essence, tick size dictates the granularity of price changes that are permitted during trading sessions.

For instance, let's consider the NSE Nifty, a prominent stock market index in India. The tick size for Nifty futures contracts is typically 0.05. This means that the price of the Nifty futures contract can only change in increments of 0.05 points. So, if the Nifty is trading at 11500, the next permissible price levels would be 11500.05, 11500.10, 11500.15, and so forth.

If for any instrument the Tick Size is 00001. A price change, then, from 1.2345 to 1.2346 would represent one tick. Ticks do not have to be measured in factors of 10. For example, a market might measure price movements in minimum increments of 0.25. For that market, a price change from 450.00 to 451.00 is four ticks or one point.

Tick sizes are integral to maintaining order and consistency within financial markets. They are defined by regulatory bodies or exchange operators and are outlined in the contract specifications for each trading instrument. In futures markets, tick sizes are often fixed, whereas in stock markets, they may vary based on the price level of the asset.

Tick Value

Tick Value refers to the monetary worth of a single tick, representing the smallest possible price movement allowed in a particular market. It is a crucial concept for traders as it quantifies the financial impact of price changes on their positions.

To illustrate, let's consider the E-Mini S&P 500 futures market, where the tick size is 0.25. This means that the price of the futures contract can move in increments of 0.25 points. Now, if the tick value is $12.50, it implies that for every 0.25-point movement in the price of the futures contract, the profit or loss for a trade would change by $12.50.

For instance, suppose a trader buys a single E-Mini S&P 500 futures contract at a price of 3000. If the price increases by one tick to 3000.25, the trader's profit would be $12.50 (assuming a long position). Conversely, if the price decreases by one tick to 2999.75, the trader's loss would also be $12.50.

Understanding the tick value is essential for traders to assess the potential risk and reward of their trades accurately. It allows them to calculate the profit or loss for each price movement and determine the appropriate position size based on their risk tolerance and trading strategy.

Blitz Strategy API provides Event callback OnMarketDataEvent method in your strategy that developers need to override to get notification of change in market data information for subscribed instrument variable

This code snippet demonstrates how to handle various aspects of market data within the OnMarketDataEvent method, including retrieving bid/ask prices, checking for changes in the last trade, calculating VWAP (Volume Weighted Average Price), accessing the best quoted price, and retrieving instrument information.

private IVObject _iv = new IVObject( "Instrument", "Tradable Instrument", true, InstrumentType.Futures | InstrumentType.Options, MarketDataType.All, OrderEventType.All);
private IOrderCommand _entryOrderCommand = null;
....
....
protected override void OnMarketDataEvent(StrategyMarketDataEventArgs strategyMarketDataEventArgs)
{
    if (strategyMarketDataEventArgs.IVObject == _iv)
    {
        ITouchLineInfo touchLineInfo = strategyMarketDataEventArgs.MarketDataContainerInfo.TouchLineInfo;
        double bestBidPrice = touchLineInfo.BestBidPrice;
        int bestBidSize = touchLineInfo.BestBidSize;
        double bestAskPrice = touchLineInfo.BestAskPrice;
        int bestAskSize = touchLineInfo.BestAskSize;
        double lastPrice = touchLineInfo.LastPrice;
        int lastSize = touchLineInfo.LastSize;
        long lastTradedTime = touchLineInfo.LastTradedTime;
    }
}
// Check if touchline represents a change in any attribute of the last trade
bool isLastPriceChange = touchLineInfo.IsLastPriceChange;

// Access the previous last price
double lastPrice = touchLineInfo.PreviousLastPrice;

// IMarketDepthInfo interface provides depth level price and size information
IMarketDepthInfo marketDepthInfo = strategyMarketDataEventArgs.MarketDataContainerInfo.MarketDepthInfo;

double totalSumBidPrice = 0;
int totalBidSize = 0;

// Calculating BuySide VWAP price till depth level 5
for (int i = 0; i < marketDepthInfo.MarketDepthLevel; i++)
{
    totalSumBidPrice += marketDepthInfo.GetBidPriceAt(i);
    totalBidSize += marketDepthInfo.GetBidSizeAt(i);

    // Break loop conditions
    if (i >= 5 || marketDepthInfo.GetBidSizeAt(i) == 0 || marketDepthInfo.GetBidPriceAt(i) <= 0)
        break;
}

// Calculate VWAP Bid price till 5th depth level
double vwapBidPriceTill5Level = totalSumBidPrice / totalBidSize;
// Use smart order to access a best quoted price
if (_entryOrderCommand.CurrentOrder == null)
    entryOrderPrice = base.GetBestPrice(_ivInfo.MarketDataContainer, entrySide);
else
    entryOrderPrice = base.GetBestPrice(_ivInfo.MarketDataContainer, _entryOrderCommand.CurrentOrder);

// Access Instrument information
IMarketDepthInfo marketDepthInfo = strategyMarketDataEventArgs.MarketDataContainerInfo.MarketDepthInfo;
QX.Base.Common.InstrumentInfo.Instrument instrument = strategyMarketDataEventArgs.IVInstrument.Instrument;

if (instrument.InstrumentType == InstrumentType.Options)
{
    Options optionInstrument = (Options)instrument;
    double strikePrice = optionInstrument.StrikePrice;
    DateTime contractExpiration = optionInstrument.ContractExpiration;
}