Class: Btce::TradeAPI
Constant Summary collapse
- KEY =
YAML::load File.open 'btce-api-key.yml'
- OPERATIONS =
%w(getInfo TransHistory TradeHistory OrderList WithdrawCoin ActiveOrders Trade CancelOrder)
Constants inherited from API
API::BTCE_DOMAIN, API::CURRENCIES, API::CURRENCY_PAIRS, API::MAX_DIGITS
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ TradeAPI
constructor
A new instance of TradeAPI.
- #sign(params) ⇒ Object
- #trade_api_call(method, extra) ⇒ Object
Methods inherited from API
Constructor Details
#initialize(opts = {}) ⇒ TradeAPI
Returns a new instance of TradeAPI.
59 60 61 62 63 |
# File 'lib/btce/api/trade_api.rb', line 59 def initialize(opts={}) raise ArgumentError unless opts.has_key?(:key) and opts.has_key?(:secret) @key = opts[:key] @secret = opts[:secret] end |
Class Method Details
Instance Method Details
#sign(params) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/btce/api/trade_api.rb', line 65 def sign(params) # The digest needs to be created. hmac = OpenSSL::HMAC.new(@secret, OpenSSL::Digest::SHA512.new) params = params.collect {|k,v| "#{k}=#{v}"}.join('&') signed = hmac.update params end |
#trade_api_call(method, extra) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/btce/api/trade_api.rb', line 73 def trade_api_call(method, extra) params = {"method" => method, "nonce" => nonce} if ! extra.empty? extra.each do |k,v| params[k.to_s] = v end end signed = sign params API::get_json({ :url => "https://#{API::BTCE_DOMAIN}/tapi", :key => @key, :params => params, :signed => signed }) end |