Module: Abot::Info::Helpers

Included in:
Table
Defined in:
lib/abot/info/helpers.rb

Overview

helper

Constant Summary collapse

AVERAGE_COLORS =
%i[
  white
  green
  cyan
  yellow
  magenta
].freeze

Class Method Summary collapse

Class Method Details

.balance_str(account, current_coins, trade_params) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/abot/info/helpers.rb', line 26

def self.balance_str(, current_coins, trade_params)
  quote_assets = trade_params['quote_asset'].split(' ')
  result = ''
  balance_btc = .current_balance_btc
  quote_assets.each_with_index do |quote, idx|
    result += "\n" unless idx.zero?
    tick_size = (quote == 'BTC' ? 6 : 2)

    balance = quote == 'BTC' ? balance_btc : .current_balance(balance_btc, quote)
    balance_wl = .current_balance_wl(current_coins, quote)

    cb = "Б: #{Paint["#{balance.round(tick_size)} ", :green]}"
    cbwl = "Б(WL): #{Paint["#{balance_wl.round(tick_size)} ", :green]}"
    fb = "С: #{Paint["#{.free_balance(quote).round(tick_size)} " \
       "(#{.percent_free_balance(balance_wl, quote)}%)", :green]} "
    result += (quote + ' ' + cb + cbwl + fb)
  end
  result
rescue StandardError
  ''
end

.check_abotObject



60
61
62
# File 'lib/abot/info/helpers.rb', line 60

def self.check_abot
  Paint['WARNING: ПРОВЕРЬТЕ БОТА !!!', :black, :red] + "\n" if (Time.now - File.mtime(DatabaseTable::DB_PATH)) > 10
end

.check_coins(account, quote_assets) ⇒ Object



64
65
66
67
68
69
# File 'lib/abot/info/helpers.rb', line 64

def self.check_coins(, quote_assets)
  coins_without_order = .coins_without_order(quote_assets)
  if coins_without_order.present?
    Paint["Монеты без ордера: #{coins_without_order.join(', ')}", :black, :red] + "\n"
  end
end

.potential_balance_str(account, current_coins, trade_params) ⇒ Object



48
49
50
# File 'lib/abot/info/helpers.rb', line 48

def self.potential_balance_str(, current_coins, trade_params)
  "П: #{Paint["#{.potential_balance(current_coins, trade_params).round(2)} USDT", :green]}"
end

.symbol_price_str(account, symbol_name) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/abot/info/helpers.rb', line 52

def self.symbol_price_str(, symbol_name)
  symbol = .symbol_info(symbol_name.to_s)
  return '' if symbol.nil?

  percent_color = symbol[:priceChangePercent].to_f.positive? ? :green : :red
  "#{symbol_name}: " + Paint["#{symbol[:askPrice].to_f} (#{symbol[:priceChangePercent]}%)", percent_color]
end

.today_info_strObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/abot/info/helpers.rb', line 15

def self.today_info_str
  profit = 'Профит сегодня:'
  transactions_count = 'Сделок '
  DatabaseTable.data_daily_profit.each do |c|
    tick_size = (c['quote'] == 'BTC' ? 7 : 2)
    profit += "#{Paint[" #{c['sum'].round(tick_size)} #{c['quote']}", :green]};"
    transactions_count += "#{c['quote']}: #{Paint[c['count'], :green]}; "
  end
  "#{profit} #{transactions_count}"
end