|
|
|
emreozen
|
Hi
I am trying to manually set the setNextSenderMsgSeqNum before every time I send out a message. Is this correct? I am trying to do this to get rid of the errors such as "Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. Expected 72 but message contained 71;" errors. Also, my Session object doesnt have this function? I would appreciate any help, Thanks in advance, |
||||||||||||||||
|
ofer yoshiahu
|
QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
QuickFIX/J Support: http://www.quickfixj.org/support/ i don't recommend this approach.
i don't know about your errors but you should let quickfixj handle the sequences for you. You should use setNextSenderMsgSeqNum only on extreme cases.
On Wed, Sep 30, 2009 at 11:55 PM, emreozen <[hidden email]> wrote: QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Quickfixj-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quickfixj-users |
||||||||||||||||
|
emreozen
|
ok, thanks, I will listen to your advice.
I managed to set up the initiator and connect, then my program goes into a while loop. I receive the logon message from the admin and the connection remains alive as I see the heartbeats. Where would be a good place to send an order in the code Should I start the order sending in the Logon function? My code is simple and I am really new to quickfix and Java, I would appreciate help. Thanks
|
|
Grant Birchmeier
|
QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
QuickFIX/J Support: http://www.quickfixj.org/support/ Sending the order is normally fired from some external control. For instance, you'd have a GUI that would command the app to fire orders, or some other algorithm thread. For your simple app, you should probably create a separate thread that will wait X seconds and send an order. This thread can be created and started in our onLogon() function. (Do not put Thread.sleep() in your onLogin() or any QFJ callback, as it will block your QFJ from receiving further messages until they expire.) -Grant On Thu, Oct 1, 2009 at 7:24 AM, emreozen <[hidden email]> wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > > ok, thanks, I will listen to your advice. > > I managed to set up the initiator and connect, then my program goes into a > while loop. > > I receive the logon message from the admin and the connection remains alive > as I see the heartbeats. > > Where would be a good place to send an order in the code > > Should I start the order sending in the Logon function? > > My code is simple and I am really new to quickfix and Java, I would > appreciate help. > > Thanks > > > ofer yoshiahu wrote: >> >> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >> QuickFIX/J Support: http://www.quickfixj.org/support/ >> >> >> >> i don't recommend this approach. >> i don't know about your errors but you should let quickfixj handle the >> sequences for you. >> You should use setNextSenderMsgSeqNum only on extreme cases. >> >> On Wed, Sep 30, 2009 at 11:55 PM, emreozen <[hidden email]> wrote: >> >>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>> QuickFIX/J <http://www.quickfixj.org/documentation/%0AQuickFIX/J> >>> Support: >>> http://www.quickfixj.org/support/ >>> >>> >>> >>> Hi >>> >>> I am trying to manually set the setNextSenderMsgSeqNum before every time >>> I >>> send out a message. >>> >>> Is this correct? I am trying to do this to get rid of the errors such as >>> "Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. >>> Expected 72 but message contained 71;" errors. >>> >>> Also, my Session object doesnt have this function? >>> >>> I would appreciate any help, >>> >>> Thanks in advance, >>> >>> -- >>> View this message in context: >>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3745596.html >>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>> >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9-12, 2009. Register >>> now! >>> http://p.sf.net/sfu/devconf >>> _______________________________________________ >>> Quickfixj-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register >> now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> Quickfixj-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >> >> > > -- > View this message in context: http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3748684.html > Sent from the QuickFIX/J mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Quickfixj-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quickfixj-users > ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Quickfixj-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quickfixj-users |
||||||||||||||||
|
emreozen
|
I have been trying to work this out but still getting the below error message:
"Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. Expected 3 but message contained 2" I couldn't figure it out, below is my code, I would appreciate help, I'm really struck at this: public class FixTrader implements Runnable{ private Thread tradingThread; private SessionID session; private boolean sent = false; FixTrader(SessionID s) { session = s; } public void run() { while (!Thread.interrupted()) { System.out.println("Thread started"); try{ Thread.sleep(10000); }catch(InterruptedException e) { e.printStackTrace();} if(!sent) { String custyID = new String("TEST@TEST.COM"); String account = new String("TESTACC"); MDReqID clientReference = new MDReqID("3333"); NewOrderSingle buyorder= getNewOrdersingl(custyID, account, new String(clientReference.getValue()), 15.0, 928.5, "BUY", "ESZ9 Index", "200912", "GLBX"); System.out.println("neworder"); sent = true; try{ Session.sendToTarget(buyorder, session); System.out.println("neworder"); } catch (SessionNotFound e2) { e2.printStackTrace();} } } } /** Start servicing quotes */ void start() { tradingThread = new Thread(this, "FixTrader"); tradingThread.start(); } /** Stop servicing quotes */ void stop() { if (tradingThread != null) { tradingThread.interrupt(); } } public NewOrderSingle getNewOrdersingl(String custyID, String account, String clientReferenceID, double quant, double limit, String side, String sym, String maturity, String exchange){ System.out.println("getNewOrdersingleSingle " ); NewOrderSingle newOrderSingle = new NewOrderSingle(); System.out.println("getNewOrdersingleSingle2 " ); newOrderSingle.setField(new ClientID(custyID)); newOrderSingle.setField(new Account(account)); newOrderSingle.setField(new ClOrdID(clientReferenceID)); newOrderSingle.setField(new HandlInst('1')); newOrderSingle.setField(new OrderQty(quant)); newOrderSingle.setField(new OrdType('2')); newOrderSingle.setField(new Price(limit)); if( side.equals("BUY")) newOrderSingle.setField(new Side('1')); else if( side.equals("SELL")) newOrderSingle.setField(new Side('2')); else System.exit(1); newOrderSingle.setField(new Symbol(sym)); newOrderSingle.setField(new TransactTime()); newOrderSingle.setField(new SecurityType("FUT")); newOrderSingle.setField(new MaturityMonthYear(maturity)); newOrderSingle.setField(new SecurityExchange(exchange)); return newOrderSingle; } } public class FixInit {//implements Runnable{ static String CONFIGURATION_DEFAULT_NAME = "fix.cfg" ; static String FileName; static SessionSettings settings1; private static FixApp application; private SocketInitiator socketinit; public static void main(String[] args)throws Exception{ InputStream inputStream; FileName = CONFIGURATION_DEFAULT_NAME; System.out.println("Program start"); System.out.println("connection started"); SessionSettings settings = new SessionSettings(FileName); application = new FixApp(settings); FileStoreFactory storeFactory = new FileStoreFactory(settings); LogFactory logFactory = new FileLogFactory(settings); MessageFactory messageFactory = new MessageFactory(); SocketInitiator init = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory); init.start(); while(true){} } } public class FixApp extends MessageCracker implements Application { private FixTrader fixTrader; ExecutorService threadExecutor; private int expected; public FixApp(SessionSettings s) { } public void onCreate(SessionID session) { System.out.println("on create: "); } public void onLogon(SessionID session) { fixTrader = new FixTrader(session); System.out.println("on logon: "); System.out.println("*** Threading started ***"); threadExecutor = Executors.newFixedThreadPool(1); threadExecutor.execute(fixTrader); } public void onLogout(SessionID session) { threadExecutor.shutdown(); System.out.println("on logout: "); } public void toAdmin(Message message, SessionID session) { printSeqNum(message); System.out.println("toAdmin: "+message); } public void toApp(Message message, SessionID session) { printSeqNum(message); System.out.println("toApp: " +message); } public void fromAdmin(Message message, SessionID session) { printSeqNumFrom1(message); System.out.println("fromAdmin: "+message); } //public void onMessage(Message message, SessionID session) public void onMessage( quickfix.fix42.NewOrderSingle message, SessionID sessionID ) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { ClOrdID clOrdID = new ClOrdID(); message.get(clOrdID); } public void onMessage( quickfix.fix42.OrderCancelRequest message, SessionID sessionID ) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { ClOrdID clOrdID = new ClOrdID(); message.get(clOrdID); } public void onMessage( quickfix.fix42.ExecutionReport message, SessionID sessionID ) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { System.out.println("Execution report"); } public void fromApp(Message message, SessionID session) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { System.out.println("fromApp: "+message); try { crack(message,session ); } catch (UnsupportedMessageType e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FieldNotFound e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IncorrectTagValue e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
|
||||||||||||||||
|
Grant Birchmeier
|
QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
QuickFIX/J Support: http://www.quickfixj.org/support/ Do you create the Acceptor too? I suggest setting ResetOnLogon=Y and SendResetSeqNumFlag=Y in your configuration files for both Acceptor and Initiator. This should remove sequence number issues from the equation, as both sides will always reset to 0 whenever an initiator logs in. When you get things running, you can take these back out and experiment with how QF/J works with sequence numbers. -Grant On Thu, Oct 8, 2009 at 2:50 PM, emreozen <[hidden email]> wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > > I have been trying to work this out but still getting the below error > message: > > "Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. > Expected 3 but message contained 2" > > I couldn't figure it out, below is my code, I would appreciate help, I'm > really struck at this: > > > public class FixTrader implements Runnable{ > private Thread tradingThread; > private SessionID session; > private boolean sent = false; > > FixTrader(SessionID s) > { > session = s; > } > > public void run() > { > while (!Thread.interrupted()) > { > System.out.println("Thread started"); > > try{ > > Thread.sleep(10000); > > }catch(InterruptedException e) > { e.printStackTrace();} > > > if(!sent) > { > > String custyID = new String("[hidden email]"); > String account = new String("TESTACC"); > MDReqID clientReference = new MDReqID("3333"); > NewOrderSingle buyorder= getNewOrdersingl(custyID, account, new > String(clientReference.getValue()), 15.0, 928.5, "BUY", "ESZ9 Index", > "200912", "GLBX"); > System.out.println("neworder"); > sent = true; > try{ > Session.sendToTarget(buyorder, session); > System.out.println("neworder"); > } > catch (SessionNotFound e2) { e2.printStackTrace();} > } > > } > > } > > /** Start servicing quotes */ > void start() { > tradingThread = new Thread(this, "FixTrader"); > tradingThread.start(); > } > > /** Stop servicing quotes */ > void stop() { > if (tradingThread != null) { > tradingThread.interrupt(); > } > } > > > public NewOrderSingle getNewOrdersingl(String custyID, String account, > String clientReferenceID, double quant, double limit, String side, String > sym, String maturity, String exchange){ > System.out.println("getNewOrdersingleSingle " ); > NewOrderSingle newOrderSingle = new NewOrderSingle(); > System.out.println("getNewOrdersingleSingle2 " ); > newOrderSingle.setField(new ClientID(custyID)); > newOrderSingle.setField(new Account(account)); > newOrderSingle.setField(new ClOrdID(clientReferenceID)); > newOrderSingle.setField(new HandlInst('1')); > newOrderSingle.setField(new OrderQty(quant)); > newOrderSingle.setField(new OrdType('2')); > newOrderSingle.setField(new Price(limit)); > if( side.equals("BUY")) > newOrderSingle.setField(new Side('1')); > else if( side.equals("SELL")) > newOrderSingle.setField(new Side('2')); > else > System.exit(1); > > newOrderSingle.setField(new Symbol(sym)); > newOrderSingle.setField(new TransactTime()); > newOrderSingle.setField(new SecurityType("FUT")); > newOrderSingle.setField(new MaturityMonthYear(maturity)); > newOrderSingle.setField(new SecurityExchange(exchange)); > > return newOrderSingle; > } > > } > > > public class FixInit {//implements Runnable{ > > static String CONFIGURATION_DEFAULT_NAME = "fix.cfg" ; > static String FileName; > static SessionSettings settings1; > > > private static FixApp application; > private SocketInitiator socketinit; > > public static void main(String[] args)throws Exception{ > > InputStream inputStream; > > FileName = CONFIGURATION_DEFAULT_NAME; > > System.out.println("Program start"); > > System.out.println("connection started"); > SessionSettings settings = new SessionSettings(FileName); > application = new FixApp(settings); > FileStoreFactory storeFactory = new FileStoreFactory(settings); > LogFactory logFactory = new FileLogFactory(settings); > MessageFactory messageFactory = new MessageFactory(); > > SocketInitiator init = new SocketInitiator(application, storeFactory, > settings, logFactory, messageFactory); > > > init.start(); > > while(true){} > } > } > > > > public class FixApp extends MessageCracker implements Application > { > private FixTrader fixTrader; > ExecutorService threadExecutor; > > private int expected; > > public FixApp(SessionSettings s) > { > > } > public void onCreate(SessionID session) > { > System.out.println("on create: "); > } > > public void onLogon(SessionID session) > { > fixTrader = new FixTrader(session); > System.out.println("on logon: "); > > > System.out.println("*** Threading started ***"); > threadExecutor = Executors.newFixedThreadPool(1); > threadExecutor.execute(fixTrader); > } > > public void onLogout(SessionID session) > { > threadExecutor.shutdown(); > System.out.println("on logout: "); > } > > public void toAdmin(Message message, SessionID session) > { > printSeqNum(message); > System.out.println("toAdmin: "+message); > } > public void toApp(Message message, SessionID session) > { > printSeqNum(message); > System.out.println("toApp: " +message); > } > public void fromAdmin(Message message, SessionID session) > { > printSeqNumFrom1(message); > System.out.println("fromAdmin: "+message); > } > > //public void onMessage(Message message, SessionID session) > > public void onMessage( quickfix.fix42.NewOrderSingle message, SessionID > sessionID ) > throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { > > ClOrdID clOrdID = new ClOrdID(); > message.get(clOrdID); > > } > > public void onMessage( quickfix.fix42.OrderCancelRequest message, SessionID > sessionID ) > throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { > > ClOrdID clOrdID = new ClOrdID(); > message.get(clOrdID); > > } > > public void onMessage( quickfix.fix42.ExecutionReport message, SessionID > sessionID ) > throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { > > System.out.println("Execution report"); > } > > public void fromApp(Message message, SessionID session) > throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { > > > System.out.println("fromApp: "+message); > try { > > crack(message,session ); > } catch (UnsupportedMessageType e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (FieldNotFound e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IncorrectTagValue e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > > } > > > > > > Grant Birchmeier wrote: >> >> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >> QuickFIX/J Support: http://www.quickfixj.org/support/ >> >> >> Sending the order is normally fired from some external control. For >> instance, you'd have a GUI that would command the app to fire orders, >> or some other algorithm thread. >> >> For your simple app, you should probably create a separate thread that >> will wait X seconds and send an order. This thread can be created and >> started in our onLogon() function. (Do not put Thread.sleep() in your >> onLogin() or any QFJ callback, as it will block your QFJ from >> receiving further messages until they expire.) >> >> -Grant >> >> >> On Thu, Oct 1, 2009 at 7:24 AM, emreozen <[hidden email]> wrote: >>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>> >>> >>> >>> ok, thanks, I will listen to your advice. >>> >>> I managed to set up the initiator and connect, then my program goes into >>> a >>> while loop. >>> >>> I receive the logon message from the admin and the connection remains >>> alive >>> as I see the heartbeats. >>> >>> Where would be a good place to send an order in the code >>> >>> Should I start the order sending in the Logon function? >>> >>> My code is simple and I am really new to quickfix and Java, I would >>> appreciate help. >>> >>> Thanks >>> >>> >>> ofer yoshiahu wrote: >>>> >>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>> >>>> >>>> >>>> i don't recommend this approach. >>>> i don't know about your errors but you should let quickfixj handle the >>>> sequences for you. >>>> You should use setNextSenderMsgSeqNum only on extreme cases. >>>> >>>> On Wed, Sep 30, 2009 at 11:55 PM, emreozen <[hidden email]> >>>> wrote: >>>> >>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>> QuickFIX/J <http://www.quickfixj.org/documentation/%0AQuickFIX/J> >>>>> Support: >>>>> http://www.quickfixj.org/support/ >>>>> >>>>> >>>>> >>>>> Hi >>>>> >>>>> I am trying to manually set the setNextSenderMsgSeqNum before every >>>>> time >>>>> I >>>>> send out a message. >>>>> >>>>> Is this correct? I am trying to do this to get rid of the errors such >>>>> as >>>>> "Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. >>>>> Expected 72 but message contained 71;" errors. >>>>> >>>>> Also, my Session object doesnt have this function? >>>>> >>>>> I would appreciate any help, >>>>> >>>>> Thanks in advance, >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3745596.html >>>>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>>> is the only developer event you need to attend this year. Jumpstart >>>>> your >>>>> developing skills, take BlackBerry mobile applications to market and >>>>> stay >>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>> now! >>>>> http://p.sf.net/sfu/devconf >>>>> _______________________________________________ >>>>> Quickfixj-users mailing list >>>>> [hidden email] >>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and >>>> stay >>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>> now! >>>> http://p.sf.net/sfu/devconf >>>> _______________________________________________ >>>> Quickfixj-users mailing list >>>> [hidden email] >>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3748684.html >>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9-12, 2009. Register >>> now! >>> http://p.sf.net/sfu/devconf >>> _______________________________________________ >>> Quickfixj-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register >> now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> Quickfixj-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >> >> > > -- > View this message in context: http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3790437.html > Sent from the QuickFIX/J mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Quickfixj-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quickfixj-users > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Quickfixj-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quickfixj-users |
||||||||||||||||
|
emreozen
|
I am building the program which is supposed to send orders and get confirmations. do I need an acceptor for this? I thought acceptor was for the server side, which gets the orders from the client and executes it? Thanks again,
|
||||||||||||||||
|
Grant Birchmeier
|
QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
QuickFIX/J Support: http://www.quickfixj.org/support/ That is what I'm asking. What is your acceptor? Are you communicating with a real exchange or did you build a toy acceptor for testing? (I hope you're not using an untested program to send real orders!) Even if you don't control the Acceptor, I suggest trying those config settings I mentioned. When you're program works without having to deal with seqnos, then you can unset those configs and experiment some more. -Grant On Fri, Oct 9, 2009 at 9:35 AM, emreozen <[hidden email]> wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > > > I am building the program which is supposed to send orders and get > confirmations. > > do I need an acceptor for this? I thought acceptor was for the server side, > which gets the orders from the client and executes it? > > Thanks again, > > > > Grant Birchmeier wrote: >> >> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >> QuickFIX/J Support: http://www.quickfixj.org/support/ >> >> >> Do you create the Acceptor too? >> >> I suggest setting ResetOnLogon=Y and SendResetSeqNumFlag=Y in your >> configuration files for both Acceptor and Initiator. This should >> remove sequence number issues from the equation, as both sides will >> always reset to 0 whenever an initiator logs in. When you get things >> running, you can take these back out and experiment with how QF/J >> works with sequence numbers. >> >> -Grant >> >> >> On Thu, Oct 8, 2009 at 2:50 PM, emreozen <[hidden email]> wrote: >>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>> >>> >>> >>> I have been trying to work this out but still getting the below error >>> message: >>> >>> "Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. >>> Expected 3 but message contained 2" >>> >>> I couldn't figure it out, below is my code, I would appreciate help, I'm >>> really struck at this: >>> >>> >>> public class FixTrader implements Runnable{ >>> private Thread tradingThread; >>> private SessionID session; >>> private boolean sent = false; >>> >>> FixTrader(SessionID s) >>> { >>> session = s; >>> } >>> >>> public void run() >>> { >>> while (!Thread.interrupted()) >>> { >>> System.out.println("Thread started"); >>> >>> try{ >>> >>> Thread.sleep(10000); >>> >>> }catch(InterruptedException e) >>> { e.printStackTrace();} >>> >>> >>> if(!sent) >>> { >>> >>> String custyID = new >>> String("[hidden email]"); >>> String account = new >>> String("TESTACC"); >>> MDReqID clientReference = new >>> MDReqID("3333"); >>> NewOrderSingle buyorder= >>> getNewOrdersingl(custyID, account, new >>> String(clientReference.getValue()), 15.0, 928.5, "BUY", "ESZ9 Index", >>> "200912", "GLBX"); >>> System.out.println("neworder"); >>> sent = true; >>> try{ >>> >>> Session.sendToTarget(buyorder, session); >>> >>> System.out.println("neworder"); >>> } >>> catch (SessionNotFound e2) { >>> e2.printStackTrace();} >>> } >>> >>> } >>> >>> } >>> >>> /** Start servicing quotes */ >>> void start() { >>> tradingThread = new Thread(this, "FixTrader"); >>> tradingThread.start(); >>> } >>> >>> /** Stop servicing quotes */ >>> void stop() { >>> if (tradingThread != null) { >>> tradingThread.interrupt(); >>> } >>> } >>> >>> >>> public NewOrderSingle getNewOrdersingl(String custyID, String >>> account, >>> String clientReferenceID, double quant, double limit, String side, String >>> sym, String maturity, String exchange){ >>> System.out.println("getNewOrdersingleSingle " ); >>> NewOrderSingle newOrderSingle = new NewOrderSingle(); >>> System.out.println("getNewOrdersingleSingle2 " ); >>> newOrderSingle.setField(new ClientID(custyID)); >>> newOrderSingle.setField(new Account(account)); >>> newOrderSingle.setField(new ClOrdID(clientReferenceID)); >>> newOrderSingle.setField(new HandlInst('1')); >>> newOrderSingle.setField(new OrderQty(quant)); >>> newOrderSingle.setField(new OrdType('2')); >>> newOrderSingle.setField(new Price(limit)); >>> if( side.equals("BUY")) >>> newOrderSingle.setField(new Side('1')); >>> else if( side.equals("SELL")) >>> newOrderSingle.setField(new Side('2')); >>> else >>> System.exit(1); >>> >>> newOrderSingle.setField(new Symbol(sym)); >>> newOrderSingle.setField(new TransactTime()); >>> newOrderSingle.setField(new SecurityType("FUT")); >>> newOrderSingle.setField(new MaturityMonthYear(maturity)); >>> newOrderSingle.setField(new SecurityExchange(exchange)); >>> >>> return newOrderSingle; >>> } >>> >>> } >>> >>> >>> public class FixInit {//implements Runnable{ >>> >>> static String CONFIGURATION_DEFAULT_NAME = "fix.cfg" ; >>> static String FileName; >>> static SessionSettings settings1; >>> >>> >>> private static FixApp application; >>> private SocketInitiator socketinit; >>> >>> public static void main(String[] args)throws Exception{ >>> >>> InputStream inputStream; >>> >>> FileName = CONFIGURATION_DEFAULT_NAME; >>> >>> System.out.println("Program start"); >>> >>> System.out.println("connection started"); >>> SessionSettings settings = new SessionSettings(FileName); >>> application = new FixApp(settings); >>> FileStoreFactory storeFactory = new >>> FileStoreFactory(settings); >>> LogFactory logFactory = new FileLogFactory(settings); >>> MessageFactory messageFactory = new MessageFactory(); >>> >>> SocketInitiator init = new SocketInitiator(application, >>> storeFactory, >>> settings, logFactory, messageFactory); >>> >>> >>> init.start(); >>> >>> while(true){} >>> } >>> } >>> >>> >>> >>> public class FixApp extends MessageCracker implements Application >>> { >>> private FixTrader fixTrader; >>> ExecutorService threadExecutor; >>> >>> private int expected; >>> >>> public FixApp(SessionSettings s) >>> { >>> >>> } >>> public void onCreate(SessionID session) >>> { >>> System.out.println("on create: "); >>> } >>> >>> public void onLogon(SessionID session) >>> { >>> fixTrader = new FixTrader(session); >>> System.out.println("on logon: "); >>> >>> >>> System.out.println("*** Threading started ***"); >>> threadExecutor = Executors.newFixedThreadPool(1); >>> threadExecutor.execute(fixTrader); >>> } >>> >>> public void onLogout(SessionID session) >>> { >>> threadExecutor.shutdown(); >>> System.out.println("on logout: "); >>> } >>> >>> public void toAdmin(Message message, SessionID session) >>> { >>> printSeqNum(message); >>> System.out.println("toAdmin: "+message); >>> } >>> public void toApp(Message message, SessionID session) >>> { >>> printSeqNum(message); >>> System.out.println("toApp: " +message); >>> } >>> public void fromAdmin(Message message, SessionID session) >>> { >>> printSeqNumFrom1(message); >>> System.out.println("fromAdmin: "+message); >>> } >>> >>> //public void onMessage(Message message, SessionID session) >>> >>> public void onMessage( quickfix.fix42.NewOrderSingle message, >>> SessionID >>> sessionID ) >>> throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue >>> { >>> >>> ClOrdID clOrdID = new ClOrdID(); >>> message.get(clOrdID); >>> >>> } >>> >>> public void onMessage( quickfix.fix42.OrderCancelRequest message, >>> SessionID >>> sessionID ) >>> throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue >>> { >>> >>> ClOrdID clOrdID = new ClOrdID(); >>> message.get(clOrdID); >>> >>> } >>> >>> public void onMessage( quickfix.fix42.ExecutionReport message, >>> SessionID >>> sessionID ) >>> throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue >>> { >>> >>> System.out.println("Execution report"); >>> } >>> >>> public void fromApp(Message message, SessionID session) >>> throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue >>> { >>> >>> >>> System.out.println("fromApp: "+message); >>> try { >>> >>> crack(message,session ); >>> } catch (UnsupportedMessageType e) { >>> // TODO Auto-generated catch block >>> e.printStackTrace(); >>> } catch (FieldNotFound e) { >>> // TODO Auto-generated catch block >>> e.printStackTrace(); >>> } catch (IncorrectTagValue e) { >>> // TODO Auto-generated catch block >>> e.printStackTrace(); >>> } >>> } >>> >>> } >>> >>> >>> >>> >>> >>> Grant Birchmeier wrote: >>>> >>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>> >>>> >>>> Sending the order is normally fired from some external control. For >>>> instance, you'd have a GUI that would command the app to fire orders, >>>> or some other algorithm thread. >>>> >>>> For your simple app, you should probably create a separate thread that >>>> will wait X seconds and send an order. This thread can be created and >>>> started in our onLogon() function. (Do not put Thread.sleep() in your >>>> onLogin() or any QFJ callback, as it will block your QFJ from >>>> receiving further messages until they expire.) >>>> >>>> -Grant >>>> >>>> >>>> On Thu, Oct 1, 2009 at 7:24 AM, emreozen <[hidden email]> wrote: >>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>>> >>>>> >>>>> >>>>> ok, thanks, I will listen to your advice. >>>>> >>>>> I managed to set up the initiator and connect, then my program goes >>>>> into >>>>> a >>>>> while loop. >>>>> >>>>> I receive the logon message from the admin and the connection remains >>>>> alive >>>>> as I see the heartbeats. >>>>> >>>>> Where would be a good place to send an order in the code >>>>> >>>>> Should I start the order sending in the Logon function? >>>>> >>>>> My code is simple and I am really new to quickfix and Java, I would >>>>> appreciate help. >>>>> >>>>> Thanks >>>>> >>>>> >>>>> ofer yoshiahu wrote: >>>>>> >>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>>>> >>>>>> >>>>>> >>>>>> i don't recommend this approach. >>>>>> i don't know about your errors but you should let quickfixj handle the >>>>>> sequences for you. >>>>>> You should use setNextSenderMsgSeqNum only on extreme cases. >>>>>> >>>>>> On Wed, Sep 30, 2009 at 11:55 PM, emreozen <[hidden email]> >>>>>> wrote: >>>>>> >>>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>>>> QuickFIX/J <http://www.quickfixj.org/documentation/%0AQuickFIX/J> >>>>>>> Support: >>>>>>> http://www.quickfixj.org/support/ >>>>>>> >>>>>>> >>>>>>> >>>>>>> Hi >>>>>>> >>>>>>> I am trying to manually set the setNextSenderMsgSeqNum before every >>>>>>> time >>>>>>> I >>>>>>> send out a message. >>>>>>> >>>>>>> Is this correct? I am trying to do this to get rid of the errors such >>>>>>> as >>>>>>> "Validation error: Protocol/Session Validation: MsgSeqNum is >>>>>>> incorrect. >>>>>>> Expected 72 but message contained 71;" errors. >>>>>>> >>>>>>> Also, my Session object doesnt have this function? >>>>>>> >>>>>>> I would appreciate any help, >>>>>>> >>>>>>> Thanks in advance, >>>>>>> >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3745596.html >>>>>>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> Come build with us! The BlackBerry® Developer Conference in SF, >>>>>>> CA >>>>>>> is the only developer event you need to attend this year. Jumpstart >>>>>>> your >>>>>>> developing skills, take BlackBerry mobile applications to market and >>>>>>> stay >>>>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>>>> now! >>>>>>> http://p.sf.net/sfu/devconf >>>>>>> _______________________________________________ >>>>>>> Quickfixj-users mailing list >>>>>>> [hidden email] >>>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>>>> is the only developer event you need to attend this year. Jumpstart >>>>>> your >>>>>> developing skills, take BlackBerry mobile applications to market and >>>>>> stay >>>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>>> now! >>>>>> http://p.sf.net/sfu/devconf >>>>>> _______________________________________________ >>>>>> Quickfixj-users mailing list >>>>>> [hidden email] >>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>>> >>>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3748684.html >>>>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>>> is the only developer event you need to attend this year. Jumpstart >>>>> your >>>>> developing skills, take BlackBerry mobile applications to market and >>>>> stay >>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>> now! >>>>> http://p.sf.net/sfu/devconf >>>>> _______________________________________________ >>>>> Quickfixj-users mailing list >>>>> [hidden email] >>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and >>>> stay >>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>> now! >>>> http://p.sf.net/sfu/devconf >>>> _______________________________________________ >>>> Quickfixj-users mailing list >>>> [hidden email] >>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3790437.html >>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>> http://p.sf.net/sfu/devconference >>> _______________________________________________ >>> Quickfixj-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Quickfixj-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >> >> > > -- > View this message in context: http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3794976.html > Sent from the QuickFIX/J mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Quickfixj-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quickfixj-users > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Quickfixj-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quickfixj-users |
||||||||||||||||
|
emreozen
|
Oh, my acceptor is a test server which has test scenarios. So in this one, I am supposed to login, which I can, and send an order. What the program does is, it launches another thread in onLogon which waits for 10 seconds and then sends an order.
|
||||||||||||||||
|
Grant Birchmeier
|
QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
QuickFIX/J Support: http://www.quickfixj.org/support/ Did you try ResetOnLogon=Y and SendResetSeqNumFlag=Y in your initiator config? (There's a chance your Acceptor may not support it, but you should try it.) The Acceptor and Initiator maintain sequence numbers from each other. If the Initiator just sent a message with seqno=4, then the Acceptor expects the message after that to have seqno=5. The Initiator expects likewise from the Acceptor. If the Initiator goes down for some reason, then upon reconnect, they will use the seqnos to sync up again. If the Initiator sees that the Acceptor's seqno is too high, then it knows it missed messages, and it will automatically ask the Acceptor to resend everything that was missed (aka it will "gap fill" the missed messages). If your seqno is too low, that's an error, and shouldn't be possible. You can't go backward. If you set ResetOnLogon=Y and SendResetSeqNumFlag=Y, then both sides will start at 0 and sidestep this concern. When developing without these options, you must make sure that you do not have two progs the same sessionID (FIXversion/senderid/targetid tuple). If you do, and you switch back-and-forth, the two programs will screw up each others seqnos. So, if your test server's acceptor supports reset-on-logon, you should set these options before doing any further development. -Grant On Fri, Oct 9, 2009 at 10:56 AM, emreozen <[hidden email]> wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > > > Oh, my acceptor is a test server which has test scenarios. > > So in this one, I am supposed to login, which I can, and send an order. > > What the program does is, it launches another thread in onLogon which waits > for 10 seconds and then sends an order. > > > Grant Birchmeier wrote: >> >> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >> QuickFIX/J Support: http://www.quickfixj.org/support/ >> >> >> That is what I'm asking. What is your acceptor? >> >> Are you communicating with a real exchange or did you build a toy >> acceptor for testing? (I hope you're not using an untested program to >> send real orders!) >> >> Even if you don't control the Acceptor, I suggest trying those config >> settings I mentioned. When you're program works without having to >> deal with seqnos, then you can unset those configs and experiment some >> more. >> >> -Grant >> >> >> On Fri, Oct 9, 2009 at 9:35 AM, emreozen <[hidden email]> wrote: >>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>> >>> >>> >>> >>> I am building the program which is supposed to send orders and get >>> confirmations. >>> >>> do I need an acceptor for this? I thought acceptor was for the server >>> side, >>> which gets the orders from the client and executes it? >>> >>> Thanks again, >>> >>> >>> >>> Grant Birchmeier wrote: >>>> >>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>> >>>> >>>> Do you create the Acceptor too? >>>> >>>> I suggest setting ResetOnLogon=Y and SendResetSeqNumFlag=Y in your >>>> configuration files for both Acceptor and Initiator. This should >>>> remove sequence number issues from the equation, as both sides will >>>> always reset to 0 whenever an initiator logs in. When you get things >>>> running, you can take these back out and experiment with how QF/J >>>> works with sequence numbers. >>>> >>>> -Grant >>>> >>>> >>>> On Thu, Oct 8, 2009 at 2:50 PM, emreozen <[hidden email]> wrote: >>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>>> >>>>> >>>>> >>>>> I have been trying to work this out but still getting the below error >>>>> message: >>>>> >>>>> "Validation error: Protocol/Session Validation: MsgSeqNum is incorrect. >>>>> Expected 3 but message contained 2" >>>>> >>>>> I couldn't figure it out, below is my code, I would appreciate help, >>>>> I'm >>>>> really struck at this: >>>>> >>>>> >>>>> public class FixTrader implements Runnable{ >>>>> private Thread tradingThread; >>>>> private SessionID session; >>>>> private boolean sent = false; >>>>> >>>>> FixTrader(SessionID s) >>>>> { >>>>> session = s; >>>>> } >>>>> >>>>> public void run() >>>>> { >>>>> while (!Thread.interrupted()) >>>>> { >>>>> System.out.println("Thread started"); >>>>> >>>>> try{ >>>>> >>>>> Thread.sleep(10000); >>>>> >>>>> }catch(InterruptedException e) >>>>> { e.printStackTrace();} >>>>> >>>>> >>>>> if(!sent) >>>>> { >>>>> >>>>> String custyID = new >>>>> String("[hidden email]"); >>>>> String account = new >>>>> String("TESTACC"); >>>>> MDReqID clientReference = new >>>>> MDReqID("3333"); >>>>> NewOrderSingle buyorder= >>>>> getNewOrdersingl(custyID, account, new >>>>> String(clientReference.getValue()), 15.0, 928.5, "BUY", "ESZ9 Index", >>>>> "200912", "GLBX"); >>>>> System.out.println("neworder"); >>>>> sent = true; >>>>> try{ >>>>> >>>>> Session.sendToTarget(buyorder, session); >>>>> >>>>> System.out.println("neworder"); >>>>> } >>>>> catch (SessionNotFound e2) { >>>>> e2.printStackTrace();} >>>>> } >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> /** Start servicing quotes */ >>>>> void start() { >>>>> tradingThread = new Thread(this, "FixTrader"); >>>>> tradingThread.start(); >>>>> } >>>>> >>>>> /** Stop servicing quotes */ >>>>> void stop() { >>>>> if (tradingThread != null) { >>>>> tradingThread.interrupt(); >>>>> } >>>>> } >>>>> >>>>> >>>>> public NewOrderSingle getNewOrdersingl(String custyID, String >>>>> account, >>>>> String clientReferenceID, double quant, double limit, String side, >>>>> String >>>>> sym, String maturity, String exchange){ >>>>> System.out.println("getNewOrdersingleSingle " ); >>>>> NewOrderSingle newOrderSingle = new NewOrderSingle(); >>>>> System.out.println("getNewOrdersingleSingle2 " ); >>>>> newOrderSingle.setField(new ClientID(custyID)); >>>>> newOrderSingle.setField(new Account(account)); >>>>> newOrderSingle.setField(new ClOrdID(clientReferenceID)); >>>>> newOrderSingle.setField(new HandlInst('1')); >>>>> newOrderSingle.setField(new OrderQty(quant)); >>>>> newOrderSingle.setField(new OrdType('2')); >>>>> newOrderSingle.setField(new Price(limit)); >>>>> if( side.equals("BUY")) >>>>> newOrderSingle.setField(new Side('1')); >>>>> else if( side.equals("SELL")) >>>>> newOrderSingle.setField(new Side('2')); >>>>> else >>>>> System.exit(1); >>>>> >>>>> newOrderSingle.setField(new Symbol(sym)); >>>>> newOrderSingle.setField(new TransactTime()); >>>>> newOrderSingle.setField(new SecurityType("FUT")); >>>>> newOrderSingle.setField(new >>>>> MaturityMonthYear(maturity)); >>>>> newOrderSingle.setField(new SecurityExchange(exchange)); >>>>> >>>>> return newOrderSingle; >>>>> } >>>>> >>>>> } >>>>> >>>>> >>>>> public class FixInit {//implements Runnable{ >>>>> >>>>> static String CONFIGURATION_DEFAULT_NAME = "fix.cfg" ; >>>>> static String FileName; >>>>> static SessionSettings settings1; >>>>> >>>>> >>>>> private static FixApp application; >>>>> private SocketInitiator socketinit; >>>>> >>>>> public static void main(String[] args)throws Exception{ >>>>> >>>>> InputStream inputStream; >>>>> >>>>> FileName = CONFIGURATION_DEFAULT_NAME; >>>>> >>>>> System.out.println("Program start"); >>>>> >>>>> System.out.println("connection started"); >>>>> SessionSettings settings = new >>>>> SessionSettings(FileName); >>>>> application = new FixApp(settings); >>>>> FileStoreFactory storeFactory = new >>>>> FileStoreFactory(settings); >>>>> LogFactory logFactory = new FileLogFactory(settings); >>>>> MessageFactory messageFactory = new MessageFactory(); >>>>> >>>>> SocketInitiator init = new SocketInitiator(application, >>>>> storeFactory, >>>>> settings, logFactory, messageFactory); >>>>> >>>>> >>>>> init.start(); >>>>> >>>>> while(true){} >>>>> } >>>>> } >>>>> >>>>> >>>>> >>>>> public class FixApp extends MessageCracker implements Application >>>>> { >>>>> private FixTrader fixTrader; >>>>> ExecutorService threadExecutor; >>>>> >>>>> private int expected; >>>>> >>>>> public FixApp(SessionSettings s) >>>>> { >>>>> >>>>> } >>>>> public void onCreate(SessionID session) >>>>> { >>>>> System.out.println("on create: "); >>>>> } >>>>> >>>>> public void onLogon(SessionID session) >>>>> { >>>>> fixTrader = new FixTrader(session); >>>>> System.out.println("on logon: "); >>>>> >>>>> >>>>> System.out.println("*** Threading started ***"); >>>>> threadExecutor = Executors.newFixedThreadPool(1); >>>>> threadExecutor.execute(fixTrader); >>>>> } >>>>> >>>>> public void onLogout(SessionID session) >>>>> { >>>>> threadExecutor.shutdown(); >>>>> System.out.println("on logout: "); >>>>> } >>>>> >>>>> public void toAdmin(Message message, SessionID session) >>>>> { >>>>> printSeqNum(message); >>>>> System.out.println("toAdmin: "+message); >>>>> } >>>>> public void toApp(Message message, SessionID session) >>>>> { >>>>> printSeqNum(message); >>>>> System.out.println("toApp: " +message); >>>>> } >>>>> public void fromAdmin(Message message, SessionID session) >>>>> { >>>>> printSeqNumFrom1(message); >>>>> System.out.println("fromAdmin: "+message); >>>>> } >>>>> >>>>> //public void onMessage(Message message, SessionID session) >>>>> >>>>> public void onMessage( quickfix.fix42.NewOrderSingle message, >>>>> SessionID >>>>> sessionID ) >>>>> throws FieldNotFound, UnsupportedMessageType, >>>>> IncorrectTagValue >>>>> { >>>>> >>>>> ClOrdID clOrdID = new ClOrdID(); >>>>> message.get(clOrdID); >>>>> >>>>> } >>>>> >>>>> public void onMessage( quickfix.fix42.OrderCancelRequest >>>>> message, >>>>> SessionID >>>>> sessionID ) >>>>> throws FieldNotFound, UnsupportedMessageType, >>>>> IncorrectTagValue >>>>> { >>>>> >>>>> ClOrdID clOrdID = new ClOrdID(); >>>>> message.get(clOrdID); >>>>> >>>>> } >>>>> >>>>> public void onMessage( quickfix.fix42.ExecutionReport message, >>>>> SessionID >>>>> sessionID ) >>>>> throws FieldNotFound, UnsupportedMessageType, >>>>> IncorrectTagValue >>>>> { >>>>> >>>>> System.out.println("Execution report"); >>>>> } >>>>> >>>>> public void fromApp(Message message, SessionID session) >>>>> throws FieldNotFound, UnsupportedMessageType, >>>>> IncorrectTagValue >>>>> { >>>>> >>>>> >>>>> System.out.println("fromApp: "+message); >>>>> try { >>>>> >>>>> crack(message,session ); >>>>> } catch (UnsupportedMessageType e) { >>>>> // TODO Auto-generated catch block >>>>> e.printStackTrace(); >>>>> } catch (FieldNotFound e) { >>>>> // TODO Auto-generated catch block >>>>> e.printStackTrace(); >>>>> } catch (IncorrectTagValue e) { >>>>> // TODO Auto-generated catch block >>>>> e.printStackTrace(); >>>>> } >>>>> } >>>>> >>>>> } >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Grant Birchmeier wrote: >>>>>> >>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>>>> >>>>>> >>>>>> Sending the order is normally fired from some external control. For >>>>>> instance, you'd have a GUI that would command the app to fire orders, >>>>>> or some other algorithm thread. >>>>>> >>>>>> For your simple app, you should probably create a separate thread that >>>>>> will wait X seconds and send an order. This thread can be created and >>>>>> started in our onLogon() function. (Do not put Thread.sleep() in your >>>>>> onLogin() or any QFJ callback, as it will block your QFJ from >>>>>> receiving further messages until they expire.) >>>>>> >>>>>> -Grant >>>>>> >>>>>> >>>>>> On Thu, Oct 1, 2009 at 7:24 AM, emreozen <[hidden email]> >>>>>> wrote: >>>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>>>>> >>>>>>> >>>>>>> >>>>>>> ok, thanks, I will listen to your advice. >>>>>>> >>>>>>> I managed to set up the initiator and connect, then my program goes >>>>>>> into >>>>>>> a >>>>>>> while loop. >>>>>>> >>>>>>> I receive the logon message from the admin and the connection remains >>>>>>> alive >>>>>>> as I see the heartbeats. >>>>>>> >>>>>>> Where would be a good place to send an order in the code >>>>>>> >>>>>>> Should I start the order sending in the Logon function? >>>>>>> >>>>>>> My code is simple and I am really new to quickfix and Java, I would >>>>>>> appreciate help. >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> >>>>>>> ofer yoshiahu wrote: >>>>>>>> >>>>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>>>>> QuickFIX/J Support: http://www.quickfixj.org/support/ >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> i don't recommend this approach. >>>>>>>> i don't know about your errors but you should let quickfixj handle >>>>>>>> the >>>>>>>> sequences for you. >>>>>>>> You should use setNextSenderMsgSeqNum only on extreme cases. >>>>>>>> >>>>>>>> On Wed, Sep 30, 2009 at 11:55 PM, emreozen <[hidden email]> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ >>>>>>>>> QuickFIX/J <http://www.quickfixj.org/documentation/%0AQuickFIX/J> >>>>>>>>> Support: >>>>>>>>> http://www.quickfixj.org/support/ >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Hi >>>>>>>>> >>>>>>>>> I am trying to manually set the setNextSenderMsgSeqNum before every >>>>>>>>> time >>>>>>>>> I >>>>>>>>> send out a message. >>>>>>>>> >>>>>>>>> Is this correct? I am trying to do this to get rid of the errors >>>>>>>>> such >>>>>>>>> as >>>>>>>>> "Validation error: Protocol/Session Validation: MsgSeqNum is >>>>>>>>> incorrect. >>>>>>>>> Expected 72 but message contained 71;" errors. >>>>>>>>> >>>>>>>>> Also, my Session object doesnt have this function? >>>>>>>>> >>>>>>>>> I would appreciate any help, >>>>>>>>> >>>>>>>>> Thanks in advance, >>>>>>>>> >>>>>>>>> -- >>>>>>>>> View this message in context: >>>>>>>>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3745596.html >>>>>>>>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>>>>>>>> >>>>>>>>> >>>>>>>>> ------------------------------------------------------------------------------ >>>>>>>>> Come build with us! The BlackBerry® Developer Conference in SF, >>>>>>>>> CA >>>>>>>>> is the only developer event you need to attend this year. Jumpstart >>>>>>>>> your >>>>>>>>> developing skills, take BlackBerry mobile applications to market >>>>>>>>> and >>>>>>>>> stay >>>>>>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>>>>>> now! >>>>>>>>> http://p.sf.net/sfu/devconf >>>>>>>>> _______________________________________________ >>>>>>>>> Quickfixj-users mailing list >>>>>>>>> [hidden email] >>>>>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>>>>>> >>>>>>>> >>>>>>>> ------------------------------------------------------------------------------ >>>>>>>> Come build with us! The BlackBerry® Developer Conference in SF, >>>>>>>> CA >>>>>>>> is the only developer event you need to attend this year. Jumpstart >>>>>>>> your >>>>>>>> developing skills, take BlackBerry mobile applications to market and >>>>>>>> stay >>>>>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>>>>> now! >>>>>>>> http://p.sf.net/sfu/devconf >>>>>>>> _______________________________________________ >>>>>>>> Quickfixj-users mailing list >>>>>>>> [hidden email] >>>>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3748684.html >>>>>>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> Come build with us! The BlackBerry® Developer Conference in SF, >>>>>>> CA >>>>>>> is the only developer event you need to attend this year. Jumpstart >>>>>>> your >>>>>>> developing skills, take BlackBerry mobile applications to market and >>>>>>> stay >>>>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>>>> now! >>>>>>> http://p.sf.net/sfu/devconf >>>>>>> _______________________________________________ >>>>>>> Quickfixj-users mailing list >>>>>>> [hidden email] >>>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>>>> is the only developer event you need to attend this year. Jumpstart >>>>>> your >>>>>> developing skills, take BlackBerry mobile applications to market and >>>>>> stay >>>>>> ahead of the curve. Join us from November 9-12, 2009. Register >>>>>> now! >>>>>> http://p.sf.net/sfu/devconf >>>>>> _______________________________________________ >>>>>> Quickfixj-users mailing list >>>>>> [hidden email] >>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>>> >>>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3790437.html >>>>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>>>> is the only developer event you need to attend this year. Jumpstart >>>>> your >>>>> developing skills, take BlackBerry mobile applications to market and >>>>> stay >>>>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>>>> http://p.sf.net/sfu/devconference >>>>> _______________________________________________ >>>>> Quickfixj-users mailing list >>>>> [hidden email] >>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and >>>> stay >>>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>>> http://p.sf.net/sfu/devconference >>>> _______________________________________________ >>>> Quickfixj-users mailing list >>>> [hidden email] >>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3794976.html >>> Sent from the QuickFIX/J mailing list archive at Nabble.com. >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>> http://p.sf.net/sfu/devconference >>> _______________________________________________ >>> Quickfixj-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Quickfixj-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quickfixj-users >> >> > > -- > View this message in context: http://n2.nabble.com/Session-setNextSenderMsgSeqNum-tp3745596p3795567.html > Sent from the QuickFIX/J mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Quickfixj-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quickfixj-users > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Quickfixj-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quickfixj-users |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |