123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/ib/gateway/order-handling.rb', line 123
def auto_adjust
adjust_price = ->(a,b) do
a=BigDecimal(a,5)
b=BigDecimal(b,5)
_,o =a.divmod(b)
a-o
end
error "No Contract provided to Auto adjust " unless contract.is_a? IB::Contract
unless contract.is_a? IB::Bag
contract.verify do |the_contract |
the_details = the_contract.contract_detail.presence || the_contract.verify.first.contract_detail
self.limit_price= adjust_price.call(limit_price.to_f, the_details.min_tick) unless limit_price.to_f.zero?
self.aux_price= adjust_price.call(aux_price.to_f, the_details.min_tick) unless aux_price.to_f.zero?
end
end
end
|