Class: WavesRubyClient::DataFeed
- Inherits:
-
Object
- Object
- WavesRubyClient::DataFeed
- Defined in:
- lib/waves_ruby_client/data_feed.rb
Overview
query data feed
Class Method Summary collapse
- .current_price ⇒ Object
-
.trade_history(count = 10) ⇒ Object
get history from data feed.
Class Method Details
.current_price ⇒ Object
4 5 6 |
# File 'lib/waves_ruby_client/data_feed.rb', line 4 def self.current_price trade_history(1).first.price end |
.trade_history(count = 10) ⇒ Object
get history from data feed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/waves_ruby_client/data_feed.rb', line 9 def self.trade_history(count = 10) params = [ '/trades', WavesRubyClient::AMOUNT_ASSET.url_id, WavesRubyClient::PRICE_ASSET.url_id, count ] WavesRubyClient::Api.instance.call_data_feed(params.join('/')).map do |entry| WavesRubyClient::Order.new( id: entry['id'], price: entry['price'].to_f, timestamp: Time.at(entry['timestamp'] / 1000), amount: entry['amount'].to_f ) end end |