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 +4 -4
- data/Gemfile.lock +4 -4
- data/lib/cns/apice.rb +16 -7
- data/lib/cns/bigquery.rb +1 -1
- data/lib/cns/bitcoinde.rb +8 -9
- data/lib/cns/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35cbb3480d93201fac4d588ef04df6a57f4e487d911f6ebd01f4c629c6701287
|
|
4
|
+
data.tar.gz: e1f7387b9cb172028410c3a3d1f358787374d3a24fceb84214808a62fc596922
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
|
61
|
-
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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>-
|
|
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]
|
|
88
|
-
dp: htx[:trade_marked_as_paid_at]
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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