Module: Coinbot::OrderBook::EMACross
- Defined in:
- lib/coinbot/order_book/ema_cross.rb
Class Method Summary collapse
-
.help ⇒ Object
Display Usage for this Module.
-
.status(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::OrderBook::DeathCross.status( ).
Class Method Details
.help ⇒ Object
Display Usage for this Module
48 49 50 51 52 |
# File 'lib/coinbot/order_book/ema_cross.rb', line 48 public_class_method def self.help puts "USAGE: ema_cross_indicator_hash = #{self}.status() " end |
.status(opts = {}) ⇒ Object
- Supported Method Parameters
-
Coinbot::OrderBook::DeathCross.status( )
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/coinbot/order_book/ema_cross.rb', line 12 public_class_method def self.status(opts = {}) order_book = opts[:order_book] indicator_status = opts[:indicator_status] invested = opts[:invested] candle = order_book[:candles].last indicator_hash = {} indicator_hash[:invested] = invested indicator_hash[:status] = 'EMA' # If -- to_f will cast as 0.0 ema_low_avg = candle[:ema_low_avg].to_f ema_high_avg = candle[:ema_high_avg].to_f indicator_hash[:color] = :white indicator_hash[:color] = :green if ema_low_avg.positive? && ema_high_avg.positive? && ema_low_avg > ema_high_avg indicator_hash[:color] = :yellow if ema_low_avg.positive? && ema_high_avg.positive? && ema_low_avg == ema_high_avg indicator_hash[:color] = :red if ema_low_avg.positive? && ema_high_avg.positive? && ema_low_avg < ema_high_avg indicator_status.ema_cross = indicator_hash rescue StandardError => e raise e end |