Class: Options::Strategies::Hedge

Inherits:
Strategy
  • Object
show all
Defined in:
lib/options/strategies.rb

Direct Known Subclasses

ShortHedge

Instance Attribute Summary collapse

Attributes inherited from Strategy

#ce_increment, #default_lot_size, #increment, #index_name, #input_lot_size, #legs, #option_type_klasses, #options_data, #pe_increment, #strike_price

Instance Method Summary collapse

Methods inherited from Strategy

#construct, #long=, #lot_size=, #merge_legs, #parse_option_type_klasses, #short=, #to_hash, #to_json

Constructor Details

#initialize(options = {}) ⇒ Hedge

Returns a new instance of Hedge.



82
83
84
85
86
87
88
89
# File 'lib/options/strategies.rb', line 82

def initialize(options={})
  super(options)
  @ce_increment = 3 * @increment
  @pe_increment = -3 * @increment
  @parent_pe_strike_price = @options.key?(:parent_pe_strike_price) ? @options[:parent_pe_strike_price] : @strike_price
  @parent_ce_strike_price = @options.key?(:parent_ce_strike_price) ? @options[:parent_ce_strike_price] : @strike_price
  @option_type_klasses = {CEOption => @parent_ce_strike_price + @ce_increment, PEOption => @parent_pe_strike_price + @pe_increment}
end

Instance Attribute Details

#parent_ce_strike_priceObject

Returns the value of attribute parent_ce_strike_price.



81
82
83
# File 'lib/options/strategies.rb', line 81

def parent_ce_strike_price
  @parent_ce_strike_price
end

#parent_pe_strike_priceObject

Returns the value of attribute parent_pe_strike_price.



81
82
83
# File 'lib/options/strategies.rb', line 81

def parent_pe_strike_price
  @parent_pe_strike_price
end

Instance Method Details

#buildObject



91
92
93
# File 'lib/options/strategies.rb', line 91

def build
  construct {|option_data| self.long = option_data }
end