Class: CoveredCallPosition
- Inherits:
-
Object
- Object
- CoveredCallPosition
- Includes:
- ArgumentProcessor
- Defined in:
- lib/covered_call_position.rb
Instance Attribute Summary collapse
-
#date_established ⇒ Object
Returns the value of attribute date_established.
-
#num_shares ⇒ Object
Returns the value of attribute num_shares.
-
#option ⇒ Object
Returns the value of attribute option.
Instance Method Summary collapse
- #call_sale ⇒ Object
- #commission ⇒ Object
- #commission=(name) ⇒ Object
- #downside_protection ⇒ Object
- #implied_volatility ⇒ Object
-
#initialize(args = {}) ⇒ CoveredCallPosition
constructor
A new instance of CoveredCallPosition.
- #net_outlay ⇒ Object
- #net_per_share ⇒ Object
- #probability_max_profit ⇒ Object
- #probability_profit ⇒ Object
- #stock ⇒ Object
- #stock_total ⇒ Object
Methods included from ArgumentProcessor
Constructor Details
#initialize(args = {}) ⇒ CoveredCallPosition
Returns a new instance of CoveredCallPosition.
6 7 8 |
# File 'lib/covered_call_position.rb', line 6 def initialize(args = {}) process_args(args) end |
Instance Attribute Details
#date_established ⇒ Object
Returns the value of attribute date_established.
4 5 6 |
# File 'lib/covered_call_position.rb', line 4 def date_established @date_established end |
#num_shares ⇒ Object
Returns the value of attribute num_shares.
4 5 6 |
# File 'lib/covered_call_position.rb', line 4 def num_shares @num_shares end |
#option ⇒ Object
Returns the value of attribute option.
4 5 6 |
# File 'lib/covered_call_position.rb', line 4 def option @option end |
Instance Method Details
#call_sale ⇒ Object
30 31 32 |
# File 'lib/covered_call_position.rb', line 30 def call_sale num_shares * option.price - commission.option_entry end |
#commission ⇒ Object
14 15 16 17 18 |
# File 'lib/covered_call_position.rb', line 14 def commission @commission_instance ||= Commission.const_get(@commission).new( :shares => num_shares, :contracts => num_shares / 100 ) end |
#commission=(name) ⇒ Object
10 11 12 |
# File 'lib/covered_call_position.rb', line 10 def commission=(name) @commission = name.to_s end |
#downside_protection ⇒ Object
42 43 44 |
# File 'lib/covered_call_position.rb', line 42 def downside_protection (net_per_share.to_f - stock.price) / stock.price end |
#implied_volatility ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/covered_call_position.rb', line 50 def implied_volatility @iv ||= BlackScholes.call_iv( stock.price / 100.0, option.strike / 100.0, 0.27, # TODO: risk-free rate option.days_to_expiry(date_established), option.price / 100.0 ) end |
#net_outlay ⇒ Object
34 35 36 |
# File 'lib/covered_call_position.rb', line 34 def net_outlay stock_total - call_sale end |
#net_per_share ⇒ Object
38 39 40 |
# File 'lib/covered_call_position.rb', line 38 def net_per_share net_outlay.to_f / num_shares end |
#probability_max_profit ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/covered_call_position.rb', line 60 def probability_max_profit BlackScholes.probability_above( stock.price / 100.0, option.strike / 100.0, option.days_to_expiry(date_established), implied_volatility ) end |
#probability_profit ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/covered_call_position.rb', line 69 def probability_profit BlackScholes.probability_above( stock.price / 100.0, net_per_share / 100.0, option.days_to_expiry(date_established), implied_volatility ) end |
#stock ⇒ Object
46 47 48 |
# File 'lib/covered_call_position.rb', line 46 def stock option.stock end |
#stock_total ⇒ Object
26 27 28 |
# File 'lib/covered_call_position.rb', line 26 def stock_total num_shares * stock.price + commission.stock_entry end |