forked from quickfix/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathat_application.py
More file actions
43 lines (35 loc) · 1.46 KB
/
Copy pathat_application.py
File metadata and controls
43 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import quickfix as fix
class Application(fix.Application):
orderIDs = {}
def onCreate(self, sessionID):
self.reset()
session = fix.Session.lookupSession( sessionID )
if session == None:
session.reset()
def onLogon(self, sessionID): return
def onLogout(self, sessionID): return
def toAdmin(self, sessionID, message): return
def fromAdmin(self, sessionID, message): return
def toApp(self, sessionID, message): return
def fromApp(self, message, sessionID):
msgType = fix.MsgType()
message.getHeader().getField( msgType )
if( msgType.getValue() == fix.MsgType_NewOrderSingle ):
echo = fix.Message( message )
possResend = fix.PossResend( False )
if( message.getHeader().isSetField( possResend ) ):
message.getHeader().getField( possResend )
clOrdID = fix.ClOrdID()
message.getField( clOrdID )
if( possResend.getValue() ):
if( clOrdID.getString() in self.orderIDs ):
return
self.orderIDs[clOrdID.getString()] = clOrdID.getString()
fix.Session.sendToTarget( echo, sessionID )
elif( msgType.getValue() == fix.MsgType_SecurityDefinition ):
echo = fix.Message( message )
fix.Session.sendToTarget( echo, sessionID )
else:
raise fix.UnsupportedMessageType()
def reset( self ):
self.orderIDs = {}