Skip to content

Instantly share code, notes, and snippets.

@alinetskyi
Last active October 3, 2019 13:43
Show Gist options
  • Save alinetskyi/741eae128210e9d16aa2d879a15498ab to your computer and use it in GitHub Desktop.
Save alinetskyi/741eae128210e9d16aa2d879a15498ab to your computer and use it in GitHub Desktop.
Delete orders that below min_price
Market.enabled.each do |m|
min_price = m.min_price
data = Order.where(market_id: m.id, state: 'wait').where('price < ?', m.min_price)
m.update!(min_price: 0)
data.each do |o|
Order.cancel(o.id)
end
m.update!(min_price: min_price)
end
Market.enabled.each do |m|
min_price = m.min_price
data = Order.where(market_id: m.id, state: 'wait').where('price < ?', m.min_price)
data.each do |o|
puts "Order that doesn't pass the validation: #{o}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment