cns 2.1.9 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5e34a759d5a3dc566f918d6e0822311511ef817a26b4f5cda3792129306e2d9
4
- data.tar.gz: 31748b2db5858844b87ae861ba7353a58c07bb5d3ab71e452257a8f731ce33cc
3
+ metadata.gz: 35cbb3480d93201fac4d588ef04df6a57f4e487d911f6ebd01f4c629c6701287
4
+ data.tar.gz: e1f7387b9cb172028410c3a3d1f358787374d3a24fceb84214808a62fc596922
5
5
  SHA512:
6
- metadata.gz: 9eba36bdb69b39ebe7e87dd42860d05ce72fb47cf0ff9ad164e387cf8ca4ea7cb138f840cd956a9591b8c0daf74c3ee9042b8c652ce3d64930425c9904955630
7
- data.tar.gz: d77d6f77d9754994e3282e21c0394389644ba5df1f54e83f4548dbf820128b434a404a8dc08a72661df8fcdc7b79620937ffad941ad8e96510309cc080326351
6
+ metadata.gz: 56adc131c7198a2496dec57d3781f930465ce0ab06cc4895b3853673906e19dcee6b992026dc87c43158e1276b4266c2684487cb18dc95b78a3a91032289af19
7
+ data.tar.gz: f9f29e2b1f086a3de056126d873fd48c5e960ce0e2f9f5f17b98eb408af5c478bf3b4b2120ce2abcc046e4d728c3d76af2b93f00879a737f98ae80684f9d82a5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cns (2.1.9)
4
+ cns (2.2.0)
5
5
  curb
6
6
  faraday
7
7
  faraday-retry
@@ -119,7 +119,7 @@ GEM
119
119
  os (1.1.4)
120
120
  ostruct (0.6.3)
121
121
  parallel (1.27.0)
122
- parser (3.3.10.1)
122
+ parser (3.3.10.2)
123
123
  ast (~> 2.4.1)
124
124
  racc
125
125
  prism (1.9.0)
@@ -141,7 +141,7 @@ GEM
141
141
  declarative (< 0.1.0)
142
142
  trailblazer-option (>= 0.1.1, < 0.2.0)
143
143
  uber (< 0.2.0)
144
- retriable (3.1.2)
144
+ retriable (3.2.1)
145
145
  reverse_markdown (3.0.2)
146
146
  nokogiri
147
147
  rexml (3.4.4)
@@ -205,7 +205,7 @@ GEM
205
205
  yard (>= 0.8)
206
206
  yard-solargraph (0.1.0)
207
207
  yard (~> 0.9)
208
- zeitwerk (2.7.4)
208
+ zeitwerk (2.7.5)
209
209
 
210
210
  PLATFORMS
211
211
  x86_64-linux
data/lib/cns/apice.rb CHANGED
@@ -10,6 +10,7 @@ module Cns
10
10
  # classe para acesso dados centralized exchanges
11
11
  class Apice
12
12
  API = {de: 'https://api.bitcoin.de/v4', us: 'https://api.kraken.com/0/private'}.freeze
13
+ MDE = %w[btc eth].freeze
13
14
 
14
15
  def initialize
15
16
  @curl =
@@ -50,15 +51,21 @@ module Cns
50
51
  # Get deposits from Bitcoin.de, uniformly formatted
51
52
  # @return [Array<Hash>] depositos uniformizados bitcoinde
52
53
  def deposits_de
53
- pag_de_req("#{API[:de]}/btc/deposits", {}, :deposits) { |i| i.map { |h| deposit_unif(h) } }
54
+ MDE.flat_map do |cry|
55
+ pag_de_req("#{API[:de]}/#{cry}/deposits", {}, :deposits) { |i| i.map { |h| deposit_unif(h, cry.upcase) } }
56
+ end
57
+ # pag_de_req("#{API[:de]}/btc/deposits", {}, :deposits) { |i| i.map { |h| deposit_unif(h) } }
54
58
  rescue Curl::Err::CurlError
55
59
  []
56
60
  end
57
61
 
58
62
  # Get withdrawals from Bitcoin.de, uniformly formatted
59
63
  # @return [Array<Hash>] withdrawals uniformizadas bitcoinde
60
- def withdrawals_de(tsp = nil)
61
- pag_de_req("#{API[:de]}/btc/withdrawals", {}, :withdrawals) { |i| i.map { |h| withdrawal_unif(h) } }
64
+ def withdrawals_de
65
+ MDE.flat_map do |cry|
66
+ pag_de_req("#{API[:de]}/#{cry}/withdrawals", {}, :withdrawals) { |i| i.map { |h| withdrawal_unif(h, cry.upcase) } }
67
+ end
68
+ # pag_de_req("#{API[:de]}/btc/withdrawals", {}, :withdrawals) { |i| i.map { |h| withdrawal_unif(h) } }
62
69
  rescue Curl::Err::CurlError
63
70
  []
64
71
  end
@@ -201,15 +208,17 @@ module Cns
201
208
 
202
209
  # Uniformly format a deposit from Bitcoin.de
203
210
  # @param [Hash] has Deposit data from Bitcoin.de
211
+ # @param [String] moe Currency code (e.g., 'BTC', 'ETH')
204
212
  # @return [Hash] deposito uniformizado bitcoinde
205
- def deposit_unif(has)
206
- {add: has[:address], time: Time.parse(has[:created_at]), qtd: has[:amount].to_d, nxid: has[:deposit_id].to_i}.merge(tp: 'deposit', moe: 'BTC', fee: 0.to_d)
213
+ def deposit_unif(has, moe)
214
+ {add: has[:address], time: Time.parse(has[:created_at]), qtd: has[:amount].to_d, nxid: has[:deposit_id].to_i}.merge(tp: 'deposit', moe: moe, fee: 0.to_d)
207
215
  end
208
216
 
209
217
  # Uniformly format a withdrawal from Bitcoin.de
210
218
  # @param [Hash] has Withdrawal data from Bitcoin.de
219
+ # @param [String] moe Currency code (e.g., 'BTC', 'ETH')
211
220
  # @return [Hash] withdrawal uniformizada bitcoinde
212
- def withdrawal_unif(has)
221
+ def withdrawal_unif(has, moe)
213
222
  {
214
223
  add: has[:address],
215
224
  time: Time.parse(has[:transferred_at]),
@@ -217,7 +226,7 @@ module Cns
217
226
  fee: has[:network_fee].to_d,
218
227
  nxid: has[:withdrawal_id].to_i,
219
228
  tp: 'withdrawal',
220
- moe: 'BTC'
229
+ moe: moe
221
230
  }
222
231
  end
223
232
 
data/lib/cns/bigquery.rb CHANGED
@@ -252,7 +252,7 @@ module Cns
252
252
  kys.map do |k|
253
253
  case k
254
254
  when :amount, :btc, :cost, :fee, :gas, :gasPrice, :gasUsed, :margin, :price, :quantity, :value, :vol, :eur, :blockReward, :qtd then fnm(hsh[k])
255
- when :blockNumber, :timeStamp, :nonce, :transactionIndex, :isError, :txreceipt_status, :tokenDecimal, :withdrawalIndex, :validatorIndex then fin(hsh[k])
255
+ when :blockNumber, :timeStamp, :nonce, :transactionIndex, :isError, :txreceipt_status, :tokenDecimal, :withdrawalIndex, :validatorIndex, :nxid then fin(hsh[k])
256
256
  when :block_time, :successfully_finished_at, :time, :trade_marked_as_paid_at then fts(hsh[k])
257
257
  when :memo, :input, :misc then fqe(hsh[k])
258
258
  else fqt(hsh[k])
data/lib/cns/bitcoinde.rb CHANGED
@@ -51,7 +51,7 @@ module Cns
51
51
  def mtrades
52
52
  return unless ops[:v] && novxt.any?
53
53
 
54
- puts("\ntrades data hora dt criacao tipo par btc eur")
54
+ puts("\ntrades data hora dt criacao tipo crypto eur")
55
55
  novxt.sort_by { |i| -i[:srx] }.each { |o| puts(fot(o)) }
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ module Cns
59
59
  def mledger
60
60
  return unless ops[:v] && novxl.any?
61
61
 
62
- puts("\nledger data hora tipo moe quantidade custo")
62
+ puts("\nledger data hora tipo moe crypto custo")
63
63
  novxl.sort_by { |i| -i[:srx] }.each { |o| puts(fol(o)) }
64
64
  end
65
65
 
@@ -82,12 +82,11 @@ module Cns
82
82
  # @return [String] texto formatado trade
83
83
  def fot(htx)
84
84
  format(
85
- '%<ky>-6.6s %<dt>19.19s %<dp>10.10s %<ty>-5.5s %<mo>-8.8s %<vl>18.8f %<co>8.2f',
85
+ '%<ky>-6.6s %<dt>19.19s %<dp>10.10s %<ty>-8.8s %<vl>18.8f %<co>14.2f',
86
86
  ky: htx[:trade_id],
87
- dt: htx[:successfully_finished_at].strftime('%F %T'),
88
- dp: htx[:trade_marked_as_paid_at].strftime('%F'),
87
+ dt: htx[:successfully_finished_at]&.strftime('%F %T'),
88
+ dp: htx[:trade_marked_as_paid_at]&.strftime('%F'),
89
89
  ty: htx[:type],
90
- mo: htx[:trading_pair],
91
90
  vl: htx[:btc],
92
91
  co: htx[:eur]
93
92
  )
@@ -138,9 +137,9 @@ module Cns
138
137
  pdes(:successfully_finished_at, t).merge(
139
138
  trade_marked_as_paid_at: ptm(t[:trade_marked_as_paid_at]),
140
139
  username: t[:trading_partner_information][:username],
141
- btc: t[:type] == 'buy' ? t[:amount_currency_to_trade_after_fee].to_d : -1 * t[:amount_currency_to_trade].to_d,
142
- eur: t[:volume_currency_to_pay_after_fee].to_d,
143
- trading_pair: t[:trading_pair].upcase
140
+ type: "#{t[:trading_pair][0..2]}#{t[:type]}",
141
+ btc: t[:type] == 'buy' ? t[:amount_currency_to_trade_after_fee].to_d : t[:amount_currency_to_trade].to_d * -1,
142
+ eur: t[:volume_currency_to_pay_after_fee].to_d
144
143
  )
145
144
  end
146
145
  end
data/lib/cns/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cns
4
- VERSION = '2.1.9'
4
+ VERSION = '2.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cns
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.9
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz