Skip to content

Instantly share code, notes, and snippets.

@shal
Last active June 13, 2019 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shal/35be4fecfb83a9a715fa9ccdbf99acc8 to your computer and use it in GitHub Desktop.
Save shal/35be4fecfb83a9a715fa9ccdbf99acc8 to your computer and use it in GitHub Desktop.
Remove orders, which have price less than minimum price.
#!/usr/bin/env ruby
#
# Author: Ali Shanaakh <hi@shal.dev>
# Removes peatio orders, where prices less than min_ask_price.
#
# Usage:
# ./cancel_min_orders.rb
markets = ["usdeur"]
markets.each do |market_id|
min_price = Market.find(market).min_ask_price
Market.find(market).update!(min_ask_price: 0.0)
orders = Order.where(market: market, state: "wait").where("price < #{min_price}")
orders.each { |o| Order.cancel(o.id) }
Market.find(market).update!(min_ask_price: min_price)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment