Class: SchwabRb::DataObjects::OptionQuote

Inherits:
Object
  • Object
show all
Defined in:
lib/schwab_rb/data_objects/quote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ OptionQuote

Returns a new instance of OptionQuote.



29
30
31
32
33
34
35
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/schwab_rb/data_objects/quote.rb', line 29

def initialize(data)
  @symbol = data[:symbol]
  @asset_main_type = data[:assetMainType]
  @realtime = data[:realtime]
  @ssid = data[:ssid]
  @quote_52_week_high = data.dig(:quote, :"52WeekHigh")
  @quote_52_week_low = data.dig(:quote, :"52WeekLow")
  @ask_price = data.dig(:quote, :askPrice)
  @ask_size = data.dig(:quote, :askSize)
  @bid_price = data.dig(:quote, :bidPrice)
  @bid_size = data.dig(:quote, :bidSize)
  @close_price = data.dig(:quote, :closePrice)
  @delta = data.dig(:quote, :delta)
  @gamma = data.dig(:quote, :gamma)
  @high_price = data.dig(:quote, :highPrice)
  @ind_ask_price = data.dig(:quote, :indAskPrice)
  @ind_bid_price = data.dig(:quote, :indBidPrice)
  @ind_quote_time = data.dig(:quote, :indQuoteTime)
  @implied_yield = data.dig(:quote, :impliedYield)
  @last_price = data.dig(:quote, :lastPrice)
  @last_size = data.dig(:quote, :lastSize)
  @low_price = data.dig(:quote, :lowPrice)
  @mark = data.dig(:quote, :mark)
  @mark_change = data.dig(:quote, :markChange)
  @mark_percent_change = data.dig(:quote, :markPercentChange)
  @money_intrinsic_value = data.dig(:quote, :moneyIntrinsicValue)
  @net_change = data.dig(:quote, :netChange)
  @net_percent_change = data.dig(:quote, :netPercentChange)
  @open_interest = data.dig(:quote, :openInterest)
  @open_price = data.dig(:quote, :openPrice)
  @quote_time = data.dig(:quote, :quoteTime)
  @rho = data.dig(:quote, :rho)
  @security_status = data.dig(:quote, :securityStatus)
  @theoretical_option_value = data.dig(:quote, :theoreticalOptionValue)
  @theta = data.dig(:quote, :theta)
  @time_value = data.dig(:quote, :timeValue)
  @total_volume = data.dig(:quote, :totalVolume)
  @trade_time = data.dig(:quote, :tradeTime)
  @underlying_price = data.dig(:quote, :underlyingPrice)
  @vega = data.dig(:quote, :vega)
  @volatility = data.dig(:quote, :volatility)
  @contract_type = data.dig(:reference, :contractType)
  @days_to_expiration = data.dig(:reference, :daysToExpiration)
  @deliverables = data.dig(:reference, :deliverables)
  @description = data.dig(:reference, :description)
  @exchange = data.dig(:reference, :exchange)
  @exchange_name = data.dig(:reference, :exchangeName)
  @exercise_type = data.dig(:reference, :exerciseType)
  @expiration_day = data.dig(:reference, :expirationDay)
  @expiration_month = data.dig(:reference, :expirationMonth)
  @expiration_type = data.dig(:reference, :expirationType)
  @expiration_year = data.dig(:reference, :expirationYear)
  @is_penny_pilot = data.dig(:reference, :isPennyPilot)
  @last_trading_day = data.dig(:reference, :lastTradingDay)
  @multiplier = data.dig(:reference, :multiplier)
  @settlement_type = data.dig(:reference, :settlementType)
  @strike_price = data.dig(:reference, :strikePrice)
  @underlying = data.dig(:reference, :underlying)
  @underlying_asset_type = data.dig(:reference, :underlyingAssetType)
end

Instance Attribute Details

#ask_priceObject (readonly)

Returns the value of attribute ask_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def ask_price
  @ask_price
end

#ask_sizeObject (readonly)

Returns the value of attribute ask_size.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def ask_size
  @ask_size
end

#asset_main_typeObject (readonly)

Returns the value of attribute asset_main_type.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def asset_main_type
  @asset_main_type
end

#bid_priceObject (readonly)

Returns the value of attribute bid_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def bid_price
  @bid_price
end

#bid_sizeObject (readonly)

Returns the value of attribute bid_size.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def bid_size
  @bid_size
end

#close_priceObject (readonly)

Returns the value of attribute close_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def close_price
  @close_price
end

#contract_typeObject (readonly)

Returns the value of attribute contract_type.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def contract_type
  @contract_type
end

#days_to_expirationObject (readonly)

Returns the value of attribute days_to_expiration.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def days_to_expiration
  @days_to_expiration
end

#deliverablesObject (readonly)

Returns the value of attribute deliverables.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def deliverables
  @deliverables
end

#deltaObject (readonly)

Returns the value of attribute delta.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def delta
  @delta
end

#descriptionObject (readonly)

Returns the value of attribute description.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def description
  @description
end

#exchangeObject (readonly)

Returns the value of attribute exchange.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def exchange
  @exchange
end

#exchange_nameObject (readonly)

Returns the value of attribute exchange_name.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def exchange_name
  @exchange_name
end

#exercise_typeObject (readonly)

Returns the value of attribute exercise_type.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def exercise_type
  @exercise_type
end

#expiration_dayObject (readonly)

Returns the value of attribute expiration_day.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def expiration_day
  @expiration_day
end

#expiration_monthObject (readonly)

Returns the value of attribute expiration_month.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def expiration_month
  @expiration_month
end

#expiration_typeObject (readonly)

Returns the value of attribute expiration_type.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def expiration_type
  @expiration_type
end

#expiration_yearObject (readonly)

Returns the value of attribute expiration_year.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def expiration_year
  @expiration_year
end

#gammaObject (readonly)

Returns the value of attribute gamma.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def gamma
  @gamma
end

#high_priceObject (readonly)

Returns the value of attribute high_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def high_price
  @high_price
end

#implied_yieldObject (readonly)

Returns the value of attribute implied_yield.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def implied_yield
  @implied_yield
end

#ind_ask_priceObject (readonly)

Returns the value of attribute ind_ask_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def ind_ask_price
  @ind_ask_price
end

#ind_bid_priceObject (readonly)

Returns the value of attribute ind_bid_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def ind_bid_price
  @ind_bid_price
end

#ind_timeObject (readonly)

Returns the value of attribute ind_time.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def ind_time
  @ind_time
end

#is_penny_pilotObject (readonly)

Returns the value of attribute is_penny_pilot.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def is_penny_pilot
  @is_penny_pilot
end

#last_priceObject (readonly)

Returns the value of attribute last_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def last_price
  @last_price
end

#last_sizeObject (readonly)

Returns the value of attribute last_size.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def last_size
  @last_size
end

#last_trading_dayObject (readonly)

Returns the value of attribute last_trading_day.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def last_trading_day
  @last_trading_day
end

#low_priceObject (readonly)

Returns the value of attribute low_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def low_price
  @low_price
end

#markObject (readonly)

Returns the value of attribute mark.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def mark
  @mark
end

#mark_changeObject (readonly)

Returns the value of attribute mark_change.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def mark_change
  @mark_change
end

#mark_percent_changeObject (readonly)

Returns the value of attribute mark_percent_change.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def mark_percent_change
  @mark_percent_change
end

#money_intrinsic_valueObject (readonly)

Returns the value of attribute money_intrinsic_value.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def money_intrinsic_value
  @money_intrinsic_value
end

#multiplierObject (readonly)

Returns the value of attribute multiplier.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def multiplier
  @multiplier
end

#net_changeObject (readonly)

Returns the value of attribute net_change.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def net_change
  @net_change
end

#net_percent_changeObject (readonly)

Returns the value of attribute net_percent_change.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def net_percent_change
  @net_percent_change
end

#open_interestObject (readonly)

Returns the value of attribute open_interest.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def open_interest
  @open_interest
end

#open_priceObject (readonly)

Returns the value of attribute open_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def open_price
  @open_price
end

#quote_52_week_highObject (readonly)

Returns the value of attribute quote_52_week_high.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def quote_52_week_high
  @quote_52_week_high
end

#quote_52_week_lowObject (readonly)

Returns the value of attribute quote_52_week_low.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def quote_52_week_low
  @quote_52_week_low
end

#realtimeObject (readonly)

Returns the value of attribute realtime.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def realtime
  @realtime
end

#rhoObject (readonly)

Returns the value of attribute rho.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def rho
  @rho
end

#security_statusObject (readonly)

Returns the value of attribute security_status.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def security_status
  @security_status
end

#settlement_typeObject (readonly)

Returns the value of attribute settlement_type.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def settlement_type
  @settlement_type
end

#ssidObject (readonly)

Returns the value of attribute ssid.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def ssid
  @ssid
end

#strike_priceObject (readonly)

Returns the value of attribute strike_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def strike_price
  @strike_price
end

#symbolObject (readonly)

Returns the value of attribute symbol.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def symbol
  @symbol
end

#theoretical_option_valueObject (readonly)

Returns the value of attribute theoretical_option_value.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def theoretical_option_value
  @theoretical_option_value
end

#thetaObject (readonly)

Returns the value of attribute theta.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def theta
  @theta
end

#timeObject (readonly)

Returns the value of attribute time.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def time
  @time
end

#time_valueObject (readonly)

Returns the value of attribute time_value.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def time_value
  @time_value
end

#total_volumeObject (readonly)

Returns the value of attribute total_volume.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def total_volume
  @total_volume
end

#trade_timeObject (readonly)

Returns the value of attribute trade_time.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def trade_time
  @trade_time
end

#underlyingObject (readonly)

Returns the value of attribute underlying.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def underlying
  @underlying
end

#underlying_asset_typeObject (readonly)

Returns the value of attribute underlying_asset_type.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def underlying_asset_type
  @underlying_asset_type
end

#underlying_priceObject (readonly)

Returns the value of attribute underlying_price.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def underlying_price
  @underlying_price
end

#vegaObject (readonly)

Returns the value of attribute vega.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def vega
  @vega
end

#volatilityObject (readonly)

Returns the value of attribute volatility.



26
27
28
# File 'lib/schwab_rb/data_objects/quote.rb', line 26

def volatility
  @volatility
end

Instance Method Details

#zoneObject



90
91
92
93
94
95
96
97
98
# File 'lib/schwab_rb/data_objects/quote.rb', line 90

def zone
  if quote_delta.abs > 0.3
    "DANGER"
  elsif quote_delta.abs > 0.15
    "AT_RISK"
  else
    "SAFE"
  end
end