Module: MarketData::Options

Includes:
Conn, Mappers, Validations
Included in:
Client
Defined in:
lib/market_data/options.rb

Constant Summary collapse

@@expirations =
"/v1/options/expirations/%{symbol}/"
@@lookup =
"/v1/options/lookup/"
@@strike =
"/v1/options/strikes/%{symbol}/"
@@chain =
"/v1/options/chain/%{symbol}/"
@@quotes =
"/v1/options/quotes/%{symbol}/"

Constants included from Validations

Validations::VALID_DAILY_RESOLUTION, Validations::VALID_RESOLUTIONS

Constants included from Mappers

Mappers::OPEN_RESPONSE_KEY, Mappers::OPTION_SYMBOL_RESPONSE_KEY, Mappers::STATUS_RESPONSE_KEY, Mappers::SYMBOL_RESPONSE_KEY

Instance Method Summary collapse

Methods included from Validations

#options_for_expirations, #options_for_option_chains, #options_for_option_quote, #options_for_strikes, #required_for_lookup, #time_valid?, #validate_bulk_candles_input!, #validate_bulk_quotes_input!, #validate_candles_input!, #validate_earnings_input!, #validate_expiration_filters!, #validate_expirations_input!, #validate_from_to_countback_strategy, #validate_index_candles_input!, #validate_index_quote_input!, #validate_lookup_input!, #validate_market_status_input!, #validate_option_chain_input!, #validate_option_chain_liquidity_filters!, #validate_option_chain_other_filters!, #validate_option_chain_strike_filters!, #validate_option_quote_input!, #validate_quotes_input!, #validate_resolution, #validate_strikes_input!

Methods included from Errors

#handle_error

Methods included from Mappers

#map_bulk_candles, #map_bulk_quotes, #map_candles, #map_earnings, #map_expirations, #map_fields_for, #map_index_candles, #map_index_quote, #map_lookup, #map_market_status, #map_option_chain, #map_option_quote, #map_quote, #map_strike

Methods included from Conn

#do_connect, #do_request, #encode_uri_component, #get_auth_headers, #get_token, #get_uri

Instance Method Details

#chain(symbol, opts = options_for_option_chains) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/market_data/options.rb', line 46

def chain(symbol, opts = options_for_option_chains)
  query = validate_option_chain_input!(symbol: symbol, **opts)
  query = query.except(:symbol)

  map_option_chain(
    do_request @@chain % {symbol: symbol}, query
  )
end

#expirations(symbol, opts = options_for_expirations) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/market_data/options.rb', line 17

def expirations(symbol, opts = options_for_expirations)
  query = validate_expirations_input!(symbol: symbol, **opts)
  
  map_expirations(
    do_request(
      @@expirations % {symbol: symbol},
      query
    )
  )
end

#lookup(required = required_for_lookup) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/market_data/options.rb', line 28

def lookup(required = required_for_lookup)
  query = validate_lookup_input!(**required)
  s_query = "#{query[:symbol]} #{query[:expiration]} #{query[:strike]} #{query[:side]}"
  
  map_lookup(
    do_request @@lookup + encode_uri_component(s_query), {}
  )
end

#option_quote(symbol, opts = options_for_option_quote) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/market_data/options.rb', line 55

def option_quote(symbol, opts = options_for_option_quote)
  query = validate_option_quote_input!(symbol: symbol, **opts)
  query = query.except(:symbol)

  map_option_quote(
    do_request @@quotes % {symbol: symbol}, query
  )
end

#strikes(symbol, opts = options_for_strikes) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/market_data/options.rb', line 37

def strikes(symbol, opts = options_for_strikes)
  query = validate_strikes_input!(symbol: symbol, **opts)
  query = query.except(:symbol)

  map_strike(
    do_request @@strike % {symbol: symbol}, query
  )
end