module Abot::Info::Coin::CoinDecorator
Public Instance Methods
decorated_buy_date()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 98 def decorated_buy_date sec = timer.to_s[0..9].to_f return '-' if sec < 1_577_836_800 # 2020-01-01 00:00:00 +0000 Time.at(sec).strftime('%d %h %H:%M') rescue StandardError '-' end
decorated_cell(name)
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 133 def decorated_cell(name) str = public_send("decorated_#{name}") value = Paint[str, (Helpers::AVERAGE_COLORS[num_averaging] || :red)] row = { value: value } row[:alignment] = :right if name == :timer row[:alignment] = :center if name == :buy_date row end
decorated_current_price()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 66 def decorated_current_price "#{current_price} (#{percent_to_order.round(2)}%)" end
decorated_current_price_perc_of_order()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 70 def decorated_current_price_perc_of_order "#{current_price} (#{percent_from_order.round(2)}%)" end
decorated_current_profit()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 21 def decorated_current_profit rounded_current_profit = if trade_params['quote_asset'].split(' ').count > 1 "#{current_profit.round(2)} #{quote_asset}" else current_profit.round(2) end if current_profit >= 0 Paint[rounded_current_profit, :green] else Paint[rounded_current_profit, :red] end end
decorated_current_quote()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 86 def decorated_current_quote current_quote.round(2) end
decorated_max_price()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 78 def decorated_max_price "#{max_price} (#{percent_to_max.round(2)}%)" end
decorated_max_price_perc_of_order()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 82 def decorated_max_price_perc_of_order "#{max_price} (#{percent_from_max.round(2)}%)" end
decorated_min_price()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 74 def decorated_min_price "#{min_price} (#{percent_from_min_to_average.round(2)}%)" end
decorated_name()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 46 def decorated_name arrow = if account.symbol_info(symbol).try(:[], :lastPrice).to_f < account.symbol_info(symbol).try(:[], :askPrice).to_f Paint[' ↑', :green] elsif account.symbol_info(symbol).try(:[], :lastPrice).to_f > account.symbol_info(symbol).try(:[], :askPrice).to_f Paint[' ↓', :red] else '' end "#{decorated_name_mobile} (#{account.symbol_info(symbol).try(:[], :priceChangePercent)}%)#{arrow}" end
decorated_name_mobile()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 57 def decorated_name_mobile pump_det = pump_detector == 'True' ? '👁 ' : '' "#{pump_det}#{name}" end
decorated_next_average_price()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 42 def decorated_next_average_price next_average_price.zero? ? '-' : "#{next_average_price} (#{decorated_next_average_price_percent})" end
decorated_next_average_price_percent()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 38 def decorated_next_average_price_percent "#{next_average_price_percent.round(2)}%" end
decorated_num_averaging()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 34 def decorated_num_averaging Paint[num_averaging, (Helpers::AVERAGE_COLORS[num_averaging] || :red)] end
decorated_potential_profit()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 90 def decorated_potential_profit if trade_params['quote_asset'].split(' ').count > 1 "#{potential_profit.round(2)} #{quote_asset}" else potential_profit.round(2) end end
decorated_sell_price()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 62 def decorated_sell_price sell_price end
decorated_sell_up()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 7 def decorated_sell_up return '-' if sell_up == Float::INFINITY rounded_sell_up = sell_up.round(2) case num_averaging when 1, 2 rounded_sell_up > 2 ? Paint[rounded_sell_up, :red] : rounded_sell_up when 3, 4, 5 rounded_sell_up > 2 ? rounded_sell_up : Paint[rounded_sell_up, :red] else rounded_sell_up end end
decorated_timer()
click to toggle source
# File lib/abot/info/decorators/coin_decorator.rb, line 107 def decorated_timer sec = timer.to_s[0..9].to_f return '-' if sec < 1_577_836_800 # 2020-01-01 00:00:00 +0000 medidas = %w[г мес д ч м c] array = [1970, 1, 1, 0, 0, 0] text = '' Time.at(Time.now.to_i - sec).utc.to_a.take(6).reverse.each_with_index do |k, i| case i when 0, 1, 2 next if text.blank? && (k - array[i]).zero? text = "#{text} #{k - array[i]}#{medidas[i]}" when 3 next_text = (k - array[i]).to_s.rjust(2, '0') text = "#{text} #{next_text}" when 4 next_text = (k - array[i]).to_s.rjust(2, '0') text = "#{text}:#{next_text}" end end text rescue StandardError '-' end