Class: Bberg::Client
- Inherits:
-
Object
- Object
- Bberg::Client
- Defined in:
- lib/bberg/client.rb
Overview
Main class for making synchronous bberg data requests.
Instance Method Summary collapse
-
#get_holidays_for_calendar(currency, calendar, start_date, end_date) ⇒ Array
Convencience method to perform a reference data request for holiday calendar data.
-
#historical_data_request(identifiers, start_time, end_time, options = {}) ⇒ Hash
Perform a historical data request.
-
#initialize(host = "localhost", port = 8194) ⇒ Client
constructor
Create a new instance of Client.
-
#reference_data_request(identifiers, options) ⇒ Hash
Perform a reference data request.
Constructor Details
#initialize(host = "localhost", port = 8194) ⇒ Client
Create a new instance of Client
13 14 15 16 17 |
# File 'lib/bberg/client.rb', line 13 def initialize(host = "localhost", port = 8194) @session_options = Bberg::Native::SessionOptions.new @session_options.setServerHost("localhost") @session_options.setServerPort(8194) end |
Instance Method Details
#get_holidays_for_calendar(currency, calendar, start_date, end_date) ⇒ Array
Convencience method to perform a reference data request for holiday calendar data.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bberg/client.rb', line 45 def get_holidays_for_calendar(currency, calendar, start_date, end_date) overrides = Hash[ "CALENDAR_START_DATE", start_date, "CALENDAR_END_DATE", end_date ] overrides["SETTLEMENT_CALENDAR_CODE"] = calendar unless calendar.nil? = Hash[ :fields => ["CALENDAR_HOLIDAYS"]] [:overrides] = overrides response = self.reference_data_request(currency, ) result = response[currency]["CALENDAR_HOLIDAYS"].map {|o| o["Holiday Date"]} result end |
#historical_data_request(identifiers, start_time, end_time, options = {}) ⇒ Hash
Perform a historical data request.
25 26 27 28 |
# File 'lib/bberg/client.rb', line 25 def historical_data_request(identifiers, start_time, end_time, = {}) request = Bberg::Requests::HistoricalDataRequest.new(@session_options, identifiers, start_time, end_time, ) request.perform_request end |
#reference_data_request(identifiers, options) ⇒ Hash
Perform a reference data request.
34 35 36 37 |
# File 'lib/bberg/client.rb', line 34 def reference_data_request(identifiers, ) request = Bberg::Requests::ReferenceDataRequest.new(@session_options, identifiers, ) request.perform_request end |