module BittrexApi
Constants
- VERSION
Attributes
configuration[RW]
Public Class Methods
balance( currency )
click to toggle source
# File lib/bittrex_api.rb, line 73 def self.balance( currency ) get_account 'getbalance', currency: currency end
balances()
click to toggle source
# File lib/bittrex_api.rb, line 69 def self.balances get_account 'getbalances' end
buy_limit( currency_pair, quantity, rate )
click to toggle source
# File lib/bittrex_api.rb, line 53 def self.buy_limit( currency_pair, quantity, rate ) get_market 'buylimit', market: currency_pair, quantity: quantity, rate: rate end
cancel( uuid )
click to toggle source
# File lib/bittrex_api.rb, line 61 def self.cancel( uuid ) get_market 'cancel', uuid: uuid end
currencies()
click to toggle source
# File lib/bittrex_api.rb, line 29 def self.currencies get_public 'getcurrencies' end
deposit_address( currency )
click to toggle source
# File lib/bittrex_api.rb, line 77 def self.deposit_address( currency ) get_account 'getdepositaddress', currency: currency end
deposit_history( currency = nil )
click to toggle source
# File lib/bittrex_api.rb, line 98 def self.deposit_history( currency = nil ) get_account 'getdeposithistory', currency: currency end
market_history( currency_pair )
click to toggle source
# File lib/bittrex_api.rb, line 49 def self.market_history( currency_pair ) get_public 'getmarkethistory', market: currency_pair end
market_summaries()
click to toggle source
# File lib/bittrex_api.rb, line 37 def self.market_summaries get_public 'getmarketsummaries' end
market_summary( currency_pair )
click to toggle source
# File lib/bittrex_api.rb, line 41 def self.market_summary( currency_pair ) get_public 'getmarketsummary', market: currency_pair end
markets()
click to toggle source
# File lib/bittrex_api.rb, line 25 def self.markets get_public 'getmarkets' end
open_orders( currency_pair = nil )
click to toggle source
# File lib/bittrex_api.rb, line 65 def self.open_orders( currency_pair = nil ) get_market 'getopenorders', market: currency_pair end
order( uuid )
click to toggle source
# File lib/bittrex_api.rb, line 86 def self.order( uuid ) get_account 'getorder', uuid: uuid end
order_book( currency_pair, type = 'both', depth = 10 )
click to toggle source
# File lib/bittrex_api.rb, line 45 def self.order_book( currency_pair, type = 'both', depth = 10 ) get_public 'getorderbook', market: currency_pair, type: type, depth: depth end
order_history( currency_pair = nil )
click to toggle source
# File lib/bittrex_api.rb, line 90 def self.order_history( currency_pair = nil ) get_account 'getorderhistory', market: currency_pair end
sell_limit( currency_pair, quantity, rate )
click to toggle source
# File lib/bittrex_api.rb, line 57 def self.sell_limit( currency_pair, quantity, rate ) get_market 'selllimit', market: currency_pair, quantity: quantity, rate: rate end
setup() { |configuration| ... }
click to toggle source
# File lib/bittrex_api.rb, line 11 def self.setup @configuration ||= Configuration.new yield( @configuration ) end
ticker( currency_pair )
click to toggle source
# File lib/bittrex_api.rb, line 33 def self.ticker( currency_pair ) get_public 'getticker', market: currency_pair end
withdraw( currency, quantity, address )
click to toggle source
# File lib/bittrex_api.rb, line 81 def self.withdraw( currency, quantity, address ) get_account 'withdraw', currency: currency, quantity: quantity, address: address end
withdrawal_history( currency = nil )
click to toggle source
# File lib/bittrex_api.rb, line 94 def self.withdrawal_history( currency = nil ) get_account 'getwithdrawalhistory', currency: currency end
Private Class Methods
get( method, command, params )
click to toggle source
# File lib/bittrex_api.rb, line 126 def self.get( method, command, params ) if method != 'public' params['apikey'] = configuration.key params['nonce'] = Time.now.to_i end full_url = make_full_url(method, command, params) if method == 'public' RestClient.get(full_url) else sig = signature(full_url) RestClient.get(full_url, apisign: sig) end end
get_account( command, params = {} )
click to toggle source
# File lib/bittrex_api.rb, line 122 def self.get_account( command, params = {} ) get 'account', command, params end
get_market( command, params = {} )
click to toggle source
# File lib/bittrex_api.rb, line 118 def self.get_market( command, params = {} ) get 'market', command, params end
get_public( command, params = {} )
click to toggle source
# File lib/bittrex_api.rb, line 114 def self.get_public( command, params = {} ) get 'public', command, params end
make_full_url( method, command, params )
click to toggle source
# File lib/bittrex_api.rb, line 103 def self.make_full_url( method, command, params ) url = "https://bittrex.com/api/v1.1/#{method}/#{command}" query = params.delete_if{ |k,v| v.nil? }.map{ |k,v| "#{k}=#{v}" }.join '&' "#{url}?#{query}" end
signature( url )
click to toggle source
# File lib/bittrex_api.rb, line 109 def self.signature( url ) OpenSSL::HMAC.hexdigest('sha512', configuration.secret.encode("ASCII"), url.encode("ASCII")) end