Class: Coinigy::Market
Overview
Represents a Market of a exchange
Instance Attribute Summary collapse
-
#exch_code ⇒ Object
Returns the value of attribute exch_code.
-
#exch_id ⇒ Object
Returns the value of attribute exch_id.
-
#exch_name ⇒ Object
Returns the value of attribute exch_name.
-
#exchange ⇒ Object
Relations.
-
#exchmkt_id ⇒ Object
Returns the value of attribute exchmkt_id.
-
#mkt_id ⇒ Object
Returns the value of attribute mkt_id.
-
#mkt_name ⇒ Object
Returns the value of attribute mkt_name.
Attributes inherited from Model
Instance Method Summary collapse
- #alert(price, note = '') ⇒ Object
- #asks ⇒ Object
- #asks_and_bids ⇒ Object
- #attributes ⇒ Object
- #bids ⇒ Object
- #data ⇒ Object
- #history ⇒ Object
- #open_alerts(reload = false) ⇒ Object
- #ticker ⇒ Object
Methods inherited from Model
#errors?, #initialize, #inspect, #save
Constructor Details
This class inherits a constructor from Coinigy::Model
Instance Attribute Details
#exch_code ⇒ Object
Returns the value of attribute exch_code
4 5 6 |
# File 'lib/coinigy/market.rb', line 4 def exch_code @exch_code end |
#exch_id ⇒ Object
Returns the value of attribute exch_id
4 5 6 |
# File 'lib/coinigy/market.rb', line 4 def exch_id @exch_id end |
#exch_name ⇒ Object
Returns the value of attribute exch_name
4 5 6 |
# File 'lib/coinigy/market.rb', line 4 def exch_name @exch_name end |
#exchange ⇒ Object
Relations
7 8 9 |
# File 'lib/coinigy/market.rb', line 7 def exchange @exchange end |
#exchmkt_id ⇒ Object
Returns the value of attribute exchmkt_id
4 5 6 |
# File 'lib/coinigy/market.rb', line 4 def exchmkt_id @exchmkt_id end |
#mkt_id ⇒ Object
Returns the value of attribute mkt_id
4 5 6 |
# File 'lib/coinigy/market.rb', line 4 def mkt_id @mkt_id end |
#mkt_name ⇒ Object
Returns the value of attribute mkt_name
4 5 6 |
# File 'lib/coinigy/market.rb', line 4 def mkt_name @mkt_name end |
Instance Method Details
#alert(price, note = '') ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/coinigy/market.rb', line 64 def alert(price, note = '') Coinigy::Alert.new('exch_code' => exch_code, 'mkt_name' => mkt_name, 'price' => price, 'alert_note' => note, 'subscription' => exchange.subscription).place end |
#asks ⇒ Object
25 26 27 |
# File 'lib/coinigy/market.rb', line 25 def asks get_data(:asks)['asks'] end |
#asks_and_bids ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/coinigy/market.rb', line 33 def asks_and_bids orders_data = get_data(:orders) { asks: orders_data['asks'], bids: orders_data['bids'] } end |
#attributes ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/coinigy/market.rb', line 12 def attributes { 'exch_id' => exch_id, 'exch_name' => exch_name, 'exch_code' => exch_code, 'mkt_id' => mkt_id, 'mkt_name' => mkt_name, 'exchmkt_id' => exchmkt_id } end |
#bids ⇒ Object
29 30 31 |
# File 'lib/coinigy/market.rb', line 29 def bids get_data(:bids)['bids'] end |
#data ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/coinigy/market.rb', line 41 def data all_data = get_data(:all) { history: all_data['history'], asks: all_data['asks'], bids: all_data['bids'] } end |
#history ⇒ Object
21 22 23 |
# File 'lib/coinigy/market.rb', line 21 def history get_data(:history)['history'] end |
#open_alerts(reload = false) ⇒ Object
72 73 74 |
# File 'lib/coinigy/market.rb', line 72 def open_alerts(reload = false) exchange.subscription.open_alerts(reload).select { |alert| alert.mkt_name == mkt_name } end |
#ticker ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/coinigy/market.rb', line 50 def ticker values = exchange.subscription.client.ticker('exchange_code' => exch_code, 'exchange_market' => mkt_name).data.first { last_trade: values['last_trade'], high_trade: values['high_trade'], low_trade: values['low_trade'], volume: values['current_volume'], timestamp: values['timestamp'], ask: values['ask'], bid: values['bid'] } end |