Class: SQA::StrategyGenerator::ProfitablePoint
- Inherits:
-
Object
- Object
- SQA::StrategyGenerator::ProfitablePoint
- Defined in:
- lib/sqa/strategy_generator.rb
Overview
Represents a profitable trade opportunity discovered in historical data
Instance Attribute Summary collapse
-
#entry_index ⇒ Object
Returns the value of attribute entry_index.
-
#entry_price ⇒ Object
Returns the value of attribute entry_price.
-
#exit_index ⇒ Object
Returns the value of attribute exit_index.
-
#exit_price ⇒ Object
Returns the value of attribute exit_price.
-
#fpl_direction ⇒ Object
Returns the value of attribute fpl_direction.
-
#fpl_magnitude ⇒ Object
Returns the value of attribute fpl_magnitude.
-
#fpl_max_delta ⇒ Object
Returns the value of attribute fpl_max_delta.
-
#fpl_min_delta ⇒ Object
Returns the value of attribute fpl_min_delta.
-
#fpl_risk ⇒ Object
Returns the value of attribute fpl_risk.
-
#gain_percent ⇒ Object
Returns the value of attribute gain_percent.
-
#holding_days ⇒ Object
Returns the value of attribute holding_days.
-
#indicators ⇒ Object
Returns the value of attribute indicators.
Instance Method Summary collapse
-
#initialize(entry_index:, entry_price:, exit_index:, exit_price:, fpl_data: nil) ⇒ ProfitablePoint
constructor
A new instance of ProfitablePoint.
- #to_s ⇒ Object
Constructor Details
#initialize(entry_index:, entry_price:, exit_index:, exit_price:, fpl_data: nil) ⇒ ProfitablePoint
Returns a new instance of ProfitablePoint.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sqa/strategy_generator.rb', line 43 def initialize(entry_index:, entry_price:, exit_index:, exit_price:, fpl_data: nil) @entry_index = entry_index @entry_price = entry_price @exit_index = exit_index @exit_price = exit_price @gain_percent = ((exit_price - entry_price) / entry_price * 100.0) @holding_days = exit_index - entry_index @indicators = {} # FPL quality metrics if fpl_data @fpl_min_delta = fpl_data[:min_delta] @fpl_max_delta = fpl_data[:max_delta] @fpl_risk = fpl_data[:risk] @fpl_direction = fpl_data[:direction] @fpl_magnitude = fpl_data[:magnitude] end end |
Instance Attribute Details
#entry_index ⇒ Object
Returns the value of attribute entry_index.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def entry_index @entry_index end |
#entry_price ⇒ Object
Returns the value of attribute entry_price.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def entry_price @entry_price end |
#exit_index ⇒ Object
Returns the value of attribute exit_index.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def exit_index @exit_index end |
#exit_price ⇒ Object
Returns the value of attribute exit_price.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def exit_price @exit_price end |
#fpl_direction ⇒ Object
Returns the value of attribute fpl_direction.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def fpl_direction @fpl_direction end |
#fpl_magnitude ⇒ Object
Returns the value of attribute fpl_magnitude.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def fpl_magnitude @fpl_magnitude end |
#fpl_max_delta ⇒ Object
Returns the value of attribute fpl_max_delta.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def fpl_max_delta @fpl_max_delta end |
#fpl_min_delta ⇒ Object
Returns the value of attribute fpl_min_delta.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def fpl_min_delta @fpl_min_delta end |
#fpl_risk ⇒ Object
Returns the value of attribute fpl_risk.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def fpl_risk @fpl_risk end |
#gain_percent ⇒ Object
Returns the value of attribute gain_percent.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def gain_percent @gain_percent end |
#holding_days ⇒ Object
Returns the value of attribute holding_days.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def holding_days @holding_days end |
#indicators ⇒ Object
Returns the value of attribute indicators.
39 40 41 |
# File 'lib/sqa/strategy_generator.rb', line 39 def indicators @indicators end |
Instance Method Details
#to_s ⇒ Object
62 63 64 65 |
# File 'lib/sqa/strategy_generator.rb', line 62 def to_s fpl_info = fpl_direction ? " dir=#{fpl_direction} risk=#{fpl_risk.round(2)}%" : "" "ProfitablePoint(gain=#{gain_percent.round(2)}%, days=#{holding_days}, entry=#{entry_index}#{fpl_info})" end |