Class: Btce::TradeAPI
- Inherits:
-
API
- Object
- API
- Btce::TradeAPI
show all
- Defined in:
- lib/btce.rb
Constant Summary
collapse
- KEY =
YAML::load File.open 'btce-api-key.yml'
- OPERATIONS =
%w(getInfo
TransHistory
TradeHistory
OrderList
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
Methods inherited from API
get_https, get_json
Constructor Details
#initialize(opts = {}) ⇒ TradeAPI
Returns a new instance of TradeAPI.
258
259
260
261
262
|
# File 'lib/btce.rb', line 258
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
.new_from_keyfile ⇒ Object
244
245
246
|
# File 'lib/btce.rb', line 244
def new_from_keyfile
new key: KEY["key"], secret: KEY["secret"]
end
|
Instance Method Details
#sign(params) ⇒ Object
264
265
266
267
268
269
270
|
# File 'lib/btce.rb', line 264
def sign(params)
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
272
273
274
275
276
277
278
279
280
281
282
283
284
|
# File 'lib/btce.rb', line 272
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
API::get_json({ :url => "https://#{API::BTCE_DOMAIN}/tapi",
:key => @key,
:params => params,
:signed => signed })
end
|