Python - AttributeErrorName : SessionID

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Python - AttributeErrorName : SessionID

Artur Silva
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/



I'm new to FIX and I have been working with QuickFix on Python and I'm getting an error "AttribueErrorName:SessionID". 

I'm using pretty simple code but I'm not being able to succesfully debug the issue. My code follows below , thanks in advance for your help.

initiator :

import sys

import time

import thread

import argparse

from datetime import datetime

import quickfix as fix



class Application(fix.Application):

   orderID = 0

   execID = 0

   def gen_ord_id(self):

       global orderID

       orderID+=1

       return orderID





   def onCreate(self, sessionID):

           return

   def onLogon(self, sessionID):

           self.sessionID = sessionID

           print ("Successful Logon to session '%s'." % sessionID.toString())

           return



   def onLogout(self, sessionID): return



   def toAdmin(self, sessionID, message):

       return



   def fromAdmin(self, sessionID, message):

       return





   def toApp(self, sessionID, message):

       print "Sent the following message: %s" % message.toString()

       return



   def fromApp(self, message, sessionID):

       print "Received the following message: %s" % message.toString()

       return



   def genOrderID(self):

       self.orderID = self.orderID+1

       return `self.orderID`



   def genExecID(self):

       self.execID = self.execID+1

       return `self.execID`

   def put_order(self):

       print("Creating the following order: ")

       trade = fix.Message()

       trade.getHeader().setField(fix.BeginString(fix.BeginString_FIX50)) #

       trade.getHeader().setField(fix.MsgType(fix.MsgType_NewOrderSingle)) #39=D

       trade.setField(fix.ClOrdID(self.genExecID())) #11=Unique order



       trade.setField(fix.HandlInst(fix.HandlInst_MANUAL_ORDER_BEST_EXECUTION)) #21=3 (Manual order, best executiona)

       trade.setField(fix.Symbol('SMBL')) #55=SMBL ?

       trade.setField(fix.Side(fix.Side_BUY)) #43=1 Buy

       trade.setField(fix.OrdType(fix.OrdType_LIMIT)) #40=2 Limit order

       trade.setField(fix.OrderQty(100)) #38=100

       trade.setField(fix.Price(10))

       print trade.toString()

       fix.Session.sendToTarget(trade, self.sessionID)





def main(config_file):

   try:

       settings = fix.SessionSettings("initiatorsettings.cfg")

       application = Application()

       storeFactory = fix.FileStoreFactory(settings)

       logFactory = fix.FileLogFactory(settings)

       initiator = fix.SocketInitiator(application, storeFactory, settings, logFactory)

       initiator.start()



       while 1:

               input = raw_input()

               if input == '1':

                   print "Putin Order"

                   application.put_order()

               if input == '2':

                   sys.exit(0)

               if input == 'd':

                   import pdb

                   pdb.set_trace()

               else:

                   print "Valid input is 1 for order, 2 for exit"

                   continue

   except (fix.ConfigError, fix.RuntimeError), e:

       print e



if __name__=='__main__':

   parser = argparse.ArgumentParser(description='FIX Client')

   parser.add_argument('file_name', type=str, help='Name of configuration file')

   args = parser.parse_args()

   main(args.file_name)

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Quickfix-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quickfix-developers
Reply | Threaded
Open this post in threaded view
|

Re: Python - AttributeErrorName : SessionID

Grant Birchmeier
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/


What's your stacktrace?

On Tue, Nov 24, 2015 at 11:29 AM, Artur Silva <[hidden email]> wrote:
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/



I'm new to FIX and I have been working with QuickFix on Python and I'm getting an error "AttribueErrorName:SessionID". 

I'm using pretty simple code but I'm not being able to succesfully debug the issue. My code follows below , thanks in advance for your help.

initiator :

import sys

import time

import thread

import argparse

from datetime import datetime

import quickfix as fix



class Application(fix.Application):

   orderID = 0

   execID = 0

   def gen_ord_id(self):

       global orderID

       orderID+=1

       return orderID





   def onCreate(self, sessionID):

           return

   def onLogon(self, sessionID):

           self.sessionID = sessionID

           print ("Successful Logon to session '%s'." % sessionID.toString())

           return



   def onLogout(self, sessionID): return



   def toAdmin(self, sessionID, message):

       return



   def fromAdmin(self, sessionID, message):

       return





   def toApp(self, sessionID, message):

       print "Sent the following message: %s" % message.toString()

       return



   def fromApp(self, message, sessionID):

       print "Received the following message: %s" % message.toString()

       return



   def genOrderID(self):

       self.orderID = self.orderID+1

       return `self.orderID`



   def genExecID(self):

       self.execID = self.execID+1

       return `self.execID`

   def put_order(self):

       print("Creating the following order: ")

       trade = fix.Message()

       trade.getHeader().setField(fix.BeginString(fix.BeginString_FIX50)) #

       trade.getHeader().setField(fix.MsgType(fix.MsgType_NewOrderSingle)) #39=D

       trade.setField(fix.ClOrdID(self.genExecID())) #11=Unique order



       trade.setField(fix.HandlInst(fix.HandlInst_MANUAL_ORDER_BEST_EXECUTION)) #21=3 (Manual order, best executiona)

       trade.setField(fix.Symbol('SMBL')) #55=SMBL ?

       trade.setField(fix.Side(fix.Side_BUY)) #43=1 Buy

       trade.setField(fix.OrdType(fix.OrdType_LIMIT)) #40=2 Limit order

       trade.setField(fix.OrderQty(100)) #38=100

       trade.setField(fix.Price(10))

       print trade.toString()

       fix.Session.sendToTarget(trade, self.sessionID)





def main(config_file):

   try:

       settings = fix.SessionSettings("initiatorsettings.cfg")

       application = Application()

       storeFactory = fix.FileStoreFactory(settings)

       logFactory = fix.FileLogFactory(settings)

       initiator = fix.SocketInitiator(application, storeFactory, settings, logFactory)

       initiator.start()



       while 1:

               input = raw_input()

               if input == '1':

                   print "Putin Order"

                   application.put_order()

               if input == '2':

                   sys.exit(0)

               if input == 'd':

                   import pdb

                   pdb.set_trace()

               else:

                   print "Valid input is 1 for order, 2 for exit"

                   continue

   except (fix.ConfigError, fix.RuntimeError), e:

       print e



if __name__=='__main__':

   parser = argparse.ArgumentParser(description='FIX Client')

   parser.add_argument('file_name', type=str, help='Name of configuration file')

   args = parser.parse_args()

   main(args.file_name)

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Quickfix-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quickfix-developers



--
Grant Birchmeier
Connamara Systems, LLC
Made-To-Measure Trading Solutions.
Exactly what you need. No more. No less.

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Quickfix-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quickfix-developers
Reply | Threaded
Open this post in threaded view
|

Re: Python - AttributeErrorName : SessionID

Artur Silva
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/


Hey,

Here follows the stacktrace :

Traceback (most recent call last):

 File "initiator.py", line 97, in main

   application.put_order()

 File "initiator.py", line 80, in put_order

   fix.Session.sendToTarget(trade, self.sessionID)

 File "C:\Users\gribeiro\Anaconda\lib\site-packages\quickfix.py", line 30939, in <lambda>

   __getattr__ = lambda self, name: _swig_getattr(self, Application, name)

 File "C:\Users\gribeiro\Anaconda\lib\site-packages\quickfix.py", line 57, in _swig_getattr

   raise AttributeError(name)

AttributeError: sessionID

On Nov 24 2015, at 5:40 pm, Grant Birchmeier <[hidden email]> wrote:
What's your stacktrace?

On Tue, Nov 24, 2015 at 11:29 AM, Artur Silva <[hidden email]> wrote:
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/



I'm new to FIX and I have been working with QuickFix on Python and I'm getting an error "AttribueErrorName:SessionID". 

I'm using pretty simple code but I'm not being able to succesfully debug the issue. My code follows below , thanks in advance for your help.

initiator :

import sys

import time

import thread

import argparse

from datetime import datetime

import quickfix as fix



class Application(fix.Application):

   orderID = 0

   execID = 0

   def gen_ord_id(self):

       global orderID

       orderID+=1

       return orderID





   def onCreate(self, sessionID):

           return

   def onLogon(self, sessionID):

           self.sessionID = sessionID

           print ("Successful Logon to session '%s'." % sessionID.toString())

           return



   def onLogout(self, sessionID): return



   def toAdmin(self, sessionID, message):

       return



   def fromAdmin(self, sessionID, message):

       return





   def toApp(self, sessionID, message):

       print "Sent the following message: %s" % message.toString()

       return



   def fromApp(self, message, sessionID):

       print "Received the following message: %s" % message.toString()

       return



   def genOrderID(self):

       self.orderID = self.orderID+1

       return `self.orderID`



   def genExecID(self):

       self.execID = self.execID+1

       return `self.execID`

   def put_order(self):

       print("Creating the following order: ")

       trade = fix.Message()

       trade.getHeader().setField(fix.BeginString(fix.BeginString_FIX50)) #

       trade.getHeader().setField(fix.MsgType(fix.MsgType_NewOrderSingle)) #39=D

       trade.setField(fix.ClOrdID(self.genExecID())) #11=Unique order



       trade.setField(fix.HandlInst(fix.HandlInst_MANUAL_ORDER_BEST_EXECUTION)) #21=3 (Manual order, best executiona)

       trade.setField(fix.Symbol('SMBL')) #55=SMBL ?

       trade.setField(fix.Side(fix.Side_BUY)) #43=1 Buy

       trade.setField(fix.OrdType(fix.OrdType_LIMIT)) #40=2 Limit order

       trade.setField(fix.OrderQty(100)) #38=100

       trade.setField(fix.Price(10))

       print trade.toString()

       fix.Session.sendToTarget(trade, self.sessionID)





def main(config_file):

   try:

       settings = fix.SessionSettings("initiatorsettings.cfg")

       application = Application()

       storeFactory = fix.FileStoreFactory(settings)

       logFactory = fix.FileLogFactory(settings)

       initiator = fix.SocketInitiator(application, storeFactory, settings, logFactory)

       initiator.start()



       while 1:

               input = raw_input()

               if input == '1':

                   print "Putin Order"

                   application.put_order()

               if input == '2':

                   sys.exit(0)

               if input == 'd':

                   import pdb

                   pdb.set_trace()

               else:

                   print "Valid input is 1 for order, 2 for exit"

                   continue

   except (fix.ConfigError, fix.RuntimeError), e:

       print e



if __name__=='__main__':

   parser = argparse.ArgumentParser(description='FIX Client')

   parser.add_argument('file_name', type=str, help='Name of configuration file')

   args = parser.parse_args()

   main(args.file_name)

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Quickfix-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quickfix-developers



--
Grant Birchmeier
Connamara Systems, LLC
Made-To-Measure Trading Solutions.
Exactly what you need. No more. No less.

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Quickfix-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quickfix-developers