lib/cotcube-bardata/daily.rb in cotcube-bardata-0.1.4 vs lib/cotcube-bardata/daily.rb in cotcube-bardata-0.1.5

- old
+ new

@@ -2,11 +2,14 @@ module Cotcube # Missing top level documentation comment module Bardata # just reads bardata/daily/<id>/<contract>.csv - def provide_daily(contract:, symbol: nil, id: nil, timezone: Time.find_zone('America/Chicago'), config: init) + def provide_daily(contract:, + symbol: nil, id: nil, + timezone: Time.find_zone('America/Chicago'), + config: init) contract = contract.to_s.upcase unless contract.is_a?(String) && [3, 5].include?(contract.size) raise ArgumentError, "Contract '#{contract}' is bogus, should be like 'M21' or 'ESM21'" end @@ -94,9 +97,10 @@ raise ArgumentError, 'Selector must be either :volume or :oi' unless selector.is_a?(Symbol) && %i[volume oi].include?(selector) sym = get_id_set(symbol: symbol, id: id) id = sym[:id] + # noinspection RubyNilAnalysis data = continuous(id: id, config: config).map do |x| { date: x[:date], volume: x[:contracts].sort_by { |z| - z[:volume] }[0..4].compact.reject { |z| z[:volume].zero? }, oi: x[:contracts].sort_by { |z| - z[:oi] }[0..4].compact.reject { |z| z[:oi].zero? }