module Aex

Constants

VERSION

Attributes

configuration[RW]

Public Class Methods

balances() click to toggle source
# File lib/aex.rb, line 35
def self.balances
  post 'getMyBalance'
end
buy( currency_pair, rate, quantity ) click to toggle source
# File lib/aex.rb, line 39
def self.buy( currency_pair, rate, quantity )
  mk_type, coinname = currency_pair.upcase.split('_')
  submit_order 1, mk_type, rate, quantity, coinname 
end
cancel_order(mk_type, order_id, coinname) click to toggle source
# File lib/aex.rb, line 53
def self.cancel_order(mk_type, order_id, coinname)
  post 'cancelOrder', mk_type: mk_type, order_id: order_id, coinname: coinname
end
depth(c, mk_type) click to toggle source
# File lib/aex.rb, line 27
def self.depth(c, mk_type)
  get 'depth', c: c, mk_type: mk_type
end
order_list(mk_type, coinname) click to toggle source
# File lib/aex.rb, line 57
def self.order_list(mk_type, coinname)
  post 'getOrderList', mk_type: mk_type, coinname: coinname
end
sell( currency_pair, rate, quantity ) click to toggle source
# File lib/aex.rb, line 44
def self.sell( currency_pair, rate, quantity )
  mk_type, coinname = currency_pair.upcase.split('_')
  submit_order 2, mk_type, rate, quantity, coinname 
end
setup() { |configuration| ... } click to toggle source
# File lib/aex.rb, line 8
def self.setup
  @configuration ||= Configuration.new
  yield( configuration )
end
submit_order(type, mk_type, price, amount, coinname) click to toggle source
# File lib/aex.rb, line 49
def self.submit_order(type, mk_type, price, amount, coinname)
  post 'submitOrder', type: type, mk_type: mk_type, price: price, amount: amount, coinname: coinname
end
ticker(c='all', mk_type='btc') click to toggle source
# File lib/aex.rb, line 23
def self.ticker(c='all', mk_type='btc')
  get 'ticker', c: c, mk_type: mk_type
end
trade_list(mk_type, coinname) click to toggle source
# File lib/aex.rb, line 61
def self.trade_list(mk_type, coinname)
  post 'getMyTradeList', mk_type: mk_type, coinname: coinname
end
trades(c, mk_type, options = {}) click to toggle source
# File lib/aex.rb, line 31
def self.trades(c, mk_type, options = {})
  get 'trades', options.merge({c: c, mk_type: mk_type})
end

Protected Class Methods

create_sign() click to toggle source
# File lib/aex.rb, line 80
def self.create_sign
  time = Time.now.to_i
  mdt = "#{configuration.key}_#{configuration.uid}_#{configuration.secret}_#{time}"
  {key: configuration.key, time: time, md5: Digest::MD5.hexdigest(mdt)}
end
get( command, params = {} ) click to toggle source
# File lib/aex.rb, line 71
def self.get( command, params = {} )
  params[:command] = command
  resource[ "#{command}.php" ].get params: params, "User-Agent" => "curl/7.35.0"
end
post( command, params = {} ) click to toggle source
# File lib/aex.rb, line 76
def self.post( command, params = {} )
  resource[ "#{command}.php" ].post params.merge(create_sign), { "User-Agent" => "curl/7.35.0" }
end
resource() click to toggle source
# File lib/aex.rb, line 67
def self.resource
  @@resouce ||= RestClient::Resource.new( 'http://api.aex.com' )
end