Class: IB::IncomingMessages::OpenOrder

Inherits:
AbstractMessage show all
Defined in:
lib/ib-ruby/messages.rb

Overview

class ErrorMessage

Instance Attribute Summary collapse

Attributes inherited from AbstractMessage

#data

Attributes inherited from ExtremelyAbstractMessage

#created_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractMessage

inherited, #initialize

Methods inherited from ExtremelyAbstractMessage

#to_human

Constructor Details

This class inherits a constructor from IB::IncomingMessages::AbstractMessage

Instance Attribute Details

#contractObject

Returns the value of attribute contract.



1026
1027
1028
# File 'lib/ib-ruby/messages.rb', line 1026

def contract
  @contract
end

#orderObject

Returns the value of attribute order.



1026
1027
1028
# File 'lib/ib-ruby/messages.rb', line 1026

def order
  @order
end

Class Method Details

.message_idObject



1028
1029
1030
# File 'lib/ib-ruby/messages.rb', line 1028

def self.message_id
  5
end

Instance Method Details

#loadObject



1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
# File 'lib/ib-ruby/messages.rb', line 1032

def load
  @order = Datatypes::Order.new
  @contract = Datatypes::Contract.new

  autoload([:version, :int])

  @order.id = @socket.read_int

  @contract.symbol = @socket.read_string
  @contract.sec_type = @socket.read_string
  @contract.expiry = @socket.read_string
  @contract.strike = @socket.read_decimal
  @contract.right = @socket.read_string
  @contract.exchange = @socket.read_string
  @contract.currency = @socket.read_string

  @contract.local_symbol = @socket.read_string if @data[:version] >= 2

  @order.action = @socket.read_string
  @order.total_quantity = @socket.read_int
  @order.order_type = @socket.read_string
  @order.limit_price = @socket.read_decimal
  @order.aux_price = @socket.read_decimal
  @order.tif = @socket.read_string
  @order.oca_group = @socket.read_string
  @order. = @socket.read_string
  @order.open_close = @socket.read_string
  @order.origin = @socket.read_int
  @order.order_ref = @socket.read_string

  @order.client_id = @socket.read_int if @data[:version] >= 3

  if @data[:version] >= 4
    @order.perm_id = @socket.read_int
    @order.ignore_rth = (@socket.read_int == 1)
    @order.hidden = (@socket.read_int == 1)
    @order.discretionary_amount = @socket.read_decimal
  end

  @order.good_after_time = @socket.read_string if @data[:version] >= 5
  @order.shares_allocation = @socket.read_string if @data[:version] >= 6

  if @data[:version] >= 7
    @order.fa_group = @socket.read_string
    @order.fa_method = @socket.read_string
    @order.fa_percentage = @socket.read_string
    @order.fa_profile = @socket.read_string
  end

  @order.good_till_date = @socket.read_string if @data[:version] >= 8

  if @data[:version] >= 9
    @order.rule_80A = @socket.read_string
    @order.percent_offset = @socket.read_decimal
    @order.settling_firm = @socket.read_string
    @order.short_sale_slot = @socket.read_int
    @order.designated_location = @socket.read_string
    @order.auction_strategy = @socket.read_int
    @order.starting_price = @socket.read_decimal
    @order.stock_ref_price = @socket.read_decimal
    @order.delta = @socket.read_decimal
    @order.stock_range_lower = @socket.read_decimal
    @order.stock_range_upper = @socket.read_decimal
    @order.display_size = @socket.read_int
    @order.rth_only = @socket.read_boolean
    @order.block_order = @socket.read_boolean
    @order.sweep_to_fill = @socket.read_boolean
    @order.all_or_none = @socket.read_boolean
    @order.min_quantity = @socket.read_int
    @order.oca_type = @socket.read_int
    @order.eTrade_only = @socket.read_boolean
    @order.firm_quote_only = @socket.read_boolean
    @order.nbbo_price_cap = @socket.read_decimal
  end

  if @data[:version] >= 10
    @order.parent_id = @socket.read_int
    @order.trigger_method = @socket.read_int
  end

  if @data[:version] >= 11
    @order.volatility = @socket.read_decimal
    @order.volatility_type = @socket.read_int

    if @data[:version] == 11
      @order.delta_neutral_order_type = ( @socket.read_int == 0 ? "NONE" : "MKT" )
    else
      @order.delta_neutral_order_type = @socket.read_string
      @order.delta_neutral_aux_price = @socket.read_decimal
    end

    @order.continuous_update = @socket.read_int
    if @server_version == 26
      @order.stock_range_lower = @socket.read_decimal
      @order.stock_range_upper = @socket.read_decimal
    end

    @order.reference_price_type = @socket.read_int
  end # if version >= 11


end