Reputation: 807
I am using the python code examples from "http://www.quickfixengine.org" and have a question. I create my application using the code segment shown below
import quickfix
if len(sys.argv) < 2: return
fileName = sys.argv[1]
try:
settings = quickfix.SessionSettings(fileName)
application = quickfix.MyApplication()
storeFactory = quickfix.FileStoreFactory(settings)
logFactory = quickfix.FileLogFactory(settings)
initiator = quickfix.SocketInitiator(application, storeFactory, settings, logFactory)
initiator.start()
# while condition == true: do something
initiator.stop()
except quickfix.ConfigError, e:
print e
The connection is made and I get logged in, and now I want to send a message (an order, for example). The provided code segment for that is:
def sendOrderCancelRequest:
message = quickfix.Message();
header = message.getHeader();
header.setField(...)
*<...build the header and body...>*
message.setField(...)
Session.sendToTarget(message)
My question is about that Session
object. Where/How is that created? Does it get created with something like Session = quickfix.Session()
, or something else that they are not showing? I've tried a few things, but with the dearth of documentation its just trial and error...
Upvotes: 1
Views: 3150
Reputation: 18504
Session
is not an object, it's a class. In this case, sendToTarget()
is static method.
Session
, maintains a class-static list of sessions. sendToTarget()
's uses the header fields in your message (or those you explicitly supply) to determine which session to send on.
EDIT: I misread your question. Here's an answer to what you asked.
The session is created in the bowels of the QF engine. It's created by a SessionFactory
, which is itself created in the initialize()
function of Initiator
and Acceptor
. This is stuff you only need to get into if you feel like hacking on the engine source.
As an app developer, you really don't need a handle to the session. If you think you do, then I'm guessing you're probably planning to do something that is not recommended (such as wanting to programmatically reset seq#s, which is a common newbie Bad Idea on the QF lists).
If you really want a handle to it, you can use Session.lookupSession()
or one of the getSession()
functions of Initiator
or Acceptor
. But again, I don't see any reason to bother. I'm a seasoned QF user, and I had to go look this up, because it's something I never ever do.
Upvotes: 1