Re: [Quickfix-developers] Python - AttributeErrorName : SessionID
Brought to you by:
orenmnero
From: Grant B. <gbi...@co...> - 2015-11-24 17:41:00
|
What's your stacktrace? On Tue, Nov 24, 2015 at 11:29 AM, Artur Silva <art...@gm...> 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 > Qui...@li... > 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. http://connamara.com |