What is FIX API? Why is FIX API helpful?
FIX API. FIX is the so-called Financial Information eXchange (FIX) protocol. It is a message-based standard for the …
This is a function to send a subscription request message for streaming quotes.
Usually, when a message describing the full refresh(the market data’ updates) arrives, the MarketDataSnapshotFullRefresh callback will be triggered.
The message type (MsgType, Tag ID: 35) is “V”. Actually, this tag field is encapsulated, only useful when you check the log file.
We will set the message to the these tag fields:
SubscriptionRequestType can be set to SubscriptionRequestType.SNAPSHOT_UPDATES or SubscriptionRequestType.DISABLE_PREVIOUS_SNAPSHOT_UPDATE_REQUEST.
SubscriptionRequestType.SNAPSHOT_UPDATES stands for a request to subscribe.
SubscriptionRequestType.DISABLE_PREVIOUS_SNAPSHOT_UPDATE_REQUEST stands for a request to unsubscribe.
This tag field will be set to an integer number generated when we subscribe to the streaming quotes.
The generated number should be stored in the class member variable temporarily to prepare for setting when we unsubscribe.
mdr.set(new SubscriptionRequestType(subscriptionRequestType));
if (subscriptionRequestType == SubscriptionRequestType.SNAPSHOT_UPDATES) {
// ...
long nextId = nextID();
mdr.set(new MDReqID(String.valueOf(nextId)));
} else {
if (mdReqID != null) {
mdr.set(new MDReqID(mdReqID));
} else {
return;
}
}
Usually, MarketDepth is set to 1 to get the top of book.
mdr.set(new MarketDepth(1)); // Top of Book
MDUpdateType can be set to MDUpdateType.FULL_REFRESH or MDUpdateType.INCREMENTAL_REFRESH.
MDUpdateType.FULL_REFRESH stands for a request to subscribe Market Data Snapshot Full Refresh.
MDUpdateType.INCREMENTAL_REFRESH stands for a request to subscribe Market Data Incremental Refresh.
Usually, it’s set to MDUpdateType.FULL_REFRESH.
mdr.set(new MDUpdateType(MDUpdateType.FULL_REFRESH));
Group of Market Data Entry Type (NoMDEntryTypes, Tag ID: 268)
Market Data Entry Type (MDEntryType, Tag ID: 269)
Each symbol should include a group setting of market data entry types.
If we want to get the Bid price, we need to set an entry type to MDEntryType.BID.
If we want to get the Ask(Offer) price, we need to set an entry type to MDEntryType.OFFER.
MarketDataRequest.NoMDEntryTypes types = null;
types = new MarketDataRequest.NoMDEntryTypes();
types.set(new MDEntryType(MDEntryType.BID));
mdr.addGroup(types);
types = new MarketDataRequest.NoMDEntryTypes();
types.set(new MDEntryType(MDEntryType.OFFER));
mdr.addGroup(types);
Group of Related Symbol (NoRelatedSym, Tag ID: 146)
Symbol Name (Symbol, Tag ID: 55)
The two tag fields setup a list of symbols, the streaming quotes of which we want to subscribe to.
MarketDataRequest.NoRelatedSym symbol = new MarketDataRequest.NoRelatedSym();
symbol.set(new quickfix.field.Symbol(symbolName));
mdr.addGroup(symbol);
mdr.setString(Account.FIELD, accountId);
The received messages will output to the “datalog” folder.
If you want to parse them, please use Fintechee Online FIX Parser.
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).
Please access our Github repository to get the latest source codes.
private void sendMarketDataRequestList(char subscriptionRequestType) {
try {
MarketDataRequest mdr = new MarketDataRequest();
mdr.set(new SubscriptionRequestType(subscriptionRequestType));
mdr.set(new MarketDepth(1)); // Top of Book
if (subscriptionRequestType == SubscriptionRequestType.SNAPSHOT_UPDATES) {
mdr.set(new MDUpdateType(MDUpdateType.FULL_REFRESH));
long nextId = nextID();
mdr.set(new MDReqID(String.valueOf(nextId)));
} else {
if (mdReqID != null) {
mdr.set(new MDReqID(mdReqID));
} else {
return;
}
}
for (String symbolName : symbolsList) {
MarketDataRequest.NoMDEntryTypes types = null;
types = new MarketDataRequest.NoMDEntryTypes();
types.set(new MDEntryType(MDEntryType.BID));
mdr.addGroup(types);
types = new MarketDataRequest.NoMDEntryTypes();
types.set(new MDEntryType(MDEntryType.OFFER));
mdr.addGroup(types);
MarketDataRequest.NoRelatedSym symbol = new MarketDataRequest.NoRelatedSym();
symbol.set(new quickfix.field.Symbol(symbolName));
mdr.addGroup(symbol);
}
mdr.setString(Account.FIELD, accountId);
send(mdr);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
}
FIX API. FIX is the so-called Financial Information eXchange (FIX) protocol. It is a message-based standard for the …
This is the FIX API Starter Application Class. It includes: A method to be called to start FIX API Data session A method …
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