abot-info 0.1.2 → 0.2.2

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: d3b9aeef83407bb23ab6b32e573f11ce4b057f317154f4394feb126bc37abd6f
4
- data.tar.gz: 4bf3c572f8efd5e92b13ace3ac581297119b11c6499ee868b7375746a1d28f67
3
+ metadata.gz: 53b632907a5efa4f5fd0df0e72636e8e6a2aba46df4f4f2a991a60dbd5e1677c
4
+ data.tar.gz: 8fec3a06980da4bb3b738c1e6945f30862956469465cb72478832164a40534e2
5
5
  SHA512:
6
- metadata.gz: d01c954849a411dd94f1817d41237854d873aed81cbd2f9348c5fced45ab5dcab3a0422c23a6dd4f7819a42f24ad33225a817ebb3e71185025ad814f00a3a0df
7
- data.tar.gz: 8cd4eb38ad00c13ee38e68f69acf849b880dd82aebc0505b380f86a88a6888d413c4553b44d4d1c1a6cb8584f66a5f5f1fa2b795e49547856f6efbfdb2d104b9
6
+ metadata.gz: 8e883e2cb07ee6d3d27ec393a1c8bc5fba77571e8fce0967c97ed0555d85ceaa261608e7f6c06e01c7b1020c90413e92028c6d50c955badc678962d570b3e1c6
7
+ data.tar.gz: 59d64fbed8a638e94e19a7958c554c7e1830bf18308fb379657fc594122c60a1b9093656f48756974cf843066148c2f12e29de6c2306f63b19ed483f67cb018b
data/lib/abot/info.rb CHANGED
@@ -43,7 +43,6 @@ module Abot
43
43
  " timer: Время с покупки\n" \
44
44
  " current_profit: Текущая прибыль\n" \
45
45
  " potential_profit: Потенциальная прибыль\n",
46
- " potential_profit: Потенциальная прибыль\n",
47
46
  " current_price_perc_of_order: Текущая цена (подсчет процента от ордера за продажу)\n" \
48
47
  " max_price_perc_of_order: Максимальная цена за 24ч (подсчет процента от ордера за продажу)\n" \
49
48
  )
@@ -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
@@ -10,7 +10,8 @@ module Abot
10
10
  attr_reader :base_asset, :quote_asset, :average_price, :current_price, :sell_price, :volume, :num_averaging,
11
11
  :total_quote, :buy_price, :step_averaging, :tick_size, :account, :timer, :trade_params
12
12
 
13
- FIAT = ['USDT', 'BUSD', 'AUD', 'BIDR', 'BRL', 'EUR', 'GBR', 'RUB', 'TRY', 'TUSD', 'USDC', 'DAI', 'IDRT', 'PAX', 'UAH', 'NGN', 'VAI', 'BVND']
13
+ FIAT = %w[USDT BUSD AUD BIDR BRL EUR GBR RUB TRY TUSD USDC DAI IDRT PAX UAH NGN VAI BVND]
14
+
14
15
 
15
16
  def initialize(options = {})
16
17
  @trade_params = options[:trade_params]
@@ -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,7 +51,7 @@ module Abot
49
51
  else
50
52
  ''
51
53
  end
52
- "#{name}(#{account.symbol_info(symbol).try(:[], :priceChangePercent)}%)#{arrow}"
54
+ "#{name} (#{account.symbol_info(symbol).try(:[], :priceChangePercent)}%)#{arrow}"
53
55
  end
54
56
 
55
57
  def decorated_name_mobile
@@ -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
@@ -97,11 +97,12 @@ module Abot
97
97
  end
98
98
 
99
99
  def info_str
100
+ "#{Helpers.check_coins(account, trade_params["quote_asset"].split(' '))}" \
100
101
  "#{Helpers.check_abot}" \
101
- "#{Helpers.daily_profit_str}\n" \
102
- "#{Helpers.balance_str(account, current_coins, trade_params)}\n" \
103
- "#{Helpers.potential_balance_str(account, current_coins, trade_params)}\n" \
104
- "#{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}"
105
106
  end
106
107
 
107
108
  def rate_coins_str
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Abot
4
4
  module Info
5
- VERSION = '0.1.2'
5
+ VERSION = '0.2.2'
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.2
4
+ version: 0.2.2
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-21 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