Class: Intrinio::ForexApi

Inherits:
Object
  • Object
show all
Defined in:
lib/intrinio-sdk/api/forex_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ForexApi



19
20
21
# File 'lib/intrinio-sdk/api/forex_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/intrinio-sdk/api/forex_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_forex_currencies(opts = {}) ⇒ ApiResponseForexCurrencies

Forex Currencies Returns a list of forex currencies for which prices are available.



27
28
29
30
# File 'lib/intrinio-sdk/api/forex_api.rb', line 27

def get_forex_currencies(opts = {})
  data, _status_code, _headers = get_forex_currencies_with_http_info(opts)
  return data
end

#get_forex_currencies_with_http_info(opts = {}) ⇒ Array<(ApiResponseForexCurrencies, Fixnum, Hash)>

Forex Currencies Returns a list of forex currencies for which prices are available.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/intrinio-sdk/api/forex_api.rb', line 36

def get_forex_currencies_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ForexApi.get_forex_currencies ..."
  end
  # resource path
  local_var_path = "/forex/currencies"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['ApiKeyAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ApiResponseForexCurrencies')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ForexApi#get_forex_currencies\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_forex_pairs(opts = {}) ⇒ ApiResponseForexPairs

Forex Currency Pairs Returns a list of currency pairs used to request foreign exchange (forex) market price data. The currency that is used as the reference is called quote currency and the currency that is quoted in relation is called the base currency. For example, in the pair code “EURGBP” with a price of 0.88, one Euro (base currency) can be exchanged for 0.88 British Pounds (quote currency).



74
75
76
77
# File 'lib/intrinio-sdk/api/forex_api.rb', line 74

def get_forex_pairs(opts = {})
  data, _status_code, _headers = get_forex_pairs_with_http_info(opts)
  return data
end

#get_forex_pairs_with_http_info(opts = {}) ⇒ Array<(ApiResponseForexPairs, Fixnum, Hash)>

Forex Currency Pairs Returns a list of currency pairs used to request foreign exchange (forex) market price data. The currency that is used as the reference is called quote currency and the currency that is quoted in relation is called the base currency. For example, in the pair code “EURGBP” with a price of 0.88, one Euro (base currency) can be exchanged for 0.88 British Pounds (quote currency).



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/intrinio-sdk/api/forex_api.rb', line 83

def get_forex_pairs_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ForexApi.get_forex_pairs ..."
  end
  # resource path
  local_var_path = "/forex/pairs"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['ApiKeyAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ApiResponseForexPairs')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ForexApi#get_forex_pairs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_forex_prices(pair, timeframe, opts = {}) ⇒ ApiResponseForexPrices

Forex Currency Prices Provides a list of forex price quotes for a given forex currency pair and timeframe.

Options Hash (opts):

  • :timezone (String)

    Returns trading times in this timezone (default to UTC)

  • :start_date (Date)

    Return Forex Prices on or after this date

  • :start_time (String)

    Return Forex Prices at or after this time (24-hour in &#39;hh:mm&#39; format, UTC timezone)

  • :end_date (Date)

    Return Forex Prices on or before this date

  • :end_time (String)

    Return Forex Prices at or before this time (24-hour in &#39;hh:mm&#39; format, UTC timezone)

  • :page_size (Integer)

    The number of results to return (default to 100)

  • :next_page (String)

    Gets the next page of data from a previous API call



130
131
132
133
# File 'lib/intrinio-sdk/api/forex_api.rb', line 130

def get_forex_prices(pair, timeframe, opts = {})
  data, _status_code, _headers = get_forex_prices_with_http_info(pair, timeframe, opts)
  return data
end

#get_forex_prices_with_http_info(pair, timeframe, opts = {}) ⇒ Array<(ApiResponseForexPrices, Fixnum, Hash)>

Forex Currency Prices Provides a list of forex price quotes for a given forex currency pair and timeframe.

Options Hash (opts):

  • :timezone (String)

    Returns trading times in this timezone

  • :start_date (Date)

    Return Forex Prices on or after this date

  • :start_time (String)

    Return Forex Prices at or after this time (24-hour in &#39;hh:mm&#39; format, UTC timezone)

  • :end_date (Date)

    Return Forex Prices on or before this date

  • :end_time (String)

    Return Forex Prices at or before this time (24-hour in &#39;hh:mm&#39; format, UTC timezone)

  • :page_size (Integer)

    The number of results to return

  • :next_page (String)

    Gets the next page of data from a previous API call



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/intrinio-sdk/api/forex_api.rb', line 148

def get_forex_prices_with_http_info(pair, timeframe, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: ForexApi.get_forex_prices ..."
  end
  # verify the required parameter 'pair' is set
  if @api_client.config.client_side_validation && pair.nil?
    fail ArgumentError, "Missing the required parameter 'pair' when calling ForexApi.get_forex_prices"
  end
  # verify the required parameter 'timeframe' is set
  if @api_client.config.client_side_validation && timeframe.nil?
    fail ArgumentError, "Missing the required parameter 'timeframe' when calling ForexApi.get_forex_prices"
  end
  # verify enum value
  if @api_client.config.client_side_validation && !['m1', 'm5', 'm15', 'm30', 'H1', 'H2', 'H3', 'H4', 'H6', 'H8', 'D1', 'W1', 'M1'].include?(timeframe)
    fail ArgumentError, "invalid value for 'timeframe', must be one of m1, m5, m15, m30, H1, H2, H3, H4, H6, H8, D1, W1, M1"
  end
  if @api_client.config.client_side_validation && opts[:'timezone'] && !['Africa/Algiers', 'Africa/Cairo', 'Africa/Casablanca', 'Africa/Harare', 'Africa/Johannesburg', 'Africa/Monrovia', 'Africa/Nairobi', 'America/Argentina/Buenos_Aires', 'America/Bogota', 'America/Caracas', 'America/Chicago', 'America/Chihuahua', 'America/Denver', 'America/Godthab', 'America/Guatemala', 'America/Guyana', 'America/Halifax', 'America/Indiana/Indianapolis', 'America/Juneau', 'America/La_Paz', 'America/Lima', 'America/Lima', 'America/Los_Angeles', 'America/Mazatlan', 'America/Mexico_City', 'America/Mexico_City', 'America/Monterrey', 'America/Montevideo', 'America/New_York', 'America/Phoenix', 'America/Regina', 'America/Santiago', 'America/Sao_Paulo', 'America/St_Johns', 'America/Tijuana', 'Asia/Almaty', 'Asia/Baghdad', 'Asia/Baku', 'Asia/Bangkok', 'Asia/Bangkok', 'Asia/Chongqing', 'Asia/Colombo', 'Asia/Dhaka', 'Asia/Dhaka', 'Asia/Hong_Kong', 'Asia/Irkutsk', 'Asia/Jakarta', 'Asia/Jerusalem', 'Asia/Kabul', 'Asia/Kamchatka', 'Asia/Karachi', 'Asia/Karachi', 'Asia/Kathmandu', 'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Krasnoyarsk', 'Asia/Kuala_Lumpur', 'Asia/Kuwait', 'Asia/Magadan', 'Asia/Muscat', 'Asia/Muscat', 'Asia/Novosibirsk', 'Asia/Rangoon', 'Asia/Riyadh', 'Asia/Seoul', 'Asia/Shanghai', 'Asia/Singapore', 'Asia/Srednekolymsk', 'Asia/Taipei', 'Asia/Tashkent', 'Asia/Tbilisi', 'Asia/Tehran', 'Asia/Tokyo', 'Asia/Tokyo', 'Asia/Tokyo', 'Asia/Ulaanbaatar', 'Asia/Urumqi', 'Asia/Vladivostok', 'Asia/Yakutsk', 'Asia/Yekaterinburg', 'Asia/Yerevan', 'Atlantic/Azores', 'Atlantic/Cape_Verde', 'Atlantic/South_Georgia', 'Australia/Adelaide', 'Australia/Brisbane', 'Australia/Darwin', 'Australia/Hobart', 'Australia/Melbourne', 'Australia/Melbourne', 'Australia/Perth', 'Australia/Sydney', 'Etc/UTC', 'UTC', 'Europe/Amsterdam', 'Europe/Athens', 'Europe/Belgrade', 'Europe/Berlin', 'Europe/Berlin', 'Europe/Bratislava', 'Europe/Brussels', 'Europe/Bucharest', 'Europe/Budapest', 'Europe/Copenhagen', 'Europe/Dublin', 'Europe/Helsinki', 'Europe/Istanbul', 'Europe/Kaliningrad', 'Europe/Kiev', 'Europe/Lisbon', 'Europe/Ljubljana', 'Europe/London', 'Europe/London', 'Europe/Madrid', 'Europe/Minsk', 'Europe/Moscow', 'Europe/Moscow', 'Europe/Paris', 'Europe/Prague', 'Europe/Riga', 'Europe/Rome', 'Europe/Samara', 'Europe/Sarajevo', 'Europe/Skopje', 'Europe/Sofia', 'Europe/Stockholm', 'Europe/Tallinn', 'Europe/Vienna', 'Europe/Vilnius', 'Europe/Volgograd', 'Europe/Warsaw', 'Europe/Zagreb', 'Pacific/Apia', 'Pacific/Auckland', 'Pacific/Auckland', 'Pacific/Chatham', 'Pacific/Fakaofo', 'Pacific/Fiji', 'Pacific/Guadalcanal', 'Pacific/Guam', 'Pacific/Honolulu', 'Pacific/Majuro', 'Pacific/Midway', 'Pacific/Midway', 'Pacific/Noumea', 'Pacific/Pago_Pago', 'Pacific/Port_Moresby', 'Pacific/Tongatapu'].include?(opts[:'timezone'])
    fail ArgumentError, 'invalid value for "timezone", must be one of Africa/Algiers, Africa/Cairo, Africa/Casablanca, Africa/Harare, Africa/Johannesburg, Africa/Monrovia, Africa/Nairobi, America/Argentina/Buenos_Aires, America/Bogota, America/Caracas, America/Chicago, America/Chihuahua, America/Denver, America/Godthab, America/Guatemala, America/Guyana, America/Halifax, America/Indiana/Indianapolis, America/Juneau, America/La_Paz, America/Lima, America/Lima, America/Los_Angeles, America/Mazatlan, America/Mexico_City, America/Mexico_City, America/Monterrey, America/Montevideo, America/New_York, America/Phoenix, America/Regina, America/Santiago, America/Sao_Paulo, America/St_Johns, America/Tijuana, Asia/Almaty, Asia/Baghdad, Asia/Baku, Asia/Bangkok, Asia/Bangkok, Asia/Chongqing, Asia/Colombo, Asia/Dhaka, Asia/Dhaka, Asia/Hong_Kong, Asia/Irkutsk, Asia/Jakarta, Asia/Jerusalem, Asia/Kabul, Asia/Kamchatka, Asia/Karachi, Asia/Karachi, Asia/Kathmandu, Asia/Kolkata, Asia/Kolkata, Asia/Kolkata, Asia/Kolkata, Asia/Krasnoyarsk, Asia/Kuala_Lumpur, Asia/Kuwait, Asia/Magadan, Asia/Muscat, Asia/Muscat, Asia/Novosibirsk, Asia/Rangoon, Asia/Riyadh, Asia/Seoul, Asia/Shanghai, Asia/Singapore, Asia/Srednekolymsk, Asia/Taipei, Asia/Tashkent, Asia/Tbilisi, Asia/Tehran, Asia/Tokyo, Asia/Tokyo, Asia/Tokyo, Asia/Ulaanbaatar, Asia/Urumqi, Asia/Vladivostok, Asia/Yakutsk, Asia/Yekaterinburg, Asia/Yerevan, Atlantic/Azores, Atlantic/Cape_Verde, Atlantic/South_Georgia, Australia/Adelaide, Australia/Brisbane, Australia/Darwin, Australia/Hobart, Australia/Melbourne, Australia/Melbourne, Australia/Perth, Australia/Sydney, Etc/UTC, UTC, Europe/Amsterdam, Europe/Athens, Europe/Belgrade, Europe/Berlin, Europe/Berlin, Europe/Bratislava, Europe/Brussels, Europe/Bucharest, Europe/Budapest, Europe/Copenhagen, Europe/Dublin, Europe/Helsinki, Europe/Istanbul, Europe/Kaliningrad, Europe/Kiev, Europe/Lisbon, Europe/Ljubljana, Europe/London, Europe/London, Europe/Madrid, Europe/Minsk, Europe/Moscow, Europe/Moscow, Europe/Paris, Europe/Prague, Europe/Riga, Europe/Rome, Europe/Samara, Europe/Sarajevo, Europe/Skopje, Europe/Sofia, Europe/Stockholm, Europe/Tallinn, Europe/Vienna, Europe/Vilnius, Europe/Volgograd, Europe/Warsaw, Europe/Zagreb, Pacific/Apia, Pacific/Auckland, Pacific/Auckland, Pacific/Chatham, Pacific/Fakaofo, Pacific/Fiji, Pacific/Guadalcanal, Pacific/Guam, Pacific/Honolulu, Pacific/Majuro, Pacific/Midway, Pacific/Midway, Pacific/Noumea, Pacific/Pago_Pago, Pacific/Port_Moresby, Pacific/Tongatapu'
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 10000
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ForexApi.get_forex_prices, must be smaller than or equal to 10000.'
  end

  # resource path
  local_var_path = "/forex/prices/{pair}/{timeframe}".sub('{' + 'pair' + '}', pair.to_s).sub('{' + 'timeframe' + '}', timeframe.to_s)

  # query parameters
  query_params = {}
  query_params[:'timezone'] = opts[:'timezone'] if !opts[:'timezone'].nil?
  query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'start_time'] = opts[:'start_time'] if !opts[:'start_time'].nil?
  query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil?
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'next_page'] = opts[:'next_page'] if !opts[:'next_page'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['ApiKeyAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ApiResponseForexPrices')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ForexApi#get_forex_prices\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end