Class: BitexBot::BuyClosingFlow

Inherits:
ClosingFlow
  • Object
show all
Defined in:
lib/bitex_bot/models/buy_closing_flow.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ClosingFlow

close_open_positions, close_time_to_live, #create_initial_order_and_close_position, #create_order_and_close_position, minimum_amount_for_closing, #sync_closed_positions

Class Method Details

.open_position_classObject



7
8
9
# File 'lib/bitex_bot/models/buy_closing_flow.rb', line 7

def self.open_position_class
  OpenBuy
end

Instance Method Details

#get_btc_profitObject

The coins we actually bought minus the coins we were supposed to re-buy



23
24
25
# File 'lib/bitex_bot/models/buy_closing_flow.rb', line 23

def get_btc_profit
  quantity - close_positions.sum(:quantity)
end

#get_next_price_and_quantityObject



27
28
29
30
31
32
# File 'lib/bitex_bot/models/buy_closing_flow.rb', line 27

def get_next_price_and_quantity
  closes = close_positions
  next_price = desired_price - ((closes.count * (closes.count * 3)) / 100.0)
  next_quantity = quantity - closes.sum(:quantity)
  [next_price, next_quantity]
end

#get_usd_profitObject

The amount received when selling initially, minus the amount spent re-buying the sold coins.



17
18
19
# File 'lib/bitex_bot/models/buy_closing_flow.rb', line 17

def get_usd_profit
  close_positions.sum(:amount) - open_positions.sum(:amount)
end

#order_methodObject



11
12
13
# File 'lib/bitex_bot/models/buy_closing_flow.rb', line 11

def order_method
  :sell
end