class CoinRail::HTTP::Private::Client
Public Class Methods
new(key, secret)
click to toggle source
# File lib/coinrail/http/private.rb, line 5 def initialize(key, secret) @connection = Connection.new(key, secret) @key = key end
Public Instance Methods
balance()
click to toggle source
# 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()
click to toggle source
# File lib/coinrail/http/private.rb, line 10 def current_timestamp (Time.now.to_i * 1000) end
limit_buy(currency, price, qty)
click to toggle source
def withdrawals
@connection.get('/v1/me/getwithdrawals').body
end
# 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: current_timestamp} @connection.post('/order/limit/buy', body).body end
limit_sell(currency, price, qty)
click to toggle source
# 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: current_timestamp} @connection.post('/order/limit/sell', body).body end
trade_completed(currency: nil, count: nil, offset: nil)
click to toggle source
# 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: current_timestamp }.delete_if { |_, v| v.nil? } @connection.post('/trade/completed', query).body end
Also aliased as: executions
trade_pending(currency: nil, count: nil, offset: nil)
click to toggle source
# 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: current_timestamp }.delete_if { |_, v| v.nil? } @connection.post('/trade/pending', query).body end
wallet_info(currency)
click to toggle source
def deposits
@connection.get('/v1/me/getdeposits').body
end
# File lib/coinrail/http/private.rb, line 37 def wallet_info(currency) body = {access_key: @key, currency: currency, timestamp: current_timestamp}.delete_if { |_, v| v.nil? } @connection.post('/wallet', body).body end
withdraw_coin(currency, address, amount)
click to toggle source
# 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: current_timestamp }.delete_if { |_, v| v.nil? } @connection.post('/withdraw', body).body end