Class: Finnhub::Forex_Timeseries
- Inherits:
-
Timeseries
- Object
- Timeseries
- Finnhub::Forex_Timeseries
- Defined in:
- lib/Forex.rb
Instance Attribute Summary
Attributes inherited from Timeseries
Instance Method Summary collapse
-
#initialize(client:, symbol:, resolution: "D", count: nil, from: nil, to: nil, format: nil) ⇒ Forex_Timeseries
constructor
A new instance of Forex_Timeseries.
Methods inherited from Timeseries
#close, #high, #low, #open, #status, #volume
Constructor Details
#initialize(client:, symbol:, resolution: "D", count: nil, from: nil, to: nil, format: nil) ⇒ Forex_Timeseries
Returns a new instance of Forex_Timeseries.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/Forex.rb', line 44 def initialize(client:, symbol:, resolution: "D", count: nil, from: nil, to: nil, format: nil) url = "/forex/candle?symbol=#{symbol}&resolution=#{resolution}" url += "&count=#{count}" unless count.nil? url += "&from=#{from}" unless from.nil? url += "&to=#{to}" unless to.nil? url += "&format=#{format}" unless format.nil? @output = client.request(url) if @output.is_a?(Hash) && @output[:s] == "ok" @timestamps = @output[:t]&.map{|t| DateTime.strptime(t.to_s,'%s')} else @timestamps = [] end end |