cex 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,151 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @author Hernani Rodrigues Vaz
4
+ module Cex
5
+ # (see Bigquery)
6
+ class Bigquery
7
+ # @return [String] comando insert SQL formatado ust (trades)
8
+ def ust_ins
9
+ "insert #{BD}.ust(txid,ordertxid,pair,time,type,ordertype,price,cost,fee,vol,margin,misc,ledgers,dias) " \
10
+ "VALUES#{apius.trades.map { |k, v| ust_val1(k, v) }.join(',')}"
11
+ end
12
+
13
+ # @return [String] comando insert SQL formatado usl (ledger)
14
+ def usl_ins
15
+ "insert #{BD}.usl(txid,refid,time,type,aclass,asset,amount,fee) " \
16
+ "VALUES#{apius.ledger.map { |k, v| usl_val(k, v) }.join(',')}"
17
+ end
18
+
19
+ # @return [String] comando insert SQL formatado det (trades)
20
+ def det_ins
21
+ "insert #{BD}.det(tp,btc,eur,time,user,id,dtc,dias) VALUES#{apide.trades.map { |h| det_val1(h) }.join(',')}"
22
+ end
23
+
24
+ # @return [String] comando insert SQL formatado del (ledger)
25
+ def del_ins
26
+ "insert #{BD}.del(time,tp,qtxt,id,qt,fee,lgid) VALUES#{apide.ledger.map { |h| del_val(h) }.join(',')}"
27
+ end
28
+
29
+ # @return [String] comando insert SQL formatado fr (ledger)
30
+ def frl_ins
31
+ "insert #{BD}.fr(uuid,tipo,valor,moe,time,dias) VALUES#{apifr.ledger.map { |h| frl_val(h) }.join(',')}"
32
+ end
33
+
34
+ # @return [String] comando insert SQL formatado fr (ledger)
35
+ def mtl_ins
36
+ "insert #{BD}.mt(id,time,type,valor,moe,pair,note,trade_id,dias) " \
37
+ "VALUES#{apimt.ledger.map { |h| mtl_val1(h) }.join(',')}"
38
+ end
39
+
40
+ # @example (see Apide#trades)
41
+ # @param [Hash] htx transacao trade apide
42
+ # @return [String] valores formatados det (trades parte1)
43
+ def det_val1(htx)
44
+ "('#{htx[:type]}'," \
45
+ 'cast(' \
46
+ "#{htx[:type] == 'buy' ? htx[:amount_currency_to_trade_after_fee] : "-#{htx[:amount_currency_to_trade]}"}" \
47
+ ' as numeric),' \
48
+ "cast(#{htx[:volume_currency_to_pay_after_fee]} as numeric)," \
49
+ "DATETIME(TIMESTAMP('#{htx[:successfully_finished_at]}'))," \
50
+ "'#{htx[:trading_partner_information][:username]}'," \
51
+ "#{det_val2(htx)}"
52
+ end
53
+
54
+ # @param (see #det_val1)
55
+ # @return [String] valores formatados det (trades parte2)
56
+ def det_val2(htx)
57
+ "'#{htx[:trade_id]}'," \
58
+ "DATETIME(TIMESTAMP('#{htx[:trade_marked_as_paid_at]}'))," \
59
+ "#{Integer(ops[:h][htx[:trade_id]] || 0)})"
60
+ end
61
+
62
+ # @example (see Apius#trades)
63
+ # @param [String] idx identificador transacao
64
+ # @param [Hash] htx transacao trade apius
65
+ # @return [String] valores formatados ust (trades parte1)
66
+ def ust_val1(idx, htx)
67
+ "('#{idx}'," \
68
+ "'#{htx[:ordertxid]}'," \
69
+ "'#{htx[:pair]}'," \
70
+ "PARSE_DATETIME('%s', '#{String(htx[:time].round)}')," \
71
+ "'#{htx[:type]}'," \
72
+ "'#{htx[:ordertype]}'," \
73
+ "cast(#{htx[:price]} as numeric)," \
74
+ "cast(#{htx[:cost]} as numeric)," \
75
+ "cast(#{htx[:fee]} as numeric)," \
76
+ "#{ust_val2(idx, htx)}"
77
+ end
78
+
79
+ # @param (see #ust_val1)
80
+ # @return [String] valores formatados ust (trades parte2)
81
+ def ust_val2(idx, htx)
82
+ "cast(#{htx[:vol]} as numeric)," \
83
+ "cast(#{htx[:margin]} as numeric)," \
84
+ "#{htx[:misc].to_s.empty? ? 'null' : "'#{htx[:misc]}'"}," \
85
+ "'#{apius.ledger.select { |_, v| v[:refid] == idx }.keys.join(',') || ''}'," \
86
+ "#{Integer(ops[:h][idx] || 0)})"
87
+ end
88
+
89
+ # @example (see Apide#deposit_hash)
90
+ # @example (see Apide#withdrawal_hash)
91
+ # @param [Hash] hlx transacao uniformizada deposits + withdrawals apide
92
+ # @return [String] valores formatados del (ledger)
93
+ def del_val(hlx)
94
+ "(DATETIME(TIMESTAMP('#{hlx[:time].iso8601}'))," \
95
+ "'#{hlx[:tp]}'," \
96
+ "'#{hlx[:qtxt]}'," \
97
+ "'#{hlx[:id]}'," \
98
+ "cast(#{hlx[:tp] == 'out' ? '-' : ''}#{hlx[:qt]} as numeric)," \
99
+ "cast(#{hlx[:fee]} as numeric)," \
100
+ "#{hlx[:lgid]})"
101
+ end
102
+
103
+ # @example (see Apius#ledger)
104
+ # @param idx (see #ust_val1)
105
+ # @param [Hash] hlx transacao ledger apius
106
+ # @return [String] valores formatados usl (ledger)
107
+ def usl_val(idx, hlx)
108
+ "('#{idx}'," \
109
+ "'#{hlx[:refid]}'," \
110
+ "PARSE_DATETIME('%s', '#{String(hlx[:time].round)}')," \
111
+ "'#{hlx[:type]}'," \
112
+ "#{hlx[:aclass].to_s.empty? ? 'null' : "'#{hlx[:aclass]}'"}," \
113
+ "'#{hlx[:asset]}'," \
114
+ "cast(#{hlx[:amount]} as numeric)," \
115
+ "cast(#{hlx[:fee]} as numeric))"
116
+ end
117
+
118
+ # @example (see Apifr#ledger)
119
+ # @param [Hash] hlx transacao ledger apifr
120
+ # @return [String] valores formatados frl (ledger)
121
+ def frl_val(hlx)
122
+ "('#{hlx[:uuid]}'," \
123
+ "'#{hlx[:name]}'," \
124
+ "cast(#{hlx[:amount]} as numeric)," \
125
+ "'#{hlx[:currency]}'," \
126
+ "PARSE_DATETIME('%s', '#{hlx[:created_at_int]}')," \
127
+ "#{Integer(ops[:h][hlx[:uuid]] || 0)})"
128
+ end
129
+
130
+ # @example (see Apimt#ledger)
131
+ # @param [Hash] hlx transacao ledger apimt
132
+ # @return [String] valores formatados mtl (ledger parte1)
133
+ def mtl_val1(hlx)
134
+ "(#{hlx[:id]}," \
135
+ "DATETIME(TIMESTAMP('#{hlx[:date]}'))," \
136
+ "'#{hlx[:type]}'," \
137
+ "cast(#{hlx[:price]} as numeric)," \
138
+ "'#{hlx[:currency]}'," \
139
+ "#{hlx[:fund_id].to_s.empty? ? 'null' : "'#{hlx[:fund_id]}'"}," \
140
+ "#{mtl_val2(hlx)}"
141
+ end
142
+
143
+ # @param hlx (see #mtl_val1)
144
+ # @return [String] valores formatados mtl (ledger parte2)
145
+ def mtl_val2(hlx)
146
+ "#{hlx[:note].to_s.empty? ? 'null' : "'#{hlx[:note]}'"}," \
147
+ "#{hlx[:trade_id].to_s.empty? ? 'null' : (hlx[:trade_id]).to_s}," \
148
+ "#{Integer(ops[:h][String(hlx[:id])] || 0)})"
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('bigdecimal/util')
4
+
5
+ # @author Hernani Rodrigues Vaz
6
+ module Cex
7
+ # classe para processar saldos & transacoes trades e ledger do bitcoinde
8
+ class Bitcoinde
9
+ # @return [Apius] API bitcoinde
10
+ attr_reader :api
11
+ # @return [Array<Hash>] todos os dados bigquery
12
+ attr_reader :dbq
13
+ # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
14
+ attr_reader :ops
15
+
16
+ # @param [Hash] dad todos os dados bigquery
17
+ # @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
18
+ # @option pop [Hash] :h ({}) configuracao dias ajuste reposicionamento temporal
19
+ # @option pop [Boolean] :v (false) mostra dados transacoes trades & ledger?
20
+ # @option pop [Boolean] :t (false) mostra transacoes todas ou somente novas?
21
+ # @return [Bitcoinde] API bitcoinde - obter saldos & transacoes trades e ledger
22
+ def initialize(dad, pop)
23
+ # API bitcoinde base
24
+ @api = Apide.new
25
+ @dbq = dad
26
+ @ops = pop
27
+ end
28
+
29
+ # @return [Hash] dados exchange bitcoinde - saldos & transacoes trades e ledger
30
+ def exd
31
+ @exd ||= {
32
+ sl: api.account,
33
+ tt: api.trades,
34
+ tl: api.deposits + api.withdrawals
35
+ }
36
+ end
37
+
38
+ # @return [Array<String>] lista txid de transacoes trades
39
+ def kyt
40
+ @kyt ||= exd[:tt].map { |h| h[:trade_id] }.flatten - (ops[:t] ? [] : dbq[:nt].map { |e| e[:txid] })
41
+ end
42
+
43
+ # @return [Array<Integer>] lista txid de transacoes ledger
44
+ def kyl
45
+ @kyl ||= exd[:tl].map { |h| h[:lgid] }.flatten - (ops[:t] ? [] : dbq[:nl].map { |e| e[:txid] })
46
+ end
47
+
48
+ # @return [Hash] transacoes trades
49
+ def trades
50
+ @trades ||= exd[:tt].select { |h| kyt.include?(h[:trade_id]) }
51
+ end
52
+
53
+ # @return [Hash] transacoes ledger
54
+ def ledger
55
+ @ledger ||= exd[:tl].select { |h| kyl.include?(h[:lgid]) }
56
+ end
57
+
58
+ # @example (see Apide#account)
59
+ # @param [String] moe codigo bitcoinde da moeda
60
+ # @param [Hash] hsx saldo bitcoinde da moeda
61
+ # @return [String] texto formatado saldos (bitcoinde)
62
+ def formata_saldos(moe, hsx)
63
+ b = dbq[:sl][moe.downcase.to_sym].to_d
64
+ e = hsx[:total_amount].to_d
65
+ format(
66
+ '%<mo>-5.5s %<ex>21.9f %<bq>21.9f %<ok>3.3s',
67
+ mo: moe.upcase,
68
+ ex: e,
69
+ bq: b,
70
+ ok: e == b ? 'OK' : 'NOK'
71
+ )
72
+ end
73
+
74
+ # @example (see Apide#trades)
75
+ # @param (see Bigquery#det_val1)
76
+ # @return [String] texto formatado transacao trade
77
+ def formata_trades(htx)
78
+ format(
79
+ '%<ky>-6.6s %<dt>19.19s %<dp>10.10s %<ty>-5.5s %<mo>-8.8s %<vl>18.8f %<co>8.2f',
80
+ ky: htx[:trade_id],
81
+ dt: Time.parse(htx[:successfully_finished_at]),
82
+ dp: Time.parse(htx[:trade_marked_as_paid_at]),
83
+ ty: htx[:type],
84
+ mo: htx[:trading_pair].upcase,
85
+ vl: htx[:amount_currency_to_trade].to_d,
86
+ co: htx[:volume_currency_to_pay].to_d
87
+ )
88
+ end
89
+
90
+ # @example (see Apide#deposit_hash)
91
+ # @example (see Apide#withdrawal_hash)
92
+ # @param (see Bigquery#del_val)
93
+ # @return [String] texto formatado transacao ledger
94
+ def formata_ledger(hlx)
95
+ format(
96
+ '%<ky>6i %<dt>19.19s %<ty>-10.10s %<mo>-3.3s %<pr>19.8f %<vl>18.8f',
97
+ ky: hlx[:lgid],
98
+ dt: hlx[:time],
99
+ ty: hlx[:tp],
100
+ mo: hlx[:qtxt].upcase,
101
+ pr: hlx[:qt].to_d,
102
+ vl: hlx[:fee].to_d
103
+ )
104
+ end
105
+
106
+ # @return [String] texto saldos & transacoes & ajuste dias
107
+ def mostra_resumo
108
+ puts("\nBITCOINDE\nmoeda saldo bitcoinde saldo bigquery")
109
+ exd[:sl].each { |k, v| puts(formata_saldos(k, v)) }
110
+
111
+ mostra_trades
112
+ mostra_ledger
113
+ return unless trades.count.positive?
114
+
115
+ puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |e| "#{e}:0" }.join(' ')}")
116
+ end
117
+
118
+ # @return [String] texto transacoes trades
119
+ def mostra_trades
120
+ return unless ops[:v] && trades.count.positive?
121
+
122
+ puts("\ntrades data hora dt criacao tipo par ---------------qtd -----eur")
123
+ trades.sort { |a, b| Time.parse(b[:successfully_finished_at]) <=> Time.parse(a[:successfully_finished_at]) }
124
+ .each { |h| puts(formata_trades(h)) }
125
+ end
126
+
127
+ # @return [String] texto transacoes ledger
128
+ def mostra_ledger
129
+ return unless ops[:v] && ledger.count.positive?
130
+
131
+ puts("\nledger data hora tipo moe ---------quantidade -------------custo")
132
+ ledger.sort { |a, b| b[:time] <=> a[:time] }.each { |h| puts(formata_ledger(h)) }
133
+ end
134
+ end
135
+ end
@@ -6,7 +6,7 @@ require('bigdecimal/util')
6
6
  module Cex
7
7
  # classe para processar saldos & transacoes trades e ledger
8
8
  class Kraken
9
- # @return [Client] API kraken
9
+ # @return [Apius] API kraken
10
10
  attr_reader :api
11
11
  # @return [Array<Hash>] todos os dados bigquery
12
12
  attr_reader :dbq
@@ -21,89 +21,90 @@ module Cex
21
21
  # @return [Kraken] API kraken - obter saldos & transacoes trades e ledger
22
22
  def initialize(dad, pop)
23
23
  # API kraken base
24
- @api = Client.new
24
+ @api = Apius.new
25
25
  @dbq = dad
26
26
  @ops = pop
27
27
  end
28
28
 
29
- # @return [Hash] dados kraken - saldos & transacoes trades e ledger
30
- def dkr
31
- @dkr ||= {
32
- sl: api.balance,
33
- kt: api.trades_history,
29
+ # @return [Hash] dados exchange kraken - saldos & transacoes trades e ledger
30
+ def exd
31
+ @exd ||= {
32
+ sl: api.account,
33
+ kt: api.trades,
34
34
  kl: api.ledger
35
35
  }
36
36
  end
37
37
 
38
38
  # @return [Array<String>] lista txid de transacoes trades
39
39
  def kyt
40
- @kyt ||= dkr[:kt]['trades'].keys - (ops[:t] ? [] : dbq[:nt].map { |e| e[:txid] })
40
+ @kyt ||= exd[:kt].keys - (ops[:t] ? [] : dbq[:nt].map { |e| e[:txid].to_sym })
41
41
  end
42
42
 
43
43
  # @return [Array<String>] lista txid de transacoes ledger
44
44
  def kyl
45
- @kyl ||= dkr[:kl]['ledger'].keys - (ops[:t] ? [] : dbq[:nl].map { |e| e[:txid] })
45
+ @kyl ||= exd[:kl].keys - (ops[:t] ? [] : dbq[:nl].map { |e| e[:txid].to_sym })
46
46
  end
47
47
 
48
48
  # @return [Hash] transacoes trades
49
49
  def trades
50
- @trades ||= dkr[:kt]['trades'].select { |k, _| kyt.include?(k) }
50
+ @trades ||= exd[:kt].select { |k, _| kyt.include?(k) }
51
51
  end
52
52
 
53
53
  # @return [Hash] transacoes ledger
54
54
  def ledger
55
- @ledger ||= dkr[:kl]['ledger'].select { |k, _| kyl.include?(k) }
55
+ @ledger ||= exd[:kl].select { |k, _| kyl.include?(k) }
56
56
  end
57
57
 
58
- # @parm [String] moe codigo kraken da moeda
59
- # @parm [String] moe saldo kraken da moeda
58
+ # @example (see Apius#account)
59
+ # @param [String] moe codigo kraken da moeda
60
+ # @param [BigDecimal] sal saldo kraken da moeda
60
61
  # @return [String] texto formatado saldos (kraken/bigquery) & iguais/ok/nok?
61
62
  def formata_saldos(moe, sal)
62
63
  t = dbq[:sl][moe.downcase.to_sym].to_d
63
64
  format(
64
65
  '%<mo>-5.5s %<kr>21.9f %<bq>21.9f %<ok>3.3s',
65
- mo: moe,
66
+ mo: moe.upcase,
66
67
  kr: sal,
67
68
  bq: t,
68
69
  ok: t == sal ? 'OK' : 'NOK'
69
70
  )
70
71
  end
71
72
 
72
- # @parm [String] idx codigo transacao
73
- # @parm [Hash] htx transacao trade
73
+ # @example (see Apius#trades)
74
+ # @param (see Bigquery#ust_val1)
74
75
  # @return [String] texto formatado transacao trade
75
- def formata_transacao_trades(idx, htx)
76
+ def formata_trades(idx, htx)
76
77
  format(
77
78
  '%<ky>-6.6s %<dt>19.19s %<ty>-10.10s %<mo>-8.8s %<pr>8.2f %<vl>15.7f %<co>8.2f',
78
79
  ky: idx,
79
- dt: Time.at(htx['time']),
80
- ty: "#{htx['type']}/#{htx['ordertype']}",
81
- mo: htx['pair'],
82
- pr: htx['price'].to_d,
83
- vl: htx['vol'].to_d,
84
- co: htx['cost'].to_d
80
+ dt: Time.at(htx[:time]),
81
+ ty: "#{htx[:type]}/#{htx[:ordertype]}",
82
+ mo: htx[:pair].upcase,
83
+ pr: htx[:price].to_d,
84
+ vl: htx[:vol].to_d,
85
+ co: htx[:cost].to_d
85
86
  )
86
87
  end
87
88
 
88
- # @parm idx (see formata_transacao_trades)
89
- # @parm [Hash] hlx transacao ledger
89
+ # @example (see Apius#ledger)
90
+ # @param (see Bigquery#usl_val)
90
91
  # @return [String] texto formatado transacao ledger
91
- def formata_transacao_ledger(idx, hlx)
92
+ def formata_ledger(idx, hlx)
92
93
  format(
93
94
  '%<ky>-6.6s %<dt>19.19s %<ty>-10.10s %<mo>-4.4s %<pr>18.7f %<vl>18.7f',
94
95
  ky: idx,
95
- dt: Time.at(hlx['time']),
96
- ty: hlx['type'],
97
- mo: hlx['asset'],
98
- pr: hlx['amount'].to_d,
99
- vl: hlx['fee'].to_d
96
+ dt: Time.at(hlx[:time]),
97
+ ty: hlx[:type],
98
+ mo: hlx[:asset].upcase,
99
+ pr: hlx[:amount].to_d,
100
+ vl: hlx[:fee].to_d
100
101
  )
101
102
  end
102
103
 
103
104
  # @return [String] texto saldos & transacoes & ajuste dias
104
105
  def mostra_resumo
105
- puts("\nmoeda saldo kraken saldo bigquery")
106
- dkr[:sl].each { |k, v| puts(formata_saldos(k, v.to_d)) }
106
+ puts("\nKRAKEN\nmoeda saldo kraken saldo bigquery")
107
+ exd[:sl].each { |k, v| puts(formata_saldos(k, v.to_d)) }
107
108
 
108
109
  mostra_trades
109
110
  mostra_ledger
@@ -117,7 +118,7 @@ module Cex
117
118
  return unless ops[:v] && trades.count.positive?
118
119
 
119
120
  puts("\ntrade data hora tipo par ---preco ---------volume ---custo")
120
- trades.each { |k, v| puts(formata_transacao_trades(k, v)) }
121
+ trades.sort { |a, b| b[1][:time] <=> a[1][:time] }.each { |k, v| puts(formata_trades(k, v)) }
121
122
  end
122
123
 
123
124
  # @return [String] texto transacoes ledger
@@ -125,7 +126,7 @@ module Cex
125
126
  return unless ops[:v] && ledger.count.positive?
126
127
 
127
128
  puts("\nledger data hora tipo moeda -------quantidade -------------custo")
128
- ledger.each { |k, v| puts(formata_transacao_ledger(k, v)) }
129
+ ledger.sort { |a, b| b[1][:time] <=> a[1][:time] }.each { |k, v| puts(formata_ledger(k, v)) }
129
130
  end
130
131
  end
131
132
  end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('bigdecimal/util')
4
+
5
+ # @author Hernani Rodrigues Vaz
6
+ module Cex
7
+ # classe para processar saldos & transacoes ledger
8
+ class Paymium
9
+ # @return [Apius] API paymium
10
+ attr_reader :api
11
+ # @return [Array<Hash>] todos os dados bigquery
12
+ attr_reader :dbq
13
+ # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
14
+ attr_reader :ops
15
+
16
+ # @param [Hash] dad todos os dados bigquery
17
+ # @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
18
+ # @option pop [Hash] :h ({}) configuracao dias ajuste reposicionamento temporal
19
+ # @option pop [Boolean] :v (false) mostra dados transacoes trades & ledger?
20
+ # @option pop [Boolean] :t (false) mostra transacoes todas ou somente novas?
21
+ # @return [Paymium] API paymium - obter saldos & transacoes ledger
22
+ def initialize(dad, pop)
23
+ # API paymium base
24
+ @api = Apifr.new
25
+ @dbq = dad
26
+ @ops = pop
27
+ end
28
+
29
+ # @return [Hash] dados exchange paymium - saldos & transacoes ledger
30
+ def exd
31
+ @exd ||= {
32
+ sl: api.account,
33
+ kl: api.ledger
34
+ }
35
+ end
36
+
37
+ # @return [Array<String>] lista txid de transacoes ledger
38
+ def kyl
39
+ @kyl ||= exd[:kl].map { |h| h[:account_operations].map { |o| o[:uuid] } }.flatten -
40
+ (ops[:t] ? [] : dbq[:nl].map { |e| e[:txid] })
41
+ end
42
+
43
+ # @return [Hash] transacoes ledger
44
+ def ledger
45
+ @ledger ||= exd[:kl].map { |h| h[:account_operations].select { |o| kyl.include?(o[:uuid]) } }.flatten
46
+ end
47
+
48
+ # @example (see Apifr#account)
49
+ # @param [Symbol] bqm symbol paymium da moeda
50
+ # @return [String] texto formatado saldos (paymium/bigquery) & iguais/ok/nok?
51
+ def formata_saldos(bqm)
52
+ b = dbq[:sl][bqm].to_d
53
+ t = exd[:sl]["balance_#{bqm}".to_sym].to_d
54
+ format(
55
+ '%<mo>-5.5s %<kr>21.9f %<bq>21.9f %<ok>3.3s',
56
+ mo: bqm.upcase,
57
+ kr: t,
58
+ bq: b,
59
+ ok: t == b ? 'OK' : 'NOK'
60
+ )
61
+ end
62
+
63
+ # @example (see Apifr#ledger)
64
+ # @param (see Bigquery#frl_val)
65
+ # @return [String] texto formatado transacao ledger
66
+ def formata_ledger(hlx)
67
+ format(
68
+ '%<ky>-18.18s %<dt>19.19s %<ty>-17.17s %<mo>-4.4s %<vl>18.7f',
69
+ ky: formata_uuid(hlx[:uuid], 18),
70
+ dt: Time.at(hlx[:created_at_int]),
71
+ ty: hlx[:name],
72
+ mo: hlx[:currency].upcase,
73
+ vl: hlx[:amount].to_d
74
+ )
75
+ end
76
+
77
+ # @example (see Apifr#ledger)
78
+ # @param [String] uid identificacor da ledger apifr
79
+ # @param [Integer] max chars a mostrar
80
+ # @return [String] texto formatado identificacor da ledger apifr
81
+ def formata_uuid(uid, max)
82
+ i = Integer(max / 2)
83
+ max < 7 ? 'erro' : "#{uid[0, i]}#{uid[-i..]}"
84
+ end
85
+
86
+ # @return [String] texto saldos & transacoes & ajuste dias
87
+ def mostra_resumo
88
+ puts("\nPAYMIUM\nmoeda saldo paymium saldo bigquery")
89
+ puts(formata_saldos(:btc))
90
+ puts(formata_saldos(:eur))
91
+
92
+ mostra_ledger
93
+ return unless ledger.count.positive?
94
+
95
+ puts("\nstring ajuste dias da ledger\n-h=#{kyl.map { |e| "#{e}:0" }.join(' ')}")
96
+ end
97
+
98
+ # @return [String] texto transacoes ledger
99
+ def mostra_ledger
100
+ return unless ops[:v] && ledger.count.positive?
101
+
102
+ puts("\nledger data hora tipo moeda -------quantidade")
103
+ ledger.sort { |a, b| b[:created_at_int] <=> a[:created_at_int] }.each { |o| puts(formata_ledger(o)) }
104
+ end
105
+ end
106
+ end