Class: CoinSync::PriceLoaders::Cryptowatch
- Inherits:
-
Base
- Object
- Base
- CoinSync::PriceLoaders::Cryptowatch
show all
- Defined in:
- lib/coinsync/price_loaders/cryptowatch.rb
Instance Method Summary
collapse
Methods inherited from Base
#convert_price, #finalize, #get_price, register_price_loader
Constructor Details
#initialize(options) ⇒ Cryptowatch
Returns a new instance of Cryptowatch.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/coinsync/price_loaders/cryptowatch.rb', line 9
def initialize(options)
options.currency = options.currency&.upcase || 'USD'
options.exchange ||= 'bitfinex'
super
Utils.lazy_require(self, 'cointools')
@cryptowatch ||= CoinTools::Cryptowatch.new
end
|
Instance Method Details
#cache_name ⇒ Object
20
21
22
|
# File 'lib/coinsync/price_loaders/cryptowatch.rb', line 20
def cache_name
"cryptowatch-#{@options.exchange}-#{@options.currency.downcase}"
end
|
#currency ⇒ Object
24
25
26
|
# File 'lib/coinsync/price_loaders/cryptowatch.rb', line 24
def currency
FiatCurrency.new(@options.currency)
end
|
#fetch_price(coin, time) ⇒ Object
28
29
30
31
|
# File 'lib/coinsync/price_loaders/cryptowatch.rb', line 28
def fetch_price(coin, time)
result = @cryptowatch.get_price_fast(@options.exchange, coin.code.downcase + @options.currency.downcase, time)
[result.price, result.time.to_i]
end
|