Class: SQA::StrategyGenerator::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/sqa/strategy_generator.rb

Overview

Represents a discovered indicator pattern

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conditions: {}) ⇒ Pattern

Returns a new instance of Pattern.



74
75
76
77
78
79
80
81
82
# File 'lib/sqa/strategy_generator.rb', line 74

def initialize(conditions: {})
  @conditions = conditions
  @frequency = 0
  @avg_gain = 0.0
  @avg_holding_days = 0.0
  @success_rate = 0.0
  @occurrences = []
  @context = PatternContext.new
end

Instance Attribute Details

#avg_gainObject

Returns the value of attribute avg_gain.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def avg_gain
  @avg_gain
end

#avg_holding_daysObject

Returns the value of attribute avg_holding_days.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def avg_holding_days
  @avg_holding_days
end

#conditionsObject

Returns the value of attribute conditions.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def conditions
  @conditions
end

#contextObject

Returns the value of attribute context.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def context
  @context
end

#frequencyObject

Returns the value of attribute frequency.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def frequency
  @frequency
end

#occurrencesObject

Returns the value of attribute occurrences.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def occurrences
  @occurrences
end

#success_rateObject

Returns the value of attribute success_rate.



70
71
72
# File 'lib/sqa/strategy_generator.rb', line 70

def success_rate
  @success_rate
end

Instance Method Details

#to_sObject



84
85
86
87
# File 'lib/sqa/strategy_generator.rb', line 84

def to_s
  ctx_info = @context.valid? ? " [#{@context.summary}]" : ""
  "Pattern(conditions=#{conditions.size}, freq=#{frequency}, gain=#{avg_gain.round(2)}%, success=#{success_rate.round(2)}%#{ctx_info})"
end