preloader
blog-post

DATA FIX API ~ Market Data Incremental Refresh

author image

This is a callback function to receive streaming quote messages once the market movements change.

It can be triggered after a subscription request message for the streaming quotes is sent.

Usually, it’s a notification when a message describing the incremental refresh(the market data’ updates) arrives.

The message type (MsgType, Tag ID: 35) is “X”. Actually, this tag field is encapsulated, only useful when you check the log file.

We will get these tag fields from the message:

  • Sending Time (SendingTime, Tag ID: 52)
SendingTime sendingTime = new SendingTime();
((Message) snapshot).getHeader().getField(sendingTime);
LocalDateTime localDateTime = sendingTime.getValue();
long time = localDateTime.toEpochSecond(ZoneOffset.UTC);
  • Group of Market Data Incremental Refresh (NoMDEntries, Tag ID: 268)
NoMDEntries noMDEntries = new NoMDEntries();
snapshot.get(noMDEntries);

for (int i = 1; i <= noMDEntries.getValue(); i++) {
  MarketDataSnapshotFullRefresh.NoMDEntries types = new MarketDataSnapshotFullRefresh.NoMDEntries();
  snapshot.getGroup(i, types);

  // ...
}
  • Instrument Name (Symbol, Tag ID: 55)
String symbolName = types.getString(Symbol.FIELD);
  • Market Data Entry Type (MDEntryType, Tag ID: 269)

This is an enumeration variable to describe that the tick quote stands for Ask(Offer) or Bid.

  • Market Data Entry Price (MDEntryPx, Tag ID: 270)

This variable stands for the current tick quote.

MDEntryType mdEntryType = new MDEntryType();
MDEntryPx mdEntryPx = new MDEntryPx();

types.get(mdEntryType);

double bid = 0.0;
if (mdEntryType.getValue() == MDEntryType.BID) {
  types.get(mdEntryPx);
  bid = mdEntryPx.getValue();
}

double ask = 0.0;
if (mdEntryType.getValue() == MDEntryType.OFFER) {
  types.get(mdEntryPx);
  ask = mdEntryPx.getValue();
}

Difference from MarketDataSnapshotFullRefresh

MarketDataSnapshotFullRefresh is a message to receive one symbol’s quotes(including the bid price and the ask price).

MarketDataIncrementalRefresh is a message including all the updates of multiple symbols.

Relevant Articles

Fintechee Online FIX API Parser

The received messages will output to the “datalog” folder.

If you want to parse them, please use Fintechee Online FIX Parser.

Fintechee FIX API Trading Platform Individual Version

If you want to trade via FIX API, please use Fintechee FIX API Trading Platform Individual Version(Paid Version).

If you have a Github / Youtube account, you can get a free license for the paid version(No Charge)!

If you have no Github / Youtube account, you can still use Fintechee FIX API Trading Platform Bridge Version(Free Forever)!

If you are working for financial institutions, you can choose Fintechee FIX API Trading Platform Institution Version(White Label License).

Github Repository

Please access our Github repository to get the latest source codes.

The Entire Source Codes to ExecutionReport

public void onMessage(MarketDataIncrementalRefresh snapshot, SessionID sessionID) {
  try {
    SendingTime sendingTime = new SendingTime();
    ((Message) snapshot).getHeader().getField(sendingTime);
    LocalDateTime localDateTime = sendingTime.getValue();
    long time = localDateTime.toEpochSecond(ZoneOffset.UTC);

    NoMDEntries noMDEntries = new NoMDEntries();
    snapshot.get(noMDEntries);

    for (int i = 1; i <= noMDEntries.getValue(); i++) {
      MarketDataSnapshotFullRefresh.NoMDEntries types = new MarketDataSnapshotFullRefresh.NoMDEntries();
      snapshot.getGroup(i, types);

      String symbolName = types.getString(Symbol.FIELD);

      MDEntryType mdEntryType = new MDEntryType();
      MDEntryPx mdEntryPx = new MDEntryPx();

      types.get(mdEntryType);

      double bid = 0.0;
      if (mdEntryType.getValue() == MDEntryType.BID) {
        types.get(mdEntryPx);
        bid = mdEntryPx.getValue();
      }

      double ask = 0.0;
      if (mdEntryType.getValue() == MDEntryType.OFFER) {
        types.get(mdEntryPx);
        ask = mdEntryPx.getValue();
      }

      System.out.println(time + " " + symbolName + ": Ask " + ask + ", Bid " + bid);
    }
  } catch (Exception e) {
    e.printStackTrace();
    logger.error(e.getMessage());
  }
}

Recent Articles

blog-post

FIX API Starter Application Class

This is the FIX API Starter Application Class. It includes: A method to be called to start FIX API Data session A method …

Paid Consulting Service

We offer professional FIX API consulting services, including self-service options for establishing a broker business. There are no additional fees, and all resources can be utilized without any associated costs.

Book One
*