module Poloniex

Constants

VERSION

Attributes

configuration[RW]

Public Class Methods

balances() click to toggle source
# File lib/poloniex.rb, line 43
def self.balances
  post 'returnBalances'
end
buy( currency_pair, rate, amount ) click to toggle source
# File lib/poloniex.rb, line 55
def self.buy( currency_pair, rate, amount )
  post 'buy', currencyPair: currency_pair, rate: rate, amount: amount
end
cancel_order( currency_pair, order_number ) click to toggle source
# File lib/poloniex.rb, line 63
def self.cancel_order( currency_pair, order_number )
  post 'cancelOrder', currencyPair: currency_pair, orderNumber: order_number
end
open_orders( currency_pair ) click to toggle source
# File lib/poloniex.rb, line 47
def self.open_orders( currency_pair )
  post 'returnOpenOrders', currencyPair: currency_pair
end
order_book( currency_pair ) click to toggle source
# File lib/poloniex.rb, line 35
def self.order_book( currency_pair )
  get 'returnOrderBook', currencyPair: currency_pair
end
sell( currency_pair, rate, amount ) click to toggle source
# File lib/poloniex.rb, line 59
def self.sell( currency_pair, rate, amount )
  post 'sell', currencyPair: currency_pair, rate: rate, amount: amount
end
setup() { |configuration| ... } click to toggle source
# File lib/poloniex.rb, line 13
def self.setup
  @configuration ||= Configuration.new
  yield( configuration )
end
ticker() click to toggle source
# File lib/poloniex.rb, line 27
def self.ticker
  get 'returnTicker'
end
trade_history( currency_pair ) click to toggle source
# File lib/poloniex.rb, line 39
def self.trade_history( currency_pair )
  get 'returnTradeHistory', currencyPair: currency_pair
end
volume() click to toggle source
# File lib/poloniex.rb, line 31
def self.volume
  get 'return24hVolume'
end
withdraw( curreny, amount, address ) click to toggle source
# File lib/poloniex.rb, line 67
def self.withdraw( curreny, amount, address )
  post 'widthdraw', currency: currency, amount: amount, address: address
end

Protected Class Methods

create_sign( data ) click to toggle source
# File lib/poloniex.rb, line 88
def self.create_sign( data )
  encoded_data = Addressable::URI.form_encode( data )
  OpenSSL::HMAC.hexdigest( 'sha512', configuration.secret , encoded_data )
end
get( command, params = {} ) click to toggle source
# File lib/poloniex.rb, line 77
def self.get( command, params = {} )
  params[:command] = command
  resource[ 'public' ].get params: params
end
post( command, params = {} ) click to toggle source
# File lib/poloniex.rb, line 82
def self.post( command, params = {} )
  params[:command] = command
  params[:nonce]   = Time.now.to_i * 1000
  resource[ 'tradingApi' ].post params, { Key: configuration.key , Sign: create_sign( params ) }
end
resource() click to toggle source
# File lib/poloniex.rb, line 73
def self.resource
  @@resouce ||= RestClient::Resource.new( 'https://www.poloniex.com' )
end