module Abot::Info::Helpers

helper

Constants

AVERAGE_COLORS

Public Class Methods

balance_str(account, current_coins, trade_params) click to toggle source
# File lib/abot/info/helpers.rb, line 26
def self.balance_str(account, current_coins, trade_params)
  quote_assets = trade_params['quote_asset'].split(' ')
  result = ''
  balance_btc = account.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 : account.current_balance(balance_btc, quote)
    balance_wl = account.current_balance_wl(current_coins, quote)

    cb = "Б: #{Paint["#{balance.round(tick_size)} ", :green]}"
    cbwl = "Б(WL): #{Paint["#{balance_wl.round(tick_size)} ", :green]}"
    fb = "С: #{Paint["#{account.free_balance(quote).round(tick_size)} " \
       "(#{account.percent_free_balance(balance_wl, quote)}%)", :green]} "
    result += (quote + ' ' + cb + cbwl + fb)
  end
  result
rescue StandardError
  ''
end
check_abot() click to toggle source
# 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) click to toggle source
# File lib/abot/info/helpers.rb, line 64
def self.check_coins(account, quote_assets)
  coins_without_order = account.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) click to toggle source
# File lib/abot/info/helpers.rb, line 48
def self.potential_balance_str(account, current_coins, trade_params)
  "П: #{Paint["#{account.potential_balance(current_coins, trade_params).round(2)} USDT", :green]}"
end
symbol_price_str(account, symbol_name) click to toggle source
# File lib/abot/info/helpers.rb, line 52
def self.symbol_price_str(account, symbol_name)
  symbol = account.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_str() click to toggle source
# 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