119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/ib/gateway/order-handling.rb', line 119
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
the_details = contract.contract_detail.present? ? contract.contract_detail : 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
|