cns 0.1.5 → 0.1.6

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.
@@ -27,25 +27,25 @@ module Cns
27
27
 
28
28
  # @return [Array<Hash>] lista trades bitcoinde novos
29
29
  def trades
30
- @trades ||= exd[:tt].select { |h| kyt.include?(h[:trade_id]) }
30
+ @trades ||= exd[:tt].select { |obj| kyt.include?(obj[:trade_id]) }
31
31
  end
32
32
 
33
33
  # @return [Array<Hash>] lista ledger (deposits + withdrawals) bitcoinde novos
34
34
  def ledger
35
- @ledger ||= exd[:tl].select { |h| kyl.include?(h[:txid]) }
35
+ @ledger ||= exd[:tl].select { |obj| kyl.include?(obj[:txid]) }
36
36
  end
37
37
 
38
38
  # @return [String] texto saldos & transacoes & ajuste dias
39
39
  def mostra_resumo
40
40
  puts("\nBITCOINDE\ntipo bitcoinde bigquery")
41
- exd[:sl].each { |k, v| puts(formata_saldos(k, v)) }
41
+ exd[:sl].each { |key, val| puts(formata_saldos(key, val)) }
42
42
  mostra_totais
43
43
 
44
44
  mostra_trades
45
45
  mostra_ledger
46
46
  return if trades.empty?
47
47
 
48
- puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |e| "#{e}:0" }.join(' ')}")
48
+ puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |obj| "#{obj}:0" }.join(' ')}")
49
49
  end
50
50
 
51
51
  # @return [Hash] dados exchange bitcoinde - saldos & trades & deposits & withdrawals
@@ -59,12 +59,12 @@ module Cns
59
59
 
60
60
  # @return [Array<String>] lista txid dos trades novos
61
61
  def kyt
62
- @kyt ||= exd[:tt].map { |h| h[:trade_id] }.flatten - (ops[:t] ? [] : bqd[:nt].map { |e| e[:txid] })
62
+ @kyt ||= exd[:tt].map { |oex| oex[:trade_id] }.flatten - (ops[:t] ? [] : bqd[:nt].map { |obq| obq[:txid] })
63
63
  end
64
64
 
65
65
  # @return [Array<Integer>] lista txid dos ledger novos
66
66
  def kyl
67
- @kyl ||= exd[:tl].map { |h| h[:txid] }.flatten - (ops[:t] ? [] : bqd[:nl].map { |e| e[:txid] })
67
+ @kyl ||= exd[:tl].map { |oex| oex[:txid] }.flatten - (ops[:t] ? [] : bqd[:nl].map { |obq| obq[:txid] })
68
68
  end
69
69
 
70
70
  # @example (see Apice#account_de)
@@ -72,14 +72,14 @@ module Cns
72
72
  # @param [Hash] hsx saldo bitcoinde da moeda
73
73
  # @return [String] texto formatado saldos
74
74
  def formata_saldos(moe, hsx)
75
- b = bqd[:sl][moe.downcase.to_sym].to_d
76
- e = hsx[:total_amount].to_d
75
+ vbq = bqd[:sl][moe.downcase.to_sym].to_d
76
+ vex = hsx[:total_amount].to_d
77
77
  format(
78
78
  '%<mo>-5.5s %<ex>21.9f %<bq>21.9f %<ok>3.3s',
79
79
  mo: moe.upcase,
80
- ex: e,
81
- bq: b,
82
- ok: e == b ? 'OK' : 'NOK'
80
+ ex: vex,
81
+ bq: vbq,
82
+ ok: vex == vbq ? 'OK' : 'NOK'
83
83
  )
84
84
  end
85
85
 
@@ -117,13 +117,13 @@ module Cns
117
117
 
118
118
  # @return [String] texto numero de transacoes
119
119
  def mostra_totais
120
- a = exd[:tt].count
121
- b = bqd[:nt].count
122
- c = exd[:tl].count
123
- d = bqd[:nl].count
120
+ vtt = exd[:tt].count
121
+ vnt = bqd[:nt].count
122
+ vtl = exd[:tl].count
123
+ vnl = bqd[:nl].count
124
124
 
125
- puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: a, b: b, o: a == b ? 'OK' : 'NOK')}")
126
- puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: c, d: d, o: c == d ? 'OK' : 'NOK')}")
125
+ puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: vtt, b: vnt, o: vtt == vnt ? 'OK' : 'NOK')}")
126
+ puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: vtl, d: vnl, o: vtl == vnl ? 'OK' : 'NOK')}")
127
127
  end
128
128
 
129
129
  # @return [String] texto transacoes trades
@@ -131,8 +131,9 @@ module Cns
131
131
  return unless ops[:v] && !trades.empty?
132
132
 
133
133
  puts("\ntrades data hora dt criacao tipo par qtd eur")
134
- trades.sort { |a, b| Time.parse(b[:successfully_finished_at]) <=> Time.parse(a[:successfully_finished_at]) }
135
- .each { |h| puts(formata_trades(h)) }
134
+ trades
135
+ .sort { |ant, prx| Time.parse(prx[:successfully_finished_at]) <=> Time.parse(ant[:successfully_finished_at]) }
136
+ .each { |obj| puts(formata_trades(obj)) }
136
137
  end
137
138
 
138
139
  # @return [String] texto transacoes ledger
@@ -140,7 +141,7 @@ module Cns
140
141
  return unless ops[:v] && !ledger.empty?
141
142
 
142
143
  puts("\nledger data hora tipo moe quantidade custo")
143
- ledger.sort { |a, b| b[:time] <=> a[:time] }.each { |h| puts(formata_ledger(h)) }
144
+ ledger.sort { |ant, prx| prx[:time] <=> ant[:time] }.each { |obj| puts(formata_ledger(obj)) }
144
145
  end
145
146
  end
146
147
  end
@@ -29,49 +29,51 @@ module Cns
29
29
 
30
30
  # @return [Array<Hash>] lista transacoes normais novas
31
31
  def novtx
32
- @novtx ||= bcd.map { |e| e[:tx].select { |n| idt.include?(n[:itx]) } }.flatten
32
+ @novtx ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten
33
33
  end
34
34
 
35
35
  # @return [Array<Hash>] lista transacoes token novas
36
36
  def novkx
37
- @novkx ||= bcd.map { |e| e[:kx].select { |n| idk.include?(n[:itx]) } }.flatten
37
+ @novkx ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten
38
38
  end
39
39
 
40
40
  # @return [Array<String>] lista dos meus enderecos
41
41
  def lax
42
- @lax ||= bqd[:wb].map { |h| h[:ax] }
42
+ @lax ||= bqd[:wb].map { |obj| obj[:ax] }
43
43
  end
44
44
 
45
45
  # @return [Array<Hash>] todos os dados etherscan - saldos & transacoes
46
46
  def bcd
47
- @bcd ||= api.account_es(lax).map { |e| base_bc(e) }
47
+ @bcd ||= api.account_es(lax).map { |obj| base_bc(obj) }
48
48
  end
49
49
 
50
50
  # @return [Array<Hash>] todos os dados juntos bigquery & etherscan
51
51
  def dados
52
- @dados ||= bqd[:wb].map { |b| bq_bc(b, bcd.select { |s| b[:ax] == s[:ax] }.first) }
52
+ @dados ||= bqd[:wb].map { |obq| bq_bc(obq, bcd.select { |obc| obq[:ax] == obc[:ax] }.first) }
53
53
  end
54
54
 
55
55
  # @return [Array<Integer>] lista indices transacoes normais novas
56
56
  def idt
57
- @idt ||= (bcd.map { |e| e[:tx].map { |n| n[:itx] } }.flatten - (ops[:t] ? [] : bqd[:nt].map { |t| t[:itx] }))
57
+ @idt ||= bcd.map { |obc| obc[:tx].map { |obj| obj[:itx] } }.flatten -
58
+ (ops[:t] ? [] : bqd[:nt].map { |obq| obq[:itx] })
58
59
  end
59
60
 
60
61
  # @return [Array<Integer>] lista indices transacoes token novas
61
62
  def idk
62
- @idk ||= (bcd.map { |e| e[:kx].map { |n| n[:itx] } }.flatten - (ops[:t] ? [] : bqd[:nk].map { |t| t[:itx] }))
63
+ @idk ||= bcd.map { |obc| obc[:kx].map { |obj| obj[:itx] } }.flatten -
64
+ (ops[:t] ? [] : bqd[:nk].map { |obq| obq[:itx] })
63
65
  end
64
66
 
65
67
  # @example (see Apibc#account_es)
66
68
  # @param [Hash] abc account etherscan
67
69
  # @return [Hash] dados etherscan - address, saldo & transacoes
68
70
  def base_bc(abc)
69
- a = abc[:account]
71
+ acc = abc[:account]
70
72
  {
71
- ax: a,
73
+ ax: acc,
72
74
  sl: (abc[:balance].to_d / 10**18).round(10),
73
- tx: filtrar_tx(a, api.norml_es(a)),
74
- kx: filtrar_tx(a, api.token_es(a))
75
+ tx: filtrar_tx(acc, api.norml_es(acc)),
76
+ kx: filtrar_tx(acc, api.token_es(acc))
75
77
  }
76
78
  end
77
79
 
@@ -81,10 +83,10 @@ module Cns
81
83
  def bq_bc(wbq, hbc)
82
84
  {
83
85
  id: wbq[:id],
84
- ax: wbq[:ax],
86
+ ax: xbq = wbq[:ax],
85
87
  bs: wbq[:sl],
86
- bt: bqd[:nt].select { |t| t[:iax] == wbq[:ax] },
87
- bk: bqd[:nk].select { |t| t[:iax] == wbq[:ax] },
88
+ bt: bqd[:nt].select { |ont| ont[:iax] == xbq },
89
+ bk: bqd[:nk].select { |onk| onk[:iax] == xbq },
88
90
  es: hbc[:sl],
89
91
  et: hbc[:tx],
90
92
  ek: hbc[:kx]
@@ -97,23 +99,23 @@ module Cns
97
99
  def filtrar_tx(add, ary)
98
100
  # elimina transferencia from: (lax) to: (add) - esta transferencia aparece em from: (add) to: (lax)
99
101
  # elimina chaves irrelevantes (DL) & adiciona chave indice itx & adiciona identificador da carteira iax
100
- ary.delete_if { |h| h[:to] == add && lax.include?(h[:from]) }
101
- .map { |h| h.delete_if { |k, _| DL.include?(k) }.merge(itx: Integer(h[:blockNumber]), iax: add) }
102
+ ary.delete_if { |odl| odl[:to] == add && lax.include?(odl[:from]) }
103
+ .map { |omp| omp.delete_if { |key, _| DL.include?(key) }.merge(itx: Integer(omp[:blockNumber]), iax: add) }
102
104
  end
103
105
 
104
106
  # @return [Array<Hash>] lista ordenada transacoes normais novas
105
107
  def sortx
106
- novtx.sort { |a, b| a[:itx] <=> b[:itx] }
108
+ novtx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
107
109
  end
108
110
 
109
111
  # @return [Array<Hash>] lista ordenada transacoes token novas
110
112
  def sorkx
111
- novkx.sort { |a, b| a[:itx] <=> b[:itx] }
113
+ novkx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
112
114
  end
113
115
 
114
116
  # @return [Array<Hash>] lista ordenada transacoes (normais & token) novas
115
117
  def sorax
116
- (novtx + novkx).sort { |a, b| a[:itx] <=> b[:itx] }
118
+ (novtx + novkx).sort { |ant, prx| ant[:itx] <=> prx[:itx] }
117
119
  end
118
120
  end
119
121
  end
@@ -9,7 +9,7 @@ module Cns
9
9
  return unless dados.count.positive?
10
10
 
11
11
  puts("\nid address etherscan nm tk bigquery nm tk")
12
- dados.each { |e| puts(formata_carteira(e)) }
12
+ dados.each { |obj| puts(formata_carteira(obj)) }
13
13
  mostra_transacao_norml
14
14
  mostra_transacao_token
15
15
  mostra_configuracao_ajuste_dias
@@ -52,9 +52,9 @@ module Cns
52
52
  # @param [Integer] max chars a mostrar
53
53
  # @return [String] endereco formatado
54
54
  def formata_endereco(add, max)
55
- i = Integer((max - 2) / 2)
56
- e = (max <= 20 ? bqd[:wb].select { |s| s[:ax] == add }.first : nil) || { id: add }
57
- max < 7 ? 'erro' : "#{e[:id][0, i - 3]}..#{add[-i - 3..]}"
55
+ int = Integer((max - 2) / 2)
56
+ hid = (max <= 20 ? bqd[:wb].select { |obj| obj[:ax] == add }.first : nil) || { id: add }
57
+ max < 7 ? 'erro' : "#{hid[:id][0, int - 3]}..#{add[-int - 3..]}"
58
58
  end
59
59
 
60
60
  # @example (see Apibc#norml_es)
@@ -91,7 +91,7 @@ module Cns
91
91
  return unless ops[:v] && novtx.count.positive?
92
92
 
93
93
  puts("\ntx normal from to data valor")
94
- sortx.each { |e| puts(formata_transacao_norml(e)) }
94
+ sortx.each { |obj| puts(formata_transacao_norml(obj)) }
95
95
  end
96
96
 
97
97
  # @return [String] texto transacoes token
@@ -99,14 +99,14 @@ module Cns
99
99
  return unless ops[:v] && novkx.count.positive?
100
100
 
101
101
  puts("\ntx token from to data valor")
102
- sorkx.each { |e| puts(formata_transacao_token(e)) }
102
+ sorkx.each { |obj| puts(formata_transacao_token(obj)) }
103
103
  end
104
104
 
105
105
  # @return [String] texto configuracao ajuste dias das transacoes (normais & token)
106
106
  def mostra_configuracao_ajuste_dias
107
107
  return unless (novtx.count + novkx.count).positive?
108
108
 
109
- puts("\nstring ajuste dias\n-h=#{sorax.map { |e| "#{e[:blockNumber]}:0" }.join(' ')}")
109
+ puts("\nstring ajuste dias\n-h=#{sorax.map { |obj| "#{obj[:blockNumber]}:0" }.join(' ')}")
110
110
  end
111
111
  end
112
112
  end
@@ -27,38 +27,39 @@ module Cns
27
27
 
28
28
  # @return [Array<Hash>] lista transacoes novas
29
29
  def novax
30
- @novax ||= bcd.map { |e| e[:tx].select { |s| idt.include?(s[:itx]) } }.flatten
30
+ @novax ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten
31
31
  end
32
32
 
33
33
  # @return [Array<String>] lista dos meus enderecos
34
34
  def lax
35
- @lax ||= bqd[:wb].map { |h| h[:ax] }
35
+ @lax ||= bqd[:wb].map { |obj| obj[:ax] }
36
36
  end
37
37
 
38
38
  # @return [Array<Hash>] todos os dados greymass - saldos & transacoes
39
39
  def bcd
40
- @bcd ||= bqd[:wb].map { |e| base_bc(e) }
40
+ @bcd ||= bqd[:wb].map { |obj| base_bc(obj) }
41
41
  end
42
42
 
43
43
  # @return [Array<Hash>] todos os dados juntos bigquery & greymass
44
44
  def dados
45
- @dados ||= bqd[:wb].map { |b| bq_bc(b, bcd.select { |s| b[:ax] == s[:ax] }.first) }
45
+ @dados ||= bqd[:wb].map { |obq| bq_bc(obq, bcd.select { |obj| obq[:ax] == obj[:ax] }.first) }
46
46
  end
47
47
 
48
48
  # @return [Array<Integer>] lista indices transacoes novas
49
49
  def idt
50
- @idt ||= (bcd.map { |e| e[:tx].map { |n| n[:itx] } }.flatten - (ops[:t] ? [] : bqd[:nt].map { |t| t[:itx] }))
50
+ @idt ||= bcd.map { |obc| obc[:tx].map { |obj| obj[:itx] } }.flatten -
51
+ (ops[:t] ? [] : bqd[:nt].map { |obq| obq[:itx] })
51
52
  end
52
53
 
53
54
  # @example (see Apibc#account_gm)
54
55
  # @param [Hash] wbq wallet bigquery
55
56
  # @return [Hash] dados greymass - address, saldo & transacoes
56
57
  def base_bc(wbq)
57
- a = wbq[:ax]
58
+ xbq = wbq[:ax]
58
59
  {
59
- ax: a,
60
- sl: greymass_sl(a).inject(:+),
61
- tx: filtrar_tx(a, api.ledger_gm(a))
60
+ ax: xbq,
61
+ sl: greymass_sl(xbq).inject(:+),
62
+ tx: filtrar_tx(xbq, api.ledger_gm(xbq))
62
63
  }
63
64
  end
64
65
 
@@ -66,11 +67,12 @@ module Cns
66
67
  # @param [Hash] hbc dados greymass - address, saldo & transacoes
67
68
  # @return [Hash] dados juntos bigquery & greymass
68
69
  def bq_bc(wbq, hbc)
70
+ xbq = wbq[:ax]
69
71
  {
70
72
  id: wbq[:id],
71
- ax: wbq[:ax],
73
+ ax: xbq,
72
74
  bs: wbq[:sl],
73
- bt: bqd[:nt].select { |t| t[:iax] == wbq[:ax] },
75
+ bt: bqd[:nt].select { |obj| obj[:iax] == xbq },
74
76
  es: hbc[:sl],
75
77
  et: hbc[:tx]
76
78
  }
@@ -79,11 +81,12 @@ module Cns
79
81
  # @param (see filtrar_tx)
80
82
  # @return [Array<BigDecimal>] lista recursos - liquido, net, spu
81
83
  def greymass_sl(add)
82
- v = api.account_gm(add)
84
+ hac = api.account_gm(add)
85
+ htr = hac[:total_resources]
83
86
  [
84
- v[:core_liquid_balance].to_d,
85
- v[:total_resources][:net_weight].to_d,
86
- v[:total_resources][:cpu_weight].to_d
87
+ hac[:core_liquid_balance].to_d,
88
+ htr[:net_weight].to_d,
89
+ htr[:cpu_weight].to_d
87
90
  ]
88
91
  end
89
92
 
@@ -93,13 +96,15 @@ module Cns
93
96
  def filtrar_tx(add, ary)
94
97
  # elimina transferencia from: (lax) to: (add) - esta transferencia aparece em from: (add) to: (lax)
95
98
  # adiciona chave indice itx & adiciona identificador da carteira iax
96
- ary.delete_if { |h| act_data(h)[:to] == add && lax.include?(act_data(h)[:from]) }
97
- .map { |h| h.merge(itx: h[:global_action_seq], iax: add) }
99
+ (ary.delete_if do |odl|
100
+ adt = odl[:action_trace][:act][:data]
101
+ adt[:to] == add && lax.include?(adt[:from])
102
+ end).map { |omp| omp.merge(itx: omp[:global_action_seq], iax: add) }
98
103
  end
99
104
 
100
105
  # @return [Array<Hash>] lista ordenada transacoes novas
101
106
  def sorax
102
- novax.sort { |a, b| b[:itx] <=> a[:itx] }
107
+ novax.sort { |ant, prx| prx[:itx] <=> ant[:itx] }
103
108
  end
104
109
  end
105
110
  end
@@ -9,7 +9,7 @@ module Cns
9
9
  return unless dados.count.positive?
10
10
 
11
11
  puts("\naddress greymass ntx bigquery ntx")
12
- dados.each { |e| puts(formata_carteira(e)) }
12
+ dados.each { |obj| puts(formata_carteira(obj)) }
13
13
  mostra_transacoes_novas
14
14
  mostra_configuracao_ajuste_dias
15
15
  end
@@ -40,47 +40,29 @@ module Cns
40
40
  def formata_ledger(hlx)
41
41
  format(
42
42
  '%<bn>12i %<fr>-12.12s %<to>-12.12s %<ac>-10.10s %<dt>10.10s %<vl>12.4f %<sy>-6.6s',
43
+ ac: (act = hlx[:action_trace][:act])[:name],
44
+ fr: (adt = act[:data])[:from],
45
+ vl: (aqt = adt[:quantity].to_s).to_d,
43
46
  bn: hlx[:itx],
44
- fr: act_data(hlx)[:from],
45
- to: act_data(hlx)[:to],
46
- ac: act(hlx)[:name],
47
+ to: adt[:to],
47
48
  dt: Date.parse(hlx[:block_time]),
48
- vl: act_data_quantity(hlx).to_d,
49
- sy: act_data_quantity(hlx)[/[[:upper:]]+/]
49
+ sy: aqt[/[[:upper:]]+/]
50
50
  )
51
51
  end
52
52
 
53
- # @param (see formata_ledger)
54
- # @return [Hash] dados da acao
55
- def act(hlx)
56
- hlx[:action_trace][:act]
57
- end
58
-
59
- # @param (see formata_ledger)
60
- # @return [Hash] dados da acao
61
- def act_data(hlx)
62
- act(hlx)[:data]
63
- end
64
-
65
- # @param (see formata_ledger)
66
- # @return [String] dados da quantidade
67
- def act_data_quantity(hlx)
68
- act_data(hlx)[:quantity].to_s
69
- end
70
-
71
53
  # @return [String] texto transacoes
72
54
  def mostra_transacoes_novas
73
55
  return unless ops[:v] && novax.count.positive?
74
56
 
75
57
  puts("\nsequence num from to accao data valor moeda")
76
- sorax.each { |e| puts(formata_ledger(e)) }
58
+ sorax.each { |obj| puts(formata_ledger(obj)) }
77
59
  end
78
60
 
79
61
  # @return [String] texto configuracao ajuste dias das transacoes
80
62
  def mostra_configuracao_ajuste_dias
81
63
  return unless novax.count.positive?
82
64
 
83
- puts("\nstring ajuste dias\n-h=#{sorax.map { |e| "#{e[:itx]}:0" }.join(' ')}")
65
+ puts("\nstring ajuste dias\n-h=#{sorax.map { |obj| "#{obj[:itx]}:0" }.join(' ')}")
84
66
  end
85
67
  end
86
68
  end
@@ -27,25 +27,25 @@ module Cns
27
27
 
28
28
  # @return [Hash] trades kraken novos
29
29
  def trades
30
- @trades ||= exd[:kt].select { |k, _| kyt.include?(k) }
30
+ @trades ||= exd[:kt].select { |key, _| kyt.include?(key) }
31
31
  end
32
32
 
33
33
  # @return [Hash] ledger kraken novos
34
34
  def ledger
35
- @ledger ||= exd[:kl].select { |k, _| kyl.include?(k) }
35
+ @ledger ||= exd[:kl].select { |key, _| kyl.include?(key) }
36
36
  end
37
37
 
38
38
  # @return [String] texto saldos & transacoes & ajuste dias
39
39
  def mostra_resumo
40
40
  puts("\nKRAKEN\ntipo kraken bigquery")
41
- exd[:sl].each { |k, v| puts(formata_saldos(k, v)) }
41
+ exd[:sl].each { |key, val| puts(formata_saldos(key, val)) }
42
42
  mostra_totais
43
43
 
44
44
  mostra_trades
45
45
  mostra_ledger
46
46
  return if trades.empty?
47
47
 
48
- puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |e| "#{e}:0" }.join(' ')}")
48
+ puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |obj| "#{obj}:0" }.join(' ')}")
49
49
  end
50
50
 
51
51
  # @return [Hash] dados exchange kraken - saldos & transacoes trades e ledger
@@ -59,12 +59,12 @@ module Cns
59
59
 
60
60
  # @return [Array<String>] lista txid dos trades novos
61
61
  def kyt
62
- @kyt ||= exd[:kt].keys - (ops[:t] ? [] : bqd[:nt].map { |e| e[:txid].to_sym })
62
+ @kyt ||= exd[:kt].keys - (ops[:t] ? [] : bqd[:nt].map { |obj| obj[:txid].to_sym })
63
63
  end
64
64
 
65
65
  # @return [Array<String>] lista txid dos ledger novos
66
66
  def kyl
67
- @kyl ||= exd[:kl].keys - (ops[:t] ? [] : bqd[:nl].map { |e| e[:txid].to_sym })
67
+ @kyl ||= exd[:kl].keys - (ops[:t] ? [] : bqd[:nl].map { |obj| obj[:txid].to_sym })
68
68
  end
69
69
 
70
70
  # @example (see Apice#account_us)
@@ -72,13 +72,14 @@ module Cns
72
72
  # @param [BigDecimal] sal saldo kraken da moeda
73
73
  # @return [String] texto formatado saldos
74
74
  def formata_saldos(moe, sal)
75
- t = bqd[:sl][moe.downcase.to_sym].to_d
75
+ vbq = bqd[:sl][moe.downcase.to_sym].to_d
76
+ vsl = sal.to_d
76
77
  format(
77
78
  '%<mo>-5.5s %<kr>21.9f %<bq>21.9f %<ok>3.3s',
78
79
  mo: moe.upcase,
79
- kr: sal.to_d,
80
- bq: t,
81
- ok: t == sal.to_d ? 'OK' : 'NOK'
80
+ kr: vsl,
81
+ bq: vbq,
82
+ ok: vbq == vsl ? 'OK' : 'NOK'
82
83
  )
83
84
  end
84
85
 
@@ -115,29 +116,29 @@ module Cns
115
116
 
116
117
  # @return [String] texto totais numero de transacoes
117
118
  def mostra_totais
118
- a = exd[:kt].count
119
- b = bqd[:nt].count
120
- c = exd[:kl].count
121
- d = bqd[:nl].count
119
+ vkt = exd[:kt].count
120
+ vnt = bqd[:nt].count
121
+ vkl = exd[:kl].count
122
+ vnl = bqd[:nl].count
122
123
 
123
- puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: a, b: b, o: a == b ? 'OK' : 'NOK')}")
124
- puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: c, d: d, o: c == d ? 'OK' : 'NOK')}")
124
+ puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: vkt, b: vnt, o: vkt == vnt ? 'OK' : 'NOK')}")
125
+ puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: vkl, d: vnl, o: vkl == vnl ? 'OK' : 'NOK')}")
125
126
  end
126
127
 
127
128
  # @return [String] texto transacoes trades
128
129
  def mostra_trades
129
130
  return unless ops[:v] && trades.count.positive?
130
131
 
131
- puts("\ntrade data hora tipo par ---preco ---------volume ---custo")
132
- trades.sort { |a, b| b[1][:time] <=> a[1][:time] }.each { |k, v| puts(formata_trades(k, v)) }
132
+ puts("\ntrade data hora tipo par preco volume custo")
133
+ trades.sort { |ant, prx| prx[1][:time] <=> ant[1][:time] }.each { |key, val| puts(formata_trades(key, val)) }
133
134
  end
134
135
 
135
136
  # @return [String] texto transacoes ledger
136
137
  def mostra_ledger
137
138
  return unless ops[:v] && ledger.count.positive?
138
139
 
139
- puts("\nledger data hora tipo moeda -------quantidade -------------custo")
140
- ledger.sort { |a, b| b[1][:time] <=> a[1][:time] }.each { |k, v| puts(formata_ledger(k, v)) }
140
+ puts("\nledger data hora tipo moeda quantidade custo")
141
+ ledger.sort { |ant, prx| prx[1][:time] <=> ant[1][:time] }.each { |key, val| puts(formata_ledger(key, val)) }
141
142
  end
142
143
  end
143
144
  end