module Trader::MarketLoader

Public Instance Methods

available_markets() click to toggle source
# File lib/trade-o-matic/core/market_loader.rb, line 14
def available_markets
  @markets ||= backend.get_available_markets
end
has_market_for?(_pair, _quote=nil) click to toggle source
# File lib/trade-o-matic/core/market_loader.rb, line 9
def has_market_for?(_pair, _quote=nil)
  _pair = CurrencyPair.for_code _pair, _quote
  available_markets.include? _pair
end
market_for(_pair, _quote=nil) click to toggle source
# File lib/trade-o-matic/core/market_loader.rb, line 3
def market_for(_pair, _quote=nil)
  _pair = CurrencyPair.for_code _pair, _quote
  ensure_supported_market _pair
  Market.new(backend, _pair).refresh!
end

Private Instance Methods

ensure_supported_currency(_currency) click to toggle source
# File lib/trade-o-matic/core/market_loader.rb, line 24
def ensure_supported_currency(_currency)
  unless available_markets.any? { |m| m.quote == _currency || m.base == _currency }
    backend.not_supported _currency
  end
end
ensure_supported_market(_pair) click to toggle source
# File lib/trade-o-matic/core/market_loader.rb, line 20
def ensure_supported_market(_pair)
  backend.not_supported _pair unless has_market_for? _pair
end