class HexTokenBot::ChannelClient::HexClient
Attributes
client[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/hex_token_bot/channel_client/hex_client.rb, line 6 def initialize(options = {}) client_options = { access_key: HexTokenBot.tran_channels['hex']['access_key'], secret_key: HexTokenBot.tran_channels['hex']['secret_key'], endpoint: HexTokenBot.tran_channels['hex']['endpoint'], timeout: HexTokenBot.tran_channels['hex']['timeout'] } @client = PeatioAPI::Client.new client_options.merge(options) end
Public Instance Methods
get_market_order_book(market_code, asks_limit = nil , bids_limit = nil)
click to toggle source
# File lib/hex_token_bot/channel_client/hex_client.rb, line 17 def get_market_order_book(market_code, asks_limit = nil , bids_limit = nil) rep = client.get '/api/v2/order_book', market: market_code rep end
get_order_newest(market_code)
click to toggle source
# File lib/hex_token_bot/channel_client/hex_client.rb, line 22 def get_order_newest(market_code) rep = client.get '/api/v2/trades', market: market_code if rep.class == Array and !rep.empty? count = rep.size rep[count - 1] else [] end end
send_order(side, market_code, price, volume)
click to toggle source
# File lib/hex_token_bot/channel_client/hex_client.rb, line 32 def send_order(side, market_code, price, volume) rep = client.post '/api/v2/orders', market: market_code, price: price, side: side, volume: volume rep end
send_order_buy(market_code, price, volume)
click to toggle source
# File lib/hex_token_bot/channel_client/hex_client.rb, line 43 def send_order_buy(market_code, price, volume) send_order('buy', market_code, price, volume) end
send_order_sell(market_code, price, volume)
click to toggle source
# File lib/hex_token_bot/channel_client/hex_client.rb, line 47 def send_order_sell(market_code, price, volume) send_order('sell', market_code, price, volume) end
send_orders_multi(orders, market_code)
click to toggle source
orders: [{side: 'buy', volume: '0.15', price: '2955.0'}, {side: 'sell', volume: '0.16', price: '2956'}]
# File lib/hex_token_bot/channel_client/hex_client.rb, line 38 def send_orders_multi(orders, market_code) rep = client.post '/api/v2/orders/multi', market: market_code, orders: orders rep end