Class: Btce::TradeAPI
- Inherits:
-
API
- Object
- API
- Btce::TradeAPI
show all
- Defined in:
- lib/btce.rb
Constant Summary
collapse
- OPERATIONS =
%w(getInfo
TransHistory
TradeHistory
OrderList
Trade
CancelOrder)
Constants inherited
from API
API::BTCE_DOMAIN, API::CURRENCIES, API::CURRENCY_PAIRS, API::KEY, API::MAX_DIGITS
Class Method Summary
collapse
Methods inherited from API
get_https, get_json
Class Method Details
.nonce ⇒ Object
277
278
279
280
281
282
|
# File 'lib/btce.rb', line 277
def nonce
while result = Time.now.to_i and @last_nonce and @last_nonce >= result
sleep 1
end
return @last_nonce = result
end
|
.sign(params) ⇒ Object
256
257
258
259
260
261
262
263
264
|
# File 'lib/btce.rb', line 256
def sign(params)
hmac = OpenSSL::HMAC.new(API::KEY['secret'],
OpenSSL::Digest::SHA512.new)
params = params
.collect {|k,v| "#{k}=#{v}"}
.join('&')
signed = hmac.update params
end
|
.trade_api_call(method, extra) ⇒ Object
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/btce.rb', line 266
def trade_api_call(method, )
params = {"method" => method, "nonce" => nonce}
if ! .empty?
.each do |k,v|
params[k.to_s] = v
end
end
signed = sign params
get_json "https://#{API::BTCE_DOMAIN}/tapi", params, signed
end
|