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