Module: Yobit

Defined in:
lib/yobit.rb,
lib/yobit/version.rb

Defined Under Namespace

Classes: ApiConfig

Constant Summary collapse

PUBLIC_API_URL =
'https://yobit.net/api/3/'.freeze
TRADE_API_URL =
'https://yobit.net/tapi/'.freeze
VERSION =
"0.1.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



20
21
22
# File 'lib/yobit.rb', line 20

def config
  @config
end

Class Method Details

.active_orders(pair) ⇒ Object



57
58
59
# File 'lib/yobit.rb', line 57

def self.active_orders(pair)
  get('ActiveOrders', client: trade_client, pair: pair)
end

.cancel_order(order_id) ⇒ Object



65
66
67
# File 'lib/yobit.rb', line 65

def self.cancel_order(order_id)
  post('CancelOrder', client: trade_client, order_id: order_id)
end

.depth(pairs_list:, limit: 150) ⇒ Object



37
38
39
40
41
# File 'lib/yobit.rb', line 37

def self.depth(pairs_list:, limit: 150)
  limit = 2000 if (limit > 2000)
  currencies = prepare_pairs(pairs_list)
  get('depth' + currencies, limit: limit)
end

.get_deposit_address(coin_name:, need_new: 0) ⇒ Object



81
82
83
# File 'lib/yobit.rb', line 81

def self.get_deposit_address(coin_name:, need_new: 0)
  get('GetDepositAddress', client: trade_client, coinName: coin_name, need_new: need_new)
end

.get_infoObject



49
50
51
# File 'lib/yobit.rb', line 49

def self.get_info
  get('getInfo', client: trade_client)
end

.infoObject



28
29
30
# File 'lib/yobit.rb', line 28

def self.info
  get('info')
end

.order_info(order_id) ⇒ Object



61
62
63
# File 'lib/yobit.rb', line 61

def self.order_info(order_id)
  get('OrderInfo', client: trade_client, order_id: order_id)
end

.setup {|config| ... } ⇒ Object

Yields:



23
24
25
26
# File 'lib/yobit.rb', line 23

def self.setup
  @config ||= ApiConfig.new
  yield config
end

.ticker(pairs_list) ⇒ Object



32
33
34
35
# File 'lib/yobit.rb', line 32

def self.ticker(pairs_list)
  currencies = prepare_pairs(pairs_list)
  get('ticker' + currencies)
end

.trade(pair:, type:, rate:, amount:) ⇒ Object



53
54
55
# File 'lib/yobit.rb', line 53

def self.trade(pair:, type:, rate:, amount:)
  post('Trade', client: trade_client, pair: pair, type: type, rate: rate, amount: amount)
end

.trade_history(from: 0, count: 1000, from_id: 0, end_id: 1000, order: "DESC", since: 0, end_time: Time.new(3000).to_i, pair:) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/yobit.rb', line 69

def self.trade_history(from: 0, count: 1000, from_id: 0, end_id: 1000, order: "DESC", since: 0, end_time: Time.new(3000).to_i, pair:)
  post('TradeHistory', client: trade_client,
       from:     from, 
       count:    count, 
       from_id:  from_id,
       end_id:   end_id, 
       order:    order, 
       since:    since, 
       end_time: end_time,
       pair:     pair)
end

.trades(pairs_list:, limit: 150) ⇒ Object



43
44
45
46
47
# File 'lib/yobit.rb', line 43

def self.trades(pairs_list:, limit: 150)
  limit = 2000 if (limit > 2000)
  currencies = prepare_pairs(pairs_list)
  get('trades' + currencies, limit: limit)
end

.withdraw_coins_to_address(coin_name:, amount:, address:) ⇒ Object



85
86
87
# File 'lib/yobit.rb', line 85

def self.withdraw_coins_to_address(coin_name:, amount:, address:)
  post('WithdrawCoinsToAddress', client: trade_client, coinName: coin_name, amount: amount, address: address)
end