Class: HexTokenBot::ChannelClient::OkcoinClient
- Inherits:
-
Object
- Object
- HexTokenBot::ChannelClient::OkcoinClient
- Defined in:
- lib/hex_token_bot/channel_client/okcoin_client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #get_market_order_book(market_code, asks_limit = nil, bids_limit = nil) ⇒ Object
- #get_order_newest(market_code) ⇒ Object
-
#initialize(options = {}) ⇒ OkcoinClient
constructor
A new instance of OkcoinClient.
- #send_order(side, market_code, price, volume) ⇒ Object
- #send_order_buy(market_code, price, volume) ⇒ Object
- #send_order_sell(market_code, price, volume) ⇒ Object
-
#send_orders_multi(orders, market_code) ⇒ Object
orders: [‘buy’, amount: ‘0.15’, price: ‘2955.0’, ‘sell’, volume: ‘0.16’, price: ‘2956’].
Constructor Details
#initialize(options = {}) ⇒ OkcoinClient
Returns a new instance of OkcoinClient.
6 7 8 9 10 11 12 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 6 def initialize( = {}) url = ['endpoint'] || HexTokenBot.data_channels['okcoin']['endpoint'] api_key = ['access_key'] || HexTokenBot.data_channels['okcoin']['access_key'] secret_key = ['secret_key'] || HexTokenBot.data_channels['okcoin']['secret_key'] @client = Okcoin::Client.new url: url, api_key: api_key, secret_key: secret_key end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 4 def client @client end |
Instance Method Details
#get_market_order_book(market_code, asks_limit = nil, bids_limit = nil) ⇒ Object
15 16 17 18 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 15 def get_market_order_book(market_code, asks_limit = nil , bids_limit = nil) rep = client.trades(symbol: market_code, since: nil) rep end |
#get_order_newest(market_code) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 20 def get_order_newest(market_code) rep = client.trades(symbol: market_code, since: nil) if rep.class == Array and !rep.empty? count = rep.size rep[count - 1] else [] end end |
#send_order(side, market_code, price, volume) ⇒ Object
30 31 32 33 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 30 def send_order(side, market_code, price, volume) rep = client.trade(symbol: market_code, type: side, price: price, amount: volume) rep end |
#send_order_buy(market_code, price, volume) ⇒ Object
41 42 43 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 41 def send_order_buy(market_code, price, volume) send_order('buy', market_code, price, volume) end |
#send_order_sell(market_code, price, volume) ⇒ Object
45 46 47 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 45 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’, amount: ‘0.15’, price: ‘2955.0’, ‘sell’, volume: ‘0.16’, price: ‘2956’]
36 37 38 39 |
# File 'lib/hex_token_bot/channel_client/okcoin_client.rb', line 36 def send_orders_multi(orders, market_code) rep = client.batch_trade(symbol: market_code, orders_data: orders) rep end |