class BitexBot::SellClosingFlow
It bought at Bitex
and needs to close (sell) in the other market.
Public Class Methods
fx_rate()
click to toggle source
# File lib/bitex_bot/models/sell_closing_flow.rb, line 13 def self.fx_rate Settings.selling_fx_rate end
open_position_class()
click to toggle source
# File lib/bitex_bot/models/sell_closing_flow.rb, line 9 def self.open_position_class OpenSell end
Private Instance Methods
estimate_crypto_profit()
click to toggle source
The coins we actually bought minus the coins we were supposed to re-buy.
# File lib/bitex_bot/models/sell_closing_flow.rb, line 27 def estimate_crypto_profit close_positions.sum(:quantity) - quantity end
estimate_fiat_profit()
click to toggle source
create_or_cancel! helpers The amount received when selling initially, minus the amount spent re-buying the sold coins.
# File lib/bitex_bot/models/sell_closing_flow.rb, line 22 def estimate_fiat_profit open_positions.sum(:amount) - positions_balance_amount end
next_price_and_quantity()
click to toggle source
# File lib/bitex_bot/models/sell_closing_flow.rb, line 31 def next_price_and_quantity closes = close_positions next_price = desired_price + price_variation(closes.count) next_quantity = ((quantity * desired_price) - closes.sum(:amount)) / next_price [next_price, next_quantity] end
order_type()
click to toggle source
create_order_and_close_position helpers
# File lib/bitex_bot/models/sell_closing_flow.rb, line 41 def order_type :buy end