Class: HexTokenBot::ChannelClient::HexClient

Inherits:
Object
  • Object
show all
Defined in:
lib/hex_token_bot/channel_client/hex_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HexClient

Returns a new instance of HexClient.



6
7
8
9
10
11
12
13
14
# 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

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/hex_token_bot/channel_client/hex_client.rb', line 4

def client
  @client
end

Instance Method Details

#get_market_order_book(market_code, asks_limit = nil, bids_limit = nil) ⇒ Object



17
18
19
20
# 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) ⇒ Object



22
23
24
25
26
27
28
29
30
# 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) ⇒ Object



32
33
34
35
# 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) ⇒ Object



43
44
45
# 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) ⇒ Object



47
48
49
# 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) ⇒ Object

orders: [‘buy’, volume: ‘0.15’, price: ‘2955.0’, ‘sell’, volume: ‘0.16’, price: ‘2956’]



38
39
40
41
# 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