Class: Iro::Option
- Inherits:
-
Object
- Object
- Iro::Option
- Includes:
- OptionBlackScholes, Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
- Defined in:
- app/models/iro/option.rb
Instance Attribute Summary collapse
-
#recompute ⇒ Object
Returns the value of attribute recompute.
Class Method Summary collapse
Instance Method Summary collapse
-
#put_call ⇒ Object
each option can be a leg in a position, no uniqueness validates :symbol, uniqueness: true, presence: true.
-
#symbol ⇒ Object
for TDA.
- #sync ⇒ Object
- #ticker ⇒ Object
Methods included from OptionBlackScholes
#call_price, #d1, #d2, #put_price, rate_annual, rate_daily, #stdev, #t
Instance Attribute Details
#recompute ⇒ Object
Returns the value of attribute recompute.
9 10 11 |
# File 'app/models/iro/option.rb', line 9 def recompute @recompute end |
Class Method Details
.expirations_list(full: false) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/iro/option.rb', line 30 def self.expirations_list full: false [ [ nil, nil ], [ 'Mar 22', '2024-03-22'.to_date ], [ 'Mar 28', '2024-03-28'.to_date ], [ 'Apr 5', '2024-04-05'.to_date ], [ 'Mar 12', '2024-03-12'.to_date ], [ 'Mar 19', '2024-03-19'.to_date ], ] end |
Instance Method Details
#put_call ⇒ Object
each option can be a leg in a position, no uniqueness validates :symbol, uniqueness: true, presence: true
20 |
# File 'app/models/iro/option.rb', line 20 field :put_call, type: :string |
#symbol ⇒ Object
for TDA
53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/iro/option.rb', line 53 def symbol if !self[:symbol] p_c_ = put_call == 'PUT' ? 'P' : 'C' strike_ = strike.to_i == strike ? strike.to_i : strike sym = "#{stock.ticker}_#{expires_on.strftime("%m%d%y")}#{p_c_}#{strike_}" # XYZ_011819P45 self[:symbol] = sym save end self[:symbol] end |
#sync ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/iro/option.rb', line 64 def sync out = Tda::Option.get_quote({ contractType: put_call, strike: strike, expirationDate: expires_on, ticker: ticker, }) puts! out, 'option sync' self.end_price = ( out.bid + out.ask ) / 2 rescue 0 self.end_delta = out.delta # self.save end |
#ticker ⇒ Object
12 |
# File 'app/models/iro/option.rb', line 12 def ticker; stock.ticker; end |