abot-info 0.1.0 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbe9530de84f99fcba646a78e0c4a61bb02ebf2e484159817721724cfe6b7733
4
- data.tar.gz: 5f1decd77bea3d406a7abe300c9a887391afe9a7991d27561c9a5a34ea8350e4
3
+ metadata.gz: 7d58b0e5421210e4d455de713e558820168d1a1ad094e203bdf69fe3244a7dbe
4
+ data.tar.gz: 4a61b59b59a4ff4fbed7219c44b1063bcd14d7f46d4ea43cb930b3b4820d7313
5
5
  SHA512:
6
- metadata.gz: 4544c13838da0d2ed4af0e559b02d8c3bac17555a2cd7bdad62d0b1fcf496a13ab8e192205c537e2244775b1e4306c001eb60df1f211ae4244719265fb1565ee
7
- data.tar.gz: b647a8cd960afb5e5bbaf739949cddfd6ab1fb4e2055ec9ab6e7228681df5e10cb76d8b4a92a528c48dad85eff855cd96275421da508f5bcdd5c8bc81bd6fcc9
6
+ metadata.gz: 96859eb095d54fe84a84f506c8356a9f7bf44b0a0ee80dd3f9e54a947390c18e3d7ebf21f39ea24cee7f105d407fa3f2b8efac62534280bdd9023bd63ce79927
7
+ data.tar.gz: af692d94de52095dcaa092b7829e817d60bad1f65ef9826a1843a46d4ccde0415ef3213003e165b92afd64c8ff29e9dd33fede1a0f5e460485edcafacb50e886
data/lib/abot/info.rb CHANGED
@@ -43,6 +43,8 @@ module Abot
43
43
  " timer: Время с покупки\n" \
44
44
  " current_profit: Текущая прибыль\n" \
45
45
  " potential_profit: Потенциальная прибыль\n",
46
+ " current_price_perc_of_order: Текущая цена (подсчет процента от ордера за продажу)\n" \
47
+ " max_price_perc_of_order: Максимальная цена за 24ч (подсчет процента от ордера за продажу)\n" \
46
48
  )
47
49
  parser.add_option(
48
50
  :del, '--del=COLUMN1,COLUMN2,COLUMN3',
@@ -60,6 +62,8 @@ module Abot
60
62
  " timer: Время с покупки\n" \
61
63
  " current_profit: Текущая прибыль\n" \
62
64
  " potential_profit: Потенциальная прибыль\n",
65
+ " current_price_perc_of_order: Текущая цена (подсчет процента от ордера за продажу)\n" \
66
+ " max_price_perc_of_order: Максимальная цена за 24ч (подсчет процента от ордера за продажу)\n"
63
67
  )
64
68
  parser.add_option(
65
69
  :db_path, '--db_path=DB_PATH',
@@ -79,6 +79,33 @@ module Abot
79
79
  symbol_info(symbol).try(:[], :highPrice).to_f
80
80
  end
81
81
 
82
+ def coins_without_order(quote_assets)
83
+ exception_coins = quote_assets + ['BNB'] + Coin::FIAT
84
+ balances = account_info[:balances]
85
+ result = balances.select do |s|
86
+ s[:free].to_f != 0 &&
87
+ !exception_coins.include?(s[:asset]) &&
88
+ symbol_info(s[:asset] + 'USDT').try(:[], :askPrice).to_f * s[:free].to_f > 5 &&
89
+ (
90
+ begin
91
+ btcusdt = get_symbols.find { |f| f[:symbol] == 'BTCUSDT' }[:askPrice].to_f
92
+ if s[:asset] == 'BTC'
93
+ symbol_info("#{s[:asset]}USDT").try(:[], :askPrice).to_f * s[:free].to_f > 5
94
+ elsif get_symbols.find { |f| f[:symbol] == "#{s[:asset]}USDT" }.nil?
95
+ coin = get_symbols.find { |f| f[:symbol] == "#{name}BTC" }
96
+ coin[:askPrice].to_f * s[:free].to_f * btcusdt > 5
97
+ else
98
+ coin = get_symbols.find { |f| f[:symbol] == "#{s[:asset]}USDT" }
99
+ coin[:askPrice].to_f * s[:free].to_f > 5
100
+ end
101
+ rescue StandardError
102
+ false
103
+ end
104
+ )
105
+ end
106
+ result.pluck(:asset)
107
+ end
108
+
82
109
  private
83
110
 
84
111
  def calculation_current_balance_btc
@@ -8,9 +8,11 @@ module Abot
8
8
  include Abot::Info::Coin::CoinDecorator
9
9
 
10
10
  attr_reader :base_asset, :quote_asset, :average_price, :current_price, :sell_price, :volume, :num_averaging,
11
- :total_quote, :buy_price, :step_averaging, :tick_size, :account, :timer, :trade_params
11
+ :total_quote, :buy_price, :step_averaging, :tick_size, :account, :timer, :trade_params,
12
+ :pump_detector
13
+
14
+ FIAT = %w[USDT BUSD AUD BIDR BRL EUR GBR RUB TRY TUSD USDC DAI IDRT PAX UAH NGN VAI BVND]
12
15
 
13
- FIAT = ['USDT', 'BUSD', 'AUD', 'BIDR', 'BRL', 'EUR', 'GBR', 'RUB', 'TRY', 'TUSD', 'USDC', 'DAI', 'IDRT', 'PAX', 'UAH', 'NGN', 'VAI', 'BVND']
14
16
 
15
17
  def initialize(options = {})
16
18
  @trade_params = options[:trade_params]
@@ -27,6 +29,7 @@ module Abot
27
29
  @step_averaging = options[:step_averaging]
28
30
  @tick_size = options[:tick_size]
29
31
  @timer = options[:timer]
32
+ @pump_detector = options[:pump_detector]
30
33
  end
31
34
 
32
35
  def self.current_coins(account, trade_params)
@@ -46,6 +49,7 @@ module Abot
46
49
  step_averaging: coin['stepAveraging'].to_f,
47
50
  tick_size: coin['tickSize'],
48
51
  timer: coin['timer'].to_s[0..9],
52
+ pump_detector: coin['pumpDetector'],
49
53
  )
50
54
  end
51
55
  end
@@ -74,6 +78,10 @@ module Abot
74
78
  @percent_to_order ||= ((sell_price / current_price - 1) * 100)
75
79
  end
76
80
 
81
+ def percent_from_order
82
+ @percent_from_order ||= ((1 - current_price / sell_price) * 100)
83
+ end
84
+
77
85
  def percent_from_min_to_average
78
86
  @percent_to_min ||= ((min_price / next_average_price - 1) * 100)
79
87
  end
@@ -82,6 +90,10 @@ module Abot
82
90
  @percent_to_max ||= ((sell_price / max_price - 1) * 100)
83
91
  end
84
92
 
93
+ def percent_from_max
94
+ @percent_from_max ||= ((1 - max_price / sell_price) * 100)
95
+ end
96
+
85
97
  def min_price
86
98
  @min_price ||= account.symbol_min_price(symbol)
87
99
  end
@@ -25,7 +25,7 @@ module Abot
25
25
  end
26
26
 
27
27
  def data_daily_profit
28
- BASE_CONNECTION.execute("SELECT quote, sum(profit) FROM daily_profit GROUP BY quote")
28
+ BASE_CONNECTION.execute("SELECT quote, sum(profit) as sum, count(*) as count FROM daily_profit GROUP BY quote")
29
29
  end
30
30
  end
31
31
  end
@@ -5,6 +5,8 @@ module Abot
5
5
  class Coin
6
6
  module CoinDecorator
7
7
  def decorated_sell_up
8
+ return '-' if sell_up == Float::INFINITY
9
+
8
10
  rounded_sell_up = sell_up.round(2)
9
11
  case num_averaging
10
12
  when 1, 2
@@ -38,7 +40,7 @@ module Abot
38
40
  end
39
41
 
40
42
  def decorated_next_average_price
41
- "#{next_average_price} (#{decorated_next_average_price_percent})"
43
+ next_average_price.zero? ? '-' : "#{next_average_price} (#{decorated_next_average_price_percent})"
42
44
  end
43
45
 
44
46
  def decorated_name
@@ -49,11 +51,12 @@ module Abot
49
51
  else
50
52
  ''
51
53
  end
52
- "#{name}(#{account.symbol_info(symbol).try(:[], :priceChangePercent)}%)#{arrow}"
54
+ "#{decorated_name_mobile} (#{account.symbol_info(symbol).try(:[], :priceChangePercent)}%)#{arrow}"
53
55
  end
54
56
 
55
57
  def decorated_name_mobile
56
- name
58
+ pump_det = pump_detector == 'True' ? '👁 ' : ''
59
+ "#{pump_det}#{name}"
57
60
  end
58
61
 
59
62
  def decorated_sell_price
@@ -64,6 +67,10 @@ module Abot
64
67
  "#{current_price} (#{percent_to_order.round(2)}%)"
65
68
  end
66
69
 
70
+ def decorated_current_price_perc_of_order
71
+ "#{current_price} (#{percent_from_order.round(2)}%)"
72
+ end
73
+
67
74
  def decorated_min_price
68
75
  "#{min_price} (#{percent_from_min_to_average.round(2)}%)"
69
76
  end
@@ -72,6 +79,10 @@ module Abot
72
79
  "#{max_price} (#{percent_to_max.round(2)}%)"
73
80
  end
74
81
 
82
+ def decorated_max_price_perc_of_order
83
+ "#{max_price} (#{percent_from_max.round(2)}%)"
84
+ end
85
+
75
86
  def decorated_current_quote
76
87
  current_quote.round(2)
77
88
  end
@@ -85,16 +96,22 @@ module Abot
85
96
  end
86
97
 
87
98
  def decorated_buy_date
88
- Time.at(timer.to_s[0..9].to_f).strftime('%d %h %H:%M')
99
+ sec = timer.to_s[0..9].to_f
100
+ return '-' if sec < 1_577_836_800 # 2020-01-01 00:00:00 +0000
101
+
102
+ Time.at(sec).strftime('%d %h %H:%M')
89
103
  rescue StandardError
90
104
  '-'
91
105
  end
92
106
 
93
107
  def decorated_timer
94
- medidas = ["г", "мес", "д", "ч", "м", "c"]
108
+ sec = timer.to_s[0..9].to_f
109
+ return '-' if sec < 1_577_836_800 # 2020-01-01 00:00:00 +0000
110
+
111
+ medidas = %w[г мес д ч м c]
95
112
  array = [1970, 1, 1, 0, 0, 0]
96
113
  text = ''
97
- Time.at(Time.now.to_i - timer.to_s[0..9].to_f).utc.to_a.take(6).reverse.each_with_index do |k, i|
114
+ Time.at(Time.now.to_i - sec).utc.to_a.take(6).reverse.each_with_index do |k, i|
98
115
  case i
99
116
  when 0, 1, 2
100
117
  next if text.blank? && (k - array[i]).zero?
@@ -118,6 +135,7 @@ module Abot
118
135
  value = Paint[str, (Helpers::AVERAGE_COLORS[num_averaging] || :red)]
119
136
  row = { value: value }
120
137
  row[:alignment] = :right if name == :timer
138
+ row[:alignment] = :center if name == :buy_date
121
139
  row
122
140
  end
123
141
  end
@@ -12,13 +12,15 @@ module Abot
12
12
  magenta
13
13
  ].freeze
14
14
 
15
- def self.daily_profit_str
15
+ def self.today_info_str
16
16
  profit = 'Профит сегодня:'
17
+ transactions_count = 'Сделок '
17
18
  DatabaseTable.data_daily_profit.each do |c|
18
19
  tick_size = (c['quote'] == 'BTC' ? 7 : 2)
19
- profit += Paint[" #{c['sum(profit)'].round(tick_size)} #{c['quote']};", :green]
20
+ profit += "#{Paint[" #{c['sum'].round(tick_size)} #{c['quote']}", :green]};"
21
+ transactions_count += "#{c['quote']}: #{Paint[c['count'], :green]}; "
20
22
  end
21
- profit
23
+ "#{profit} #{transactions_count}"
22
24
  end
23
25
 
24
26
  def self.balance_str(account, current_coins, trade_params)
@@ -58,6 +60,13 @@ module Abot
58
60
  def self.check_abot
59
61
  Paint['WARNING: ПРОВЕРЬТЕ БОТА !!!', :black, :red] + "\n" if (Time.now - File.mtime(DatabaseTable::DB_PATH)) > 10
60
62
  end
63
+
64
+ def self.check_coins(account, quote_assets)
65
+ coins_without_order = account.coins_without_order(quote_assets)
66
+ if coins_without_order.present?
67
+ Paint["Монеты без ордера: #{coins_without_order.join(', ')}", :black, :red] + "\n"
68
+ end
69
+ end
61
70
  end
62
71
  end
63
72
  end
@@ -22,6 +22,8 @@ module Abot
22
22
  potential_profit: "Пот.\nпрофит",
23
23
  buy_date: "Дата покупки",
24
24
  timer: 'Время',
25
+ current_price_perc_of_order: 'Тек.цена',
26
+ max_price_perc_of_order: 'Максимум 24h',
25
27
  }.freeze
26
28
  HEADINGS_COINS_TABLE_DEFAULT = %i[
27
29
  name
@@ -95,11 +97,12 @@ module Abot
95
97
  end
96
98
 
97
99
  def info_str
100
+ "#{Helpers.check_coins(account, trade_params["quote_asset"].split(' '))}" \
98
101
  "#{Helpers.check_abot}" \
99
- "#{Helpers.daily_profit_str}\n" \
100
- "#{Helpers.balance_str(account, current_coins, trade_params)}\n" \
101
- "#{Helpers.potential_balance_str(account, current_coins, trade_params)}\n" \
102
- "#{rate_coins_str}"
102
+ "#{Helpers.today_info_str}\n" \
103
+ "#{Helpers.balance_str(account, current_coins, trade_params)}\n" \
104
+ "#{Helpers.potential_balance_str(account, current_coins, trade_params)}\n" \
105
+ "#{rate_coins_str}"
103
106
  end
104
107
 
105
108
  def rate_coins_str
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Abot
4
4
  module Info
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abot-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - w_dmitrii
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-20 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler