|
From: Vamsi P. <vam...@we...> - 2018-06-27 13:12:19
|
Yes i did as you suggested.please find below code. As a callback method "
toApp" method is calling.Please help me.
package com.wealthobjects.fix.application;
import quickfix.Application;
import quickfix.DoNotSend;
import quickfix.FieldNotFound;
import quickfix.IncorrectDataFormat;
import quickfix.IncorrectTagValue;
import quickfix.RejectLogon;
import quickfix.Session;
import quickfix.SessionID;
import quickfix.SessionNotFound;
import quickfix.UnsupportedMessageType;
import quickfix.field.Currency;
import quickfix.field.DeleteReason;
import quickfix.field.ExpireDate;
import quickfix.field.ExpireTime;
import quickfix.field.MDEntryID;
import quickfix.field.MDEntryOriginator;
import quickfix.field.MDEntryPositionNo;
import quickfix.field.MDEntryPx;
import quickfix.field.MDEntrySize;
import quickfix.field.MDEntryType;
import quickfix.field.MDReqID;
import quickfix.field.MDUpdateAction;
import quickfix.field.MDUpdateType;
import quickfix.field.MarketDepth;
import quickfix.field.MsgType;
import quickfix.field.NoMDEntryTypes;
import quickfix.field.NoRelatedSym;
import quickfix.field.NumberOfOrders;
import quickfix.field.SenderCompID;
import quickfix.field.SubscriptionRequestType;
import quickfix.field.Symbol;
import quickfix.field.TargetCompID;
import quickfix.fix44.MarketDataIncrementalRefresh;
import quickfix.fix44.Logon;
import quickfix.fix44.MarketDataIncrementalRefresh.NoMDEntries;
import quickfix.fix44.MarketDataRequest;
import quickfix.fix44.MarketDataSnapshotFullRefresh;
import quickfix.fix44.NewOrderSingle;
import quickfix.fix44.SecurityDefinition;
import quickfix.Message;
import quickfix.MessageCracker;
public class WoFixApplication extends MessageCracker implements Application{
public void onCreate(SessionID sessionId) {
System.out.println("session created with
counterpart--->"+sessionId.getBeginString());
}
public void onLogon(SessionID sessionId) {
System.out.println("onLogon with
counterpart--->"+sessionId.getBeginString());
}
public void onLogout(SessionID sessionId) {
System.out.println("onLogout with
counterpart--->"+sessionId.getBeginString());
}
public void toAdmin(Message message, SessionID sessionId) {
System.out.println("toAdmin with
counterpart--->"+sessionId.getBeginString());
System.out.println("message--->"+message.bodyLength());
}
public void fromAdmin(Message message, SessionID sessionId) throws
FieldNotFound, IncorrectDataFormat,
IncorrectTagValue, RejectLogon{
System.out.println("fromAdmin with
counterpart--->"+sessionId.getBeginString());
System.out.println("message--->"+message.bodyLength());
}
public void toApp(quickfix.Message message, SessionID sessionId){
try {
System.out.println("toApp with
counterpart--->"+sessionId.getBeginString());
System.out.println("message--->"+message.bodyLength());
System.out.println("market message--->"+message.getHeader().getField(new
MsgType()).getValue());
System.out.println("market message getClass--->"+message.getClass());
System.out.println("header types from
toApp------>"+message.getHeader().getString(MsgType.FIELD));
//crack((MarketDataRequest)message,sessionId);
if
(MsgType.MARKET_DATA_SNAPSHOT_FULL_REFRESH.equals(message.getHeader().getField(new
MsgType()).getValue())) {
// Handle snapshot here
System.out.println("Received a full market data snapshot");
}
else if
(MsgType.MARKET_DATA_INCREMENTAL_REFRESH.equals(message.getHeader().getField(new
MsgType()).getValue())) {
// Handle incremental updates here
System.out.println("Received an incremental market data update");
}else
if(MsgType.MARKET_DATA_REQUEST.equals(message.getHeader().getField(new
MsgType()).getValue())) {
System.out.println("Received an MARKET_DATA_REQUEST market data update");
System.out.println("getFieldOrder
length---->"+message.getHeader().getFieldOrder().length);
/*message.
int numberOfEntries = message.getField(new NoMDEntries()).getValue();
MarketDataSnapshotFullRefresh.NoMDEntries group = new
MarketDataSnapshotFullRefresh.NoMDEntries();
for(int i=0;i>=numberOfEntries;i++){
//business logic to read the message
message.getGroup(i , group);
int val = (int) group.getMDEntrySize().getValue();
System.out.println("value is = " + val);
}
*/
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void fromApp(Message message, SessionID sessionId) throws
FieldNotFound, IncorrectDataFormat,
IncorrectTagValue, UnsupportedMessageType{
System.out.println("fromApp with
counterpart--->"+sessionId.getBeginString());
System.out.println("message--->"+message.bodyLength());
System.out.println("market message--->"+message.getHeader().getField(new
MsgType()).getValue());
System.out.println("market message getClass--->"+message.getClass());
System.out.println("header types
fromApp------>"+message.getHeader().getString(MsgType.FIELD));
System.out.println("header types
fromApp------>"+message.getHeader().getFieldOrder().length);
if
(MsgType.MARKET_DATA_SNAPSHOT_FULL_REFRESH.equals(message.getHeader().getField(new
MsgType()).getValue())) {
// Handle snapshot here
System.out.println("Received a full market data snapshot");
}
else if
(MsgType.MARKET_DATA_INCREMENTAL_REFRESH.equals(message.getHeader().getField(new
MsgType()).getValue())) {
// Handle incremental updates here
System.out.println("Received an incremental market data update");
}else
if(MsgType.MARKET_DATA_REQUEST.equals(message.getHeader().getField(new
MsgType()).getValue())) {
System.out.println("Received an MARKET_DATA_REQUEST market data update");
System.out.println("getFieldOrder
length---->"+message.getHeader().getFieldOrder().length);
/*int numberOfEntries = message.getField(new NoMDEntries()).getValue();
MarketDataSnapshotFullRefresh.NoMDEntries group = new
MarketDataSnapshotFullRefresh.NoMDEntries();
for(int i=0;i<numberOfEntries;i++){
//business logic to read the message
message.getGroup(i , group);
int val = (int) group.getMDEntrySize().getValue();
System.out.println("value is = " + val + " f = " +
f);
}
*/
}
}
/*@Override
public void onMessage(NewOrderSingle message, SessionID sessionID)
throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
System.out.println("Inside onMessage for New Order Single");
super.onMessage(message, sessionID);
}
@Override
public void onMessage(SecurityDefinition message, SessionID sessionID)
throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
System.out.println("Inside onMessage for SecurityDefinition");
super.onMessage(message, sessionID);
}
@Override
public void onMessage(Logon message, SessionID sessionID)
throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
System.out.println("Inside Logon Message");
super.onMessage(message, sessionID);
}
//market data call back functions
@Override
public void onMessage(MarketDataSnapshotFullRefresh message, SessionID
session)
throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
System.out.println("Inside MarketDataSnapshotFullRefresh Message");
String Symbol = message.get(new Symbol()).getValue();
System.out.println("Symbol from
MarketDataSnapshotFullRefresh"+Symbol);
super.onMessage(message, session);
}
@Override
public void onMessage(MarketDataRequest message, SessionID session)
throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
System.out.println("Inside MarketDataRequest Message");
System.out.println("------>"+message.getNoRelatedSym().getValue());
super.onMessage(message, session);
}*/
public void onMessage(MarketDataIncrementalRefresh message, SessionID
session)
throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
System.out.println("Inside MarketDataIncrementalRefresh Message");
System.out.println("------>"+message.getBoolean(1));
super.onMessage(message, session);
}
}
On Wed, Jun 27, 2018 at 4:01 PM, Øyvind Matheson Wergeland <
oyv...@om...> wrote:
> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
> QuickFIX/J Support: http://www.quickfixj.org/support/
>
>
>
>
> All inbound application level messages are passed to Application.fromApp.
> Note that FIX messages are asynchronous; there is no guarantee from the
> protocol when a response for your MarketDataRequest is returned.
>
> https://www.quickfixj.org/usermanual/2.0.0//usage/application.html
>
> You have to implement the Application interface and register it in your
> acceptor as in the example on the page above.
>
>
> Best regards
>
> *Øyvind Matheson Wergeland*
> CTO
>
> Mobile: (+47) 95 16 16 88
> E-mail: oyv...@om...
>
> *Oslo Market Solutions*
> PO Box 4, 0051 Oslo, Norway
> Telephone: (+47) 40 00 23 13
> www.oms.no
> On 06/27/2018 11:25 AM, Vamsi Pinnamaneni wrote:
>
> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
> QuickFIX/J Support: http://www.quickfixj.org/support/
>
>
>
> I am using following code
>
> public static void sendMarketDataRequest(SessionID sessionId)
> throws SessionNotFound {
> System.out.println("sending request........");
> // We generate a new request ID
> MDReqID reqId = new MDReqID("MDRQ-" + String.valueOf(System.
> currentTimeMillis()));
>
> // We want EUR/XBT data
> String currencyPair = "USD/VND";
>
> // We want to get a snapshot and also subscribe to the market depth updates
> SubscriptionRequestType subscriptionType = new SubscriptionRequestType(
> SubscriptionRequestType.SNAPSHOT);
>
> // We want the full book here, not just the top
> MarketDepth depthType = new MarketDepth(1);
>
> // We'll want only incremental refreshes when new data is available
> MDUpdateType updateType = new MDUpdateType(MDUpdateType.FULL_REFRESH);
>
> MarketDataRequest mdr = new MarketDataRequest(reqId, subscriptionType,
> depthType);
>
> mdr.setField(updateType);
>
> MarketDataRequest.NoRelatedSym instruments = new MarketDataRequest.
> NoRelatedSym();
> instruments.set(new Symbol(currencyPair));
> mdr.addGroup(instruments);
>
> // Specify that we'll want the bids and asks
> mdr.setField(new NoMDEntryTypes(2));
> MarketDataRequest.NoMDEntryTypes group = new MarketDataRequest.
> NoMDEntryTypes();
> group.set(new MDEntryType(MDEntryType.BID));
> group.set(new MDEntryType(MDEntryType.OFFER));
> mdr.addGroup(group);
>
> boolean fromMarket = Session.sendToTarget(mdr, sessionId);
> System.out.println("market request status--->"+fromMarket);
> }
>
> /////
> the request is success. after that which cal back method i need to check
> and how to parse that Code for getting Symbol prize.
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> Quickfixj-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/quickfixj-users
>
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Quickfixj-users mailing list
> Qui...@li...
> https://lists.sourceforge.net/lists/listinfo/quickfixj-users
>
>
--
Regards,
Vamsi Krishna Pinnamaneni
The information contained in this message may be confidential and is
intended for the addressee only. If you don't think this email is meant for
you, please let us know. Do not copy or forward the information it
contains, and delete this email from your system. Any personal views or
opinions are those of the author and do not necessarily represent those of
Wealth Objects Limited. This email does not create or vary any contractual
obligations between Wealth Objects Limited and the addressee.
|