forked from quickfix/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathat_application.rb
More file actions
63 lines (50 loc) · 1.41 KB
/
Copy pathat_application.rb
File metadata and controls
63 lines (50 loc) · 1.41 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'quickfix_ruby'
class Application < Quickfix::Application
def initiatlize
@orderIDs = Hash.new
end
def onCreate(sessionID)
reset()
session = Quickfix::Session.lookupSession( sessionID )
session.reset() if session != nil
end
def onLogon(sessionID)
end
def onLogout(sessionID)
reset()
end
def toAdmin(sessionID, message)
end
def fromAdmin(sessionID, message)
end
def toApp(sessionID, message)
end
def fromApp(message, sessionID)
msgType = Quickfix::MsgType.new
message.getHeader().getField( msgType )
if( msgType.getValue() == Quickfix::MsgType_NewOrderSingle() )
echo = Quickfix::Message.new( message )
possResend = Quickfix::PossResend.new( false )
if( message.getHeader().isSetField( possResend ) )
message.getHeader().getField( possResend )
end
clOrdID = Quickfix::ClOrdID.new
message.getField( clOrdID )
if( possResend.getValue() )
if( @orderIDs.has_key?([clOrdID.getString(), sessionID.toString()]) )
return
end
end
@orderIDs[[clOrdID.getString(), sessionID.toString()]] = [clOrdID.getString(), sessionID.toString()]
Quickfix::Session::sendToTarget( echo, sessionID )
elsif( msgType.getValue() == Quickfix::MsgType_SecurityDefinition() )
echo = Quickfix::Message.new( message )
Quickfix::Session::sendToTarget( echo, sessionID )
else
raise Quickfix::UnsupportedMessageType.new
end
end
def reset
@orderIDs = Hash.new
end
end