class Vexapion::Poloniex
Public Instance Methods
available_account_balances()
click to toggle source
# File lib/vexapion/poloniex.rb, line 91 def available_account_balances post('returnAvailableAccountBalances') end
balances()
click to toggle source
# File lib/vexapion/poloniex.rb, line 51 def balances post('returnBalances') end
buy(pair, rate, amount)
click to toggle source
# File lib/vexapion/poloniex.rb, line 68 def buy(pair, rate, amount) post('buy', 'currencyPair' => pair.upcase, 'rate' => rate, 'amount' => amount) end
cancel_order(order_number)
click to toggle source
# File lib/vexapion/poloniex.rb, line 78 def cancel_order(order_number) post('cancelOrder', orderNumber: order_number) end
complete_balances(account='all')
click to toggle source
# File lib/vexapion/poloniex.rb, line 55 def complete_balances(account='all') post('returnCompleteBalances', 'account' => account) end
deposit_addresses()
click to toggle source
# File lib/vexapion/poloniex.rb, line 118 def deposit_addresses post('returnDepositAddresses') end
deposits_withdrawals(start_time, end_time, count)
click to toggle source
# File lib/vexapion/poloniex.rb, line 126 def deposits_withdrawals(start_time, end_time, count) post('returnDepositsWithdrawals', 'start' => start_time, 'end' => end_time, 'count' => count) end
fee_info()
click to toggle source
Trade(Private) API
# File lib/vexapion/poloniex.rb, line 47 def fee_info post('returnFeeInfo') end
generate_new_address(currency)
click to toggle source
# File lib/vexapion/poloniex.rb, line 122 def generate_new_address(currency) post('generateNewAddress', 'currency' => currency.upcase) end
margin_account_summary()
click to toggle source
# File lib/vexapion/poloniex.rb, line 104 def margin_account_summary post('returnMarginAccountSummary') end
margin_buy(pair, rate, amount)
click to toggle source
# File lib/vexapion/poloniex.rb, line 108 def margin_buy(pair, rate, amount) post('marginBuy', 'currencyPair' => pair.upcase, 'rate' => rate, 'amount' => amount) end
margin_sell(pair, rate, amount)
click to toggle source
# File lib/vexapion/poloniex.rb, line 113 def margin_sell(pair, rate, amount) post('marginSell', 'currencyPair' => pair.upcase, 'rate' => rate, 'amount' => amount) end
market_trade_history(pair, start_time='', end_time='')
click to toggle source
# File lib/vexapion/poloniex.rb, line 37 def market_trade_history(pair, start_time='', end_time='') params = { currencyPair: pair.upcase } params[:start] = start_time if start_time != '' params[:end] = end_time if end_time != '' get('returnTradeHistory', params) end
move_order(order_number, rate)
click to toggle source
# File lib/vexapion/poloniex.rb, line 82 def move_order(order_number, rate) post('moveOrder', orderNumber: order_number, 'rate' => rate) end
open_orders(pair)
click to toggle source
# File lib/vexapion/poloniex.rb, line 59 def open_orders(pair) post('returnOpenOrders', currencyPair: pair.upcase) end
orderbook(pair, depth)
click to toggle source
# File lib/vexapion/poloniex.rb, line 33 def orderbook(pair, depth) get('returnOrderBook', currencyPair: pair.upcase, depth: depth) end
sell(pair, rate, amount)
click to toggle source
# File lib/vexapion/poloniex.rb, line 73 def sell(pair, rate, amount) post('sell', 'currencyPair' => pair.upcase, 'rate' => rate, 'amount' => amount) end
set_min_interval(sec)
click to toggle source
# File lib/vexapion/poloniex.rb, line 18 def set_min_interval(sec) @conn.min_interval = sec end
ticker()
click to toggle source
# File lib/vexapion/poloniex.rb, line 29 def ticker get('returnTicker') end
tradable_balances()
click to toggle source
# File lib/vexapion/poloniex.rb, line 95 def tradable_balances post('returnTradableBalances') end
trade_history(pair, start, end_time)
click to toggle source
# File lib/vexapion/poloniex.rb, line 63 def trade_history(pair, start, end_time) post('returnTradeHistory', 'currencyPair' => pair.upcase, 'start' => start, 'end' => end_time) end
transfer_balance(currency, amount, from_account, to_account)
click to toggle source
# File lib/vexapion/poloniex.rb, line 99 def transfer_balance(currency, amount, from_account, to_account) post('transferBalance', currency: currency.upcase, amount: amount, fromAccount: from_account, toAccount: to_account) end
volume_24hours()
click to toggle source
Public API
# File lib/vexapion/poloniex.rb, line 25 def volume_24hours get('return24hVolume') end
withdraw(currency, amount, address)
click to toggle source
# File lib/vexapion/poloniex.rb, line 86 def withdraw(currency, amount, address) post('widthdraw', currency: currency.upcase, 'amount' => amount, 'address' => address) end
Private Instance Methods
error_check(res)
click to toggle source
# File lib/vexapion/poloniex.rb, line 174 def error_check(res) if !res.nil? && res['success'] == 0 && res.has_key?('errors') fail Warning(0, res['errors']) end end
get(command, params = {})
click to toggle source
Create request header & body
# File lib/vexapion/poloniex.rb, line 135 def get(command, params = {}) params['command'] = command param = URI.encode_www_form(params) uri = URI.parse @public_url + param request = Net::HTTP::Get.new(uri.request_uri) res = do_command(uri, request) error_check(res) res end
headers(sign)
click to toggle source
# File lib/vexapion/poloniex.rb, line 167 def headers(sign) { 'Sign' => sign, 'Key' => @key } end
post(command, params = {})
click to toggle source
# File lib/vexapion/poloniex.rb, line 146 def post(command, params = {}) params['command'] = command params['nonce'] = get_nonce post_data = URI.encode_www_form(params) header = headers(signature(post_data)) uri = URI.parse @private_url request = Net::HTTP::Post.new(uri.request_uri, header) request.body = post_data res = do_command(uri, request) error_check(res) res end
signature(data)
click to toggle source
# File lib/vexapion/poloniex.rb, line 162 def signature(data) algo = OpenSSL::Digest.new('sha512') OpenSSL::HMAC.hexdigest(algo, @secret, data) end