Class: IB::OutgoingMessages::AbstractMessage
- Inherits:
-
ExtremelyAbstractMessage
- Object
- ExtremelyAbstractMessage
- IB::OutgoingMessages::AbstractMessage
- Defined in:
- lib/ib-ruby/messages.rb
Direct Known Subclasses
CancelMarketData, CancelMarketDepth, CancelNewsBulletins, CancelOrder, ExerciseOptions, PlaceOrder, ReplaceFA, RequestAccountData, RequestAllOpenOrders, RequestAutoOpenOrders, RequestContractData, RequestExecutions, RequestFA, RequestHistoricalData, RequestIds, RequestManagedAccounts, RequestMarketData, RequestMarketDepth, RequestNewsBulletins, RequestOpenOrders, RequestScannerSubscription, SetServerLoglevel
Instance Attribute Summary
Attributes inherited from ExtremelyAbstractMessage
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ AbstractMessage
constructor
data is a Hash.
- #queue ⇒ Object
-
#send(server) ⇒ Object
This causes the message to send itself over the server socket in server.
Methods inherited from ExtremelyAbstractMessage
Constructor Details
#initialize(data = nil) ⇒ AbstractMessage
data is a Hash.
51 52 53 54 |
# File 'lib/ib-ruby/messages.rb', line 51 def initialize(data=nil) @created_at = Time.now @data = Datatypes::StringentHash.new(data) end |
Class Method Details
.message_id ⇒ Object
46 47 48 |
# File 'lib/ib-ruby/messages.rb', line 46 def self. raise Exception("AbstractMessage.message_id called - you need to override this in a subclass.") end |
Instance Method Details
#queue ⇒ Object
78 79 80 |
# File 'lib/ib-ruby/messages.rb', line 78 def queue raise Exception("AbstractMessage.queue() called - you need to override this in a subclass.") end |
#send(server) ⇒ Object
This causes the message to send itself over the server socket in server. “server” is the @server instance variable from the IB object. You can also use this to e.g. get the server version number.
Subclasses can either override this method for precise control over how stuff gets sent to the server, or else define a method queue() that returns an Array of elements that ought to be sent to the server by calling to_s on each one and postpending a ‘0’.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ib-ruby/messages.rb', line 66 def send(server) self.queue(server).each {|datum| # TWS wants to receive booleans as 1 or 0... rewrite as # necessary. datum = "1" if datum == true datum = "0" if datum == false server[:socket].syswrite(datum.to_s + "\0") } end |