class Abot::Info::Coin
Constants
- FIAT
Attributes
account[R]
average_price[R]
base_asset[R]
buy_price[R]
current_price[R]
num_averaging[R]
pump_detector[R]
quote_asset[R]
sell_price[R]
step_averaging[R]
tick_size[R]
timer[R]
total_quote[R]
trade_params[R]
volume[R]
Public Class Methods
available_coins_number(current_coins, data_settings, free_balance)
click to toggle source
# File lib/abot/info/coin.rb, line 57 def self.available_coins_number(current_coins, data_settings, free_balance) aver_arr = [] current_coins.each_with_index {|m| aver_arr[m.num_averaging] = ((aver_arr[m.num_averaging].to_i) + 1) } aver_weight = 0 aver_arr.each_with_index { |e, idx| aver_weight += (e.to_i * idx) } max_pairs = (free_balance / 100) * data_settings["max_trade_pairs"].to_i progressive_max_pairs = max_pairs - aver_weight progressive_max_pairs.positive? ? progressive_max_pairs.round(0) : 0 end
current_coins(account, trade_params)
click to toggle source
# File lib/abot/info/coin.rb, line 35 def self.current_coins(account, trade_params) DatabaseTable.data_coins.map do |coin| Coin.new( trade_params: trade_params, account: account, base_asset: coin['baseAsset'], quote_asset: coin['quoteAsset'], average_price: coin['averagePrice'].to_f, current_price: coin['askPrice'].to_f, sell_price: coin['sellPrice'].to_f, volume: coin['allQuantity'].to_f, num_averaging: (coin['numAveraging'].to_i - 1), total_quote: coin['totalQuote'].to_f.round(2), buy_price: coin['buyPrice'].to_f, step_averaging: coin['stepAveraging'].to_f, tick_size: coin['tickSize'], timer: coin['timer'].to_s[0..9], pump_detector: coin['pumpDetector'], ) end end
new(options = {})
click to toggle source
# File lib/abot/info/coin.rb, line 17 def initialize(options = {}) @trade_params = options[:trade_params] @account = options[:account] @base_asset = options[:base_asset] @quote_asset = options[:quote_asset] @average_price = options[:average_price] @current_price = options[:current_price] @sell_price = options[:sell_price] @volume = options[:volume] @num_averaging = options[:num_averaging] @total_quote = options[:total_quote] @buy_price = options[:buy_price] @step_averaging = options[:step_averaging] @tick_size = options[:tick_size] @timer = options[:timer] @pump_detector = options[:pump_detector] end
sum_current_profit(current_coins, quote)
click to toggle source
# File lib/abot/info/coin.rb, line 67 def self.sum_current_profit(current_coins, quote) current_coins = current_coins.select { |s| s.quote_asset == quote } current_coins.sum(&:current_profit) end
sum_potential_profit(current_coins, quote)
click to toggle source
# File lib/abot/info/coin.rb, line 72 def self.sum_potential_profit(current_coins, quote) current_coins = current_coins.select { |s| s.quote_asset == quote } current_coins.sum(&:potential_profit) end
Public Instance Methods
current_profit()
click to toggle source
# File lib/abot/info/coin.rb, line 105 def current_profit @current_profit ||= ((current_price - average_price) * volume) end
current_quote()
click to toggle source
# File lib/abot/info/coin.rb, line 113 def current_quote @current_quote ||= (total_quote + current_profit) end
max_price()
click to toggle source
# File lib/abot/info/coin.rb, line 101 def max_price @max_price ||= account.symbol_max_price(symbol) end
min_price()
click to toggle source
# File lib/abot/info/coin.rb, line 97 def min_price @min_price ||= account.symbol_min_price(symbol) end
name()
click to toggle source
# File lib/abot/info/coin.rb, line 130 def name quote_asset == 'USDT' ? base_asset : symbol end
next_average_price()
click to toggle source
# File lib/abot/info/coin.rb, line 121 def next_average_price @next_average_price ||= (buy_price - (buy_price / 100 * (step_averaging - trade_params['buy_down'].to_f))).round(tick_round_size) end
next_average_price_percent()
click to toggle source
# File lib/abot/info/coin.rb, line 126 def next_average_price_percent @next_average_price_percent ||= ((current_price / next_average_price - 1) * 100) end
percent_from_max()
click to toggle source
# File lib/abot/info/coin.rb, line 93 def percent_from_max @percent_from_max ||= ((1 - max_price / sell_price) * 100) end
percent_from_min_to_average()
click to toggle source
# File lib/abot/info/coin.rb, line 85 def percent_from_min_to_average @percent_to_min ||= ((min_price / next_average_price - 1) * 100) end
percent_from_order()
click to toggle source
# File lib/abot/info/coin.rb, line 81 def percent_from_order @percent_from_order ||= ((1 - current_price / sell_price) * 100) end
percent_to_max()
click to toggle source
# File lib/abot/info/coin.rb, line 89 def percent_to_max @percent_to_max ||= ((sell_price / max_price - 1) * 100) end
percent_to_order()
click to toggle source
# File lib/abot/info/coin.rb, line 77 def percent_to_order @percent_to_order ||= ((sell_price / current_price - 1) * 100) end
potential_profit()
click to toggle source
# File lib/abot/info/coin.rb, line 109 def potential_profit ((sell_price - average_price) * volume) end
sell_up()
click to toggle source
# File lib/abot/info/coin.rb, line 117 def sell_up @sell_up ||= ((potential_profit / total_quote) * 100 - 0.15) end
symbol()
click to toggle source
# File lib/abot/info/coin.rb, line 134 def symbol base_asset + quote_asset end
Private Instance Methods
tick_round_size()
click to toggle source
# File lib/abot/info/coin.rb, line 140 def tick_round_size @tick_round_size ||= tick_size.length - 2 end