Class: CoinRail::HTTP::Private::Client
- Inherits:
-
Object
- Object
- CoinRail::HTTP::Private::Client
- Defined in:
- lib/coinrail/http/private.rb
Instance Method Summary collapse
- #balance ⇒ Object
- #current_timestamp ⇒ Object
-
#initialize(key, secret) ⇒ Client
constructor
A new instance of Client.
-
#limit_buy(currency, price, qty) ⇒ Object
def withdrawals @connection.get(‘/v1/me/getwithdrawals’).body end.
- #limit_sell(currency, price, qty) ⇒ Object
- #trade_completed(currency: nil, count: nil, offset: nil) ⇒ Object (also: #executions)
- #trade_pending(currency: nil, count: nil, offset: nil) ⇒ Object
-
#wallet_info(currency) ⇒ Object
def deposits @connection.get(‘/v1/me/getdeposits’).body end.
- #withdraw_coin(currency, address, amount) ⇒ Object
Constructor Details
#initialize(key, secret) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/coinrail/http/private.rb', line 5 def initialize(key, secret) @connection = Connection.new(key, secret) @key = key end |
Instance Method Details
#balance ⇒ Object
14 15 16 17 18 19 |
# File 'lib/coinrail/http/private.rb', line 14 def balance puts @key body = {timestamp: (Time.now.to_i * 1000).to_s, access_key: @key} @connection.post('/balance', body.to_json).body end |
#current_timestamp ⇒ Object
10 11 12 |
# File 'lib/coinrail/http/private.rb', line 10 def (Time.now.to_i * 1000) end |
#limit_buy(currency, price, qty) ⇒ Object
def withdrawals
@connection.get('/v1/me/getwithdrawals').body
end
58 59 60 61 62 63 64 65 66 |
# File 'lib/coinrail/http/private.rb', line 58 def limit_buy(currency, price, qty) throw "limit_buy: all parameter should not be nil" if currency.nil? or price.nil? or qty.nil? body = {access_key: @key, currency: currency, price: price, qty: qty, timestamp: } @connection.post('/order/limit/buy', body).body end |
#limit_sell(currency, price, qty) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/coinrail/http/private.rb', line 68 def limit_sell(currency, price, qty) throw "limit_sell: all parameter should not be nil" if currency.nil? or price.nil? or qty.nil? body = {access_key: @key, currency: currency, price: price, qty: qty, timestamp: } @connection.post('/order/limit/sell', body).body end |
#trade_completed(currency: nil, count: nil, offset: nil) ⇒ Object Also known as: executions
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/coinrail/http/private.rb', line 78 def trade_completed(currency: nil, count: nil, offset: nil) query = { access_key: @key, currency: currency, count: count, offset: offset, timestamp: }.delete_if { |_, v| v.nil? } @connection.post('/trade/completed', query).body end |
#trade_pending(currency: nil, count: nil, offset: nil) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/coinrail/http/private.rb', line 92 def trade_pending(currency: nil, count: nil, offset: nil) query = { access_key: @key, currency: currency, count: count, offset: offset, timestamp: }.delete_if { |_, v| v.nil? } @connection.post('/trade/pending', query).body end |
#wallet_info(currency) ⇒ Object
def deposits
@connection.get('/v1/me/getdeposits').body
end
37 38 39 40 41 42 |
# File 'lib/coinrail/http/private.rb', line 37 def wallet_info(currency) body = {access_key: @key, currency: currency, timestamp: }.delete_if { |_, v| v.nil? } @connection.post('/wallet', body).body end |
#withdraw_coin(currency, address, amount) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/coinrail/http/private.rb', line 44 def withdraw_coin(currency, address, amount) body = {access_key: @key, currency: currency, address: address, amount: amount, timestamp: }.delete_if { |_, v| v.nil? } @connection.post('/withdraw', body).body end |