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
- .balance_str(account, current_coins, trade_params) ⇒ Object
- .check_abot ⇒ Object
- .daily_profit_str ⇒ Object
- .potential_balance_str(account, current_coins, trade_params) ⇒ Object
- .symbol_price_str(account, symbol_name) ⇒ Object
Class Method Details
.balance_str(account, current_coins, trade_params) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/abot/info/helpers.rb', line 24 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 ⇒ Object
58 59 60 |
# File 'lib/abot/info/helpers.rb', line 58 def self.check_abot Paint['WARNING: ПРОВЕРЬТЕ БОТА !!!', :black, :red] + "\n" if (Time.now - File.mtime(DatabaseTable::DB_PATH)) > 10 end |
.daily_profit_str ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/abot/info/helpers.rb', line 15 def self.daily_profit_str profit = 'Профит сегодня:' DatabaseTable.data_daily_profit.each do |c| tick_size = (c['quote'] == 'BTC' ? 7 : 2) profit += Paint[" #{c['sum(profit)'].round(tick_size)} #{c['quote']};", :green] end profit end |
.potential_balance_str(account, current_coins, trade_params) ⇒ Object
46 47 48 |
# File 'lib/abot/info/helpers.rb', line 46 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) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/abot/info/helpers.rb', line 50 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 |