Class: Cex::Apius
- Inherits:
-
Object
- Object
- Cex::Apius
- Defined in:
- lib/cex/apius.rb
Overview
classe para processar dados no kraken
Instance Attribute Summary collapse
-
#aky ⇒ String
readonly
API key.
-
#asc ⇒ String
readonly
API secret.
-
#pth ⇒ String
readonly
API private path.
-
#urb ⇒ String
readonly
API url base.
Instance Method Summary collapse
-
#account ⇒ Hash
Saldos no kraken.
-
#initialize(pky: ENV['KRAKEN_API_KEY'], psc: ENV['KRAKEN_API_SECRET'], ops: { www: 'https://api.kraken.com', ver: 0 }) ⇒ Apius
constructor
API kraken base.
-
#ledger(ofs = 0, has = {}) ⇒ Hash
Dados ledger no kraken.
-
#trades(ofs = 0, has = {}) ⇒ Hash
Dados trades no kraken.
Constructor Details
#initialize(pky: ENV['KRAKEN_API_KEY'], psc: ENV['KRAKEN_API_SECRET'], ops: { www: 'https://api.kraken.com', ver: 0 }) ⇒ Apius
Returns API kraken base.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cex/apius.rb', line 25 def initialize( pky: ENV['KRAKEN_API_KEY'], psc: ENV['KRAKEN_API_SECRET'], ops: { www: 'https://api.kraken.com', ver: 0 } ) @aky = pky @asc = psc @urb = "#{ops[:www]}/#{ops[:ver]}" @pth = "/#{ops[:ver]}/private/" end |
Instance Attribute Details
#aky ⇒ String (readonly)
Returns API key.
13 14 15 |
# File 'lib/cex/apius.rb', line 13 def aky @aky end |
#asc ⇒ String (readonly)
Returns API secret.
15 16 17 |
# File 'lib/cex/apius.rb', line 15 def asc @asc end |
#pth ⇒ String (readonly)
Returns API private path.
19 20 21 |
# File 'lib/cex/apius.rb', line 19 def pth @pth end |
#urb ⇒ String (readonly)
Returns API url base.
17 18 19 |
# File 'lib/cex/apius.rb', line 17 def urb @urb end |
Instance Method Details
#account ⇒ Hash
Returns saldos no kraken.
49 50 51 |
# File 'lib/cex/apius.rb', line 49 def account api_post('Balance')[:result] end |
#ledger(ofs = 0, has = {}) ⇒ Hash
Returns dados ledger no kraken.
111 112 113 114 115 116 117 118 |
# File 'lib/cex/apius.rb', line 111 def ledger(ofs = 0, has = {}) r = api_post('Ledgers', ofs: ofs)[:result] has.merge!(r[:ledger]) ofs += 50 ofs < r[:count] ? ledger(ofs, has) : has rescue StandardError has end |
#trades(ofs = 0, has = {}) ⇒ Hash
Returns dados trades no kraken.
79 80 81 82 83 84 85 86 |
# File 'lib/cex/apius.rb', line 79 def trades(ofs = 0, has = {}) r = api_post('TradesHistory', ofs: ofs)[:result] has.merge!(r[:trades]) ofs += 50 ofs < r[:count] ? trades(ofs, has) : has rescue StandardError has end |