Class: Intrinio::OptionsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ OptionsApi

Returns a new instance of OptionsApi.



19
20
21
# File 'lib/intrinio-sdk/api/options_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/options_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_options(symbol, opts = {}) ⇒ ApiResponseOptions

Options Returns the master list of option contracts for a given symbol.

Parameters:

  • symbol

    The option symbol, corresponding to the underlying security.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :type (String)

    The option contract type.

  • :strike (Float)

    The strike price of the option contract. This will return options contracts with strike price equal to this price.

  • :strike_greater_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices greater than this price.

  • :strike_less_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices less than this price.

  • :expiration (String)

    The expiration date of the option contract. This will return options contracts with expiration dates on this date.

  • :expiration_after (String)

    The expiration date of the option contract. This will return options contracts with expiration dates after this date.

  • :expiration_before (String)

    The expiration date of the option contract. This will return options contracts with expiration dates before this date.

  • :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

Returns:



37
38
39
40
# File 'lib/intrinio-sdk/api/options_api.rb', line 37

def get_options(symbol, opts = {})
  data, _status_code, _headers = get_options_with_http_info(symbol, opts)
  return data
end

#get_options_chain(symbol, expiration, opts = {}) ⇒ ApiResponseOptionsChain

Options Chain Returns all options contracts and their prices for the given symbol and expiration date.

Parameters:

  • symbol

    The option symbol, corresponding to the underlying security.

  • expiration

    The expiration date of the options contract

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :date (Date)

    The date of the option price. Returns option prices on this date.

  • :type (String)

    The option contract type.

  • :strike (Float)

    The strike price of the option contract. This will return options contracts with strike price equal to this price.

  • :strike_greater_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices greater than this price.

  • :strike_less_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices less than this price.

  • :moneyness (String)

    The moneyness of the options contracts to return. 'all' will return all options contracts. 'in_the_money' will return options contracts that are in the money (call options with strike prices below the current price, put options with strike prices above the current price). 'out_of_they_money' will return options contracts that are out of the money (call options with strike prices above the current price, put options with strike prices below the current price). 'near_the_money' will return options contracts that are $0.50 or less away from being in the money.

  • :page_size (Integer)

    The number of results to return (default to 100)

Returns:



123
124
125
126
# File 'lib/intrinio-sdk/api/options_api.rb', line 123

def get_options_chain(symbol, expiration, opts = {})
  data, _status_code, _headers = get_options_chain_with_http_info(symbol, expiration, opts)
  return data
end

#get_options_chain_with_http_info(symbol, expiration, opts = {}) ⇒ Array<(ApiResponseOptionsChain, Fixnum, Hash)>

Options Chain Returns all options contracts and their prices for the given symbol and expiration date.

Parameters:

  • symbol

    The option symbol, corresponding to the underlying security.

  • expiration

    The expiration date of the options contract

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :date (Date)

    The date of the option price. Returns option prices on this date.

  • :type (String)

    The option contract type.

  • :strike (Float)

    The strike price of the option contract. This will return options contracts with strike price equal to this price.

  • :strike_greater_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices greater than this price.

  • :strike_less_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices less than this price.

  • :moneyness (String)

    The moneyness of the options contracts to return. &#39;all&#39; will return all options contracts. &#39;in_the_money&#39; will return options contracts that are in the money (call options with strike prices below the current price, put options with strike prices above the current price). &#39;out_of_they_money&#39; will return options contracts that are out of the money (call options with strike prices above the current price, put options with strike prices below the current price). &#39;near_the_money&#39; will return options contracts that are $0.50 or less away from being in the money.

  • :page_size (Integer)

    The number of results to return

Returns:

  • (Array<(ApiResponseOptionsChain, Fixnum, Hash)>)

    ApiResponseOptionsChain data, response status code and response headers



141
142
143
144
145
146
147
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
# File 'lib/intrinio-sdk/api/options_api.rb', line 141

def get_options_chain_with_http_info(symbol, expiration, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OptionsApi.get_options_chain ..."
  end
  # verify the required parameter 'symbol' is set
  if @api_client.config.client_side_validation && symbol.nil?
    fail ArgumentError, "Missing the required parameter 'symbol' when calling OptionsApi.get_options_chain"
  end
  # verify the required parameter 'expiration' is set
  if @api_client.config.client_side_validation && expiration.nil?
    fail ArgumentError, "Missing the required parameter 'expiration' when calling OptionsApi.get_options_chain"
  end
  if @api_client.config.client_side_validation && opts[:'type'] && !['call', 'put'].include?(opts[:'type'])
    fail ArgumentError, 'invalid value for "type", must be one of call, put'
  end
  if @api_client.config.client_side_validation && opts[:'moneyness'] && !['all', 'in_the_money', 'out_of_the_money', 'near_the_money'].include?(opts[:'moneyness'])
    fail ArgumentError, 'invalid value for "moneyness", must be one of all, in_the_money, out_of_the_money, near_the_money'
  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 OptionsApi.get_options_chain, must be smaller than or equal to 10000.'
  end

  # resource path
  local_var_path = "/options/chain/{symbol}/{expiration}".sub('{' + 'symbol' + '}', symbol.to_s).sub('{' + 'expiration' + '}', expiration.to_s)

  # query parameters
  query_params = {}
  query_params[:'date'] = opts[:'date'] if !opts[:'date'].nil?
  query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
  query_params[:'strike'] = opts[:'strike'] if !opts[:'strike'].nil?
  query_params[:'strike_greater_than'] = opts[:'strike_greater_than'] if !opts[:'strike_greater_than'].nil?
  query_params[:'strike_less_than'] = opts[:'strike_less_than'] if !opts[:'strike_less_than'].nil?
  query_params[:'moneyness'] = opts[:'moneyness'] if !opts[:'moneyness'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].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 => 'ApiResponseOptionsChain')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OptionsApi#get_options_chain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_options_expirations(symbol, opts = {}) ⇒ ApiResponseOptionsExpirations

Options Expirations Returns all option contract expiration dates for a given symbol.

Parameters:

  • symbol

    The option symbol, corresponding to the underlying security.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :after (String)

    Return option contract expiration dates after this date.

  • :before (String)

    Return option contract expiration dates before this date.

Returns:



207
208
209
210
# File 'lib/intrinio-sdk/api/options_api.rb', line 207

def get_options_expirations(symbol, opts = {})
  data, _status_code, _headers = get_options_expirations_with_http_info(symbol, opts)
  return data
end

#get_options_expirations_with_http_info(symbol, opts = {}) ⇒ Array<(ApiResponseOptionsExpirations, Fixnum, Hash)>

Options Expirations Returns all option contract expiration dates for a given symbol.

Parameters:

  • symbol

    The option symbol, corresponding to the underlying security.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :after (String)

    Return option contract expiration dates after this date.

  • :before (String)

    Return option contract expiration dates before this date.

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/intrinio-sdk/api/options_api.rb', line 219

def get_options_expirations_with_http_info(symbol, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OptionsApi.get_options_expirations ..."
  end
  # verify the required parameter 'symbol' is set
  if @api_client.config.client_side_validation && symbol.nil?
    fail ArgumentError, "Missing the required parameter 'symbol' when calling OptionsApi.get_options_expirations"
  end
  # resource path
  local_var_path = "/options/expirations/{symbol}".sub('{' + 'symbol' + '}', symbol.to_s)

  # query parameters
  query_params = {}
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
  query_params[:'before'] = opts[:'before'] if !opts[:'before'].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 => 'ApiResponseOptionsExpirations')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OptionsApi#get_options_expirations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_options_prices(identifier, opts = {}) ⇒ ApiResponseOptionPrices

Option Prices Returns all option prices for a given option contract identifier.

Parameters:

  • identifier

    The Intrinio ID or code of the options contract to request prices for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_date (String)

    Return option contract prices on or after this date.

  • :end_date (String)

    Return option contract prices on or before this date.

  • :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

Returns:



268
269
270
271
# File 'lib/intrinio-sdk/api/options_api.rb', line 268

def get_options_prices(identifier, opts = {})
  data, _status_code, _headers = get_options_prices_with_http_info(identifier, opts)
  return data
end

#get_options_prices_with_http_info(identifier, opts = {}) ⇒ Array<(ApiResponseOptionPrices, Fixnum, Hash)>

Option Prices Returns all option prices for a given option contract identifier.

Parameters:

  • identifier

    The Intrinio ID or code of the options contract to request prices for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_date (String)

    Return option contract prices on or after this date.

  • :end_date (String)

    Return option contract prices on or before this date.

  • :page_size (Integer)

    The number of results to return

  • :next_page (String)

    Gets the next page of data from a previous API call

Returns:

  • (Array<(ApiResponseOptionPrices, Fixnum, Hash)>)

    ApiResponseOptionPrices data, response status code and response headers



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/intrinio-sdk/api/options_api.rb', line 282

def get_options_prices_with_http_info(identifier, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OptionsApi.get_options_prices ..."
  end
  # verify the required parameter 'identifier' is set
  if @api_client.config.client_side_validation && identifier.nil?
    fail ArgumentError, "Missing the required parameter 'identifier' when calling OptionsApi.get_options_prices"
  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 OptionsApi.get_options_prices, must be smaller than or equal to 10000.'
  end

  # resource path
  local_var_path = "/options/prices/{identifier}".sub('{' + 'identifier' + '}', identifier.to_s)

  # query parameters
  query_params = {}
  query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].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 => 'ApiResponseOptionPrices')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OptionsApi#get_options_prices\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_options_with_http_info(symbol, opts = {}) ⇒ Array<(ApiResponseOptions, Fixnum, Hash)>

Options Returns the master list of option contracts for a given symbol.

Parameters:

  • symbol

    The option symbol, corresponding to the underlying security.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :type (String)

    The option contract type.

  • :strike (Float)

    The strike price of the option contract. This will return options contracts with strike price equal to this price.

  • :strike_greater_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices greater than this price.

  • :strike_less_than (Float)

    The strike price of the option contract. This will return options contracts with strike prices less than this price.

  • :expiration (String)

    The expiration date of the option contract. This will return options contracts with expiration dates on this date.

  • :expiration_after (String)

    The expiration date of the option contract. This will return options contracts with expiration dates after this date.

  • :expiration_before (String)

    The expiration date of the option contract. This will return options contracts with expiration dates before this date.

  • :page_size (Integer)

    The number of results to return

  • :next_page (String)

    Gets the next page of data from a previous API call

Returns:

  • (Array<(ApiResponseOptions, Fixnum, Hash)>)

    ApiResponseOptions data, response status code and response headers



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
# File 'lib/intrinio-sdk/api/options_api.rb', line 56

def get_options_with_http_info(symbol, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OptionsApi.get_options ..."
  end
  # verify the required parameter 'symbol' is set
  if @api_client.config.client_side_validation && symbol.nil?
    fail ArgumentError, "Missing the required parameter 'symbol' when calling OptionsApi.get_options"
  end
  if @api_client.config.client_side_validation && opts[:'type'] && !['call', 'put'].include?(opts[:'type'])
    fail ArgumentError, 'invalid value for "type", must be one of call, put'
  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 OptionsApi.get_options, must be smaller than or equal to 10000.'
  end

  # resource path
  local_var_path = "/options/{symbol}".sub('{' + 'symbol' + '}', symbol.to_s)

  # query parameters
  query_params = {}
  query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
  query_params[:'strike'] = opts[:'strike'] if !opts[:'strike'].nil?
  query_params[:'strike_greater_than'] = opts[:'strike_greater_than'] if !opts[:'strike_greater_than'].nil?
  query_params[:'strike_less_than'] = opts[:'strike_less_than'] if !opts[:'strike_less_than'].nil?
  query_params[:'expiration'] = opts[:'expiration'] if !opts[:'expiration'].nil?
  query_params[:'expiration_after'] = opts[:'expiration_after'] if !opts[:'expiration_after'].nil?
  query_params[:'expiration_before'] = opts[:'expiration_before'] if !opts[:'expiration_before'].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 => 'ApiResponseOptions')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OptionsApi#get_options\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end