Class: QuidaxMarkets

Inherits:
QuidaxBaseObject show all
Defined in:
lib/quidax/objects/markets.rb

Overview

Object for markets

Instance Attribute Summary

Attributes inherited from QuidaxBaseObject

#quidax

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from QuidaxBaseObject

get_request, #initialize, post_request, put_request, url

Constructor Details

This class inherits a constructor from QuidaxBaseObject

Class Method Details

.get_all(q_object:) ⇒ Object



34
35
36
# File 'lib/quidax/objects/markets.rb', line 34

def self.get_all(q_object:)
  get_request(q_object, API::MARKET_PATH)
end

.get_all_tickers(q_object:) ⇒ Object



38
39
40
41
# File 'lib/quidax/objects/markets.rb', line 38

def self.get_all_tickers(q_object:)
  path = "#{API::MARKET_PATH}/tickers"
  get_request(q_object, path)
end

.get_depth_for_a_market(q_object:, market:, query: nil) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/quidax/objects/markets.rb', line 104

def self.get_depth_for_a_market(q_object:, market:, query: nil)
  query ||= {
    limit: 10
  }
  query.stringify_keys!
  Utils.check_missing_keys(required_keys: %w[limit], keys: query.keys, field: "query")
  Utils.validate_value_in_range(range: 1..10_000, value: query["limit"], field: 'query["limit"]')
  path = "#{API::MARKET_PATH}/#{market}/depth"

  get_request(q_object, path, query)
end

.get_k_line(q_object:, market:, query: nil) ⇒ Object

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/quidax/objects/markets.rb', line 48

def self.get_k_line(q_object:, market:, query: nil)
  query ||= {
    period: 1,
    limit: 30
  }

  query.stringify_keys!

  Utils.check_missing_keys(required_keys: %w[period limit], keys: query.keys, field: "query")
  allowed_periods = [1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10_080]
  Utils.validate_value_in_array(array: allowed_periods, value: query["period"], field: "period")

  raise ArgumentError, "limit must be in range 1..10_00" unless (1..10_000).include?(query["limit"])

  path = "#{API::MARKET_PATH}/#{market}/k"

  get_request(q_object, path, query)
end

.get_k_line_with_pending_trades(q_object:, market:, trade_id:, query: nil) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/quidax/objects/markets.rb', line 67

def self.get_k_line_with_pending_trades(q_object:, market:, trade_id:, query: nil)
  query ||= {
    period: 1,
    limit: 30
  }
  query.stringify_keys!

  Utils.check_missing_keys(required_keys: %w[period limit], keys: query.keys, field: "query")
  allowed_periods = [1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10_080]

  Utils.validate_value_in_array(array: allowed_periods, value: query["period"], field: "period")

  Utils.validate_value_in_range(range: 1..10_000, value: query["limit"], field: 'query["limit"]')

  path = "#{API::MARKET_PATH}/#{market}/k_with_pending_trades/#{trade_id}"

  get_request(q_object, path, query)
end

.get_orderbook_items(q_object:, market:, query: nil) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/quidax/objects/markets.rb', line 86

def self.get_orderbook_items(q_object:, market:, query: nil)
  query ||= {
    ask_limit: "20",
    bids_limit: "20"
  }

  query.stringify_keys!

  Utils.check_missing_keys(required_keys: %w[ask_limit bids_limit], keys: query.keys, field: "query")

  Utils.validate_value_in_range(range: 1..200, value: query["ask_limit"], field: 'query["ask_limit"]')
  Utils.validate_value_in_range(range: 1..200, value: query["bids_limit"], field: 'query["bids_limit"]')

  path = "#{API::MARKET_PATH}/#{market}/order_book"

  get_request(q_object, path, query)
end

.get_ticker(q_object:, market:) ⇒ Object



43
44
45
46
# File 'lib/quidax/objects/markets.rb', line 43

def self.get_ticker(q_object:, market:)
  path = "#{API::MARKET_PATH}/tickers/#{market}"
  get_request(q_object, path)
end

Instance Method Details

#get_allObject



5
6
7
# File 'lib/quidax/objects/markets.rb', line 5

def get_all
  QuidaxMarkets.get_all(q_object: @quidax)
end

#get_all_tickersObject



9
10
11
# File 'lib/quidax/objects/markets.rb', line 9

def get_all_tickers
  QuidaxMarkets.get_all_tickers(q_object: @quidax)
end

#get_depth_for_a_market(market:, query: nil) ⇒ Object



30
31
32
# File 'lib/quidax/objects/markets.rb', line 30

def get_depth_for_a_market(market:, query: nil)
  QuidaxMarkets.get_depth_for_a_market(q_object: @quidax, market: market, query: query)
end

#get_k_line(market:, query: nil) ⇒ Object



17
18
19
# File 'lib/quidax/objects/markets.rb', line 17

def get_k_line(market:, query: nil)
  QuidaxMarkets.get_k_line(q_object: @quidax, market: market, query: query)
end

#get_k_line_with_pending_trades(market:, trade_id:, query: nil) ⇒ Object



21
22
23
24
# File 'lib/quidax/objects/markets.rb', line 21

def get_k_line_with_pending_trades(market:, trade_id:, query: nil)
  QuidaxMarkets.get_k_line_with_pending_trades(q_object: @quidax, market: market, trade_id: trade_id,
                                               query: query)
end

#get_orderbook_items(market:, query: nil) ⇒ Object



26
27
28
# File 'lib/quidax/objects/markets.rb', line 26

def get_orderbook_items(market:, query: nil)
  QuidaxMarkets.get_orderbook_items(q_object: @quidax, market: market, query: query)
end

#get_ticker(market:) ⇒ Object



13
14
15
# File 'lib/quidax/objects/markets.rb', line 13

def get_ticker(market:)
  QuidaxMarkets.get_ticker(q_object: @quidax, market: market)
end