Class: Trader::Market

Inherits:
Book
  • Object
show all
Defined in:
lib/trade-o-matic/core/market.rb

Instance Attribute Summary collapse

Attributes inherited from Book

#ask_slope, #bid_slope, #pair

Instance Method Summary collapse

Methods inherited from Book

#add_ask, #add_bid, #add_transaction, #prepare, #volume

Constructor Details

#initialize(_backend, _pair) ⇒ Market

Returns a new instance of Market.



5
6
7
8
# File 'lib/trade-o-matic/core/market.rb', line 5

def initialize(_backend, _pair)
  super _pair
  @backend = _backend
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



3
4
5
# File 'lib/trade-o-matic/core/market.rb', line 3

def backend
  @backend
end

Instance Method Details

#base_currencyObject



14
15
16
# File 'lib/trade-o-matic/core/market.rb', line 14

def base_currency
  pair.base
end

#bookObject



10
11
12
# File 'lib/trade-o-matic/core/market.rb', line 10

def book
  self
end

#on_transactionObject



27
28
29
30
31
# File 'lib/trade-o-matic/core/market.rb', line 27

def on_transaction
  backend.listen_transactions(pair) do |raw|
    yield TransactionEvent.new raw, nil
  end
end

#quote_currencyObject



18
19
20
# File 'lib/trade-o-matic/core/market.rb', line 18

def quote_currency
  pair.quote
end

#refresh!Object



22
23
24
25
# File 'lib/trade-o-matic/core/market.rb', line 22

def refresh!
  backend.fill_book(book)
  self
end