Class: DataStream::Api

Inherits:
Object
  • Object
show all
Includes:
DssUtilities
Defined in:
lib/data_stream_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DssUtilities

#parseDate

Constructor Details

#initializeApi

Returns a new instance of Api.



81
82
83
# File 'lib/data_stream_api.rb', line 81

def initialize
  @session = Session.new
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



79
80
81
# File 'lib/data_stream_api.rb', line 79

def session
  @session
end

Instance Method Details

#isin_stream(isin, date_start, date_end, options = {}) ⇒ Object



114
115
116
# File 'lib/data_stream_api.rb', line 114

def isin_stream(isin, date_start, date_end, options={})
  stream isin, date_start, date_end, options
end

#ric_stream(ric, date_start, date_end, options = {}) ⇒ Object



110
111
112
# File 'lib/data_stream_api.rb', line 110

def ric_stream(ric, date_start, date_end, options={})
  stream "<#{ric}>", date_start, date_end, options
end

#stream(value, date_start, date_end, options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/data_stream_api.rb', line 85

def stream(value, date_start, date_end, options={})
  date = {
    "End" => date_end,
    "Frequency" => "",
    "Kind" => 1,
    "Start" => date_start
  }

  instrument = {
    "Properties" => [
      {
        "Key" => "IsSymbolSet",
        "Value" => true
      }
    ],
    "Value" => value
  }
  stream = Stream.new @session, instrument, date
  stream.result["DataResponse"]["Dates"].each_with_index.map do |date, i|
    { date: parseDate(date, options),
      value: stream.result["DataResponse"]["DataTypeValues"][0]["SymbolValues"][0]["Value"][i]
    }
  end
end