Skip to content

Commit

Permalink
corrected additional days function for candlestick color indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
jocon15 committed Jan 11, 2025
1 parent 9e2f55e commit db65c04
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/StockBench/indicators/candlestick_color/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ class CandlestickColorTrigger(Trigger):
def __init__(self, indicator_symbol):
super().__init__(indicator_symbol, side=Trigger.AGNOSTIC)

def additional_days_from_rule_key(self, rule_key, rule_value) -> int:
"""Calculate the additional days required.
def additional_days_from_rule_key(self, rule_key) -> int:
"""Calculate the additional days required from rule key.
Args:
rule_key (any): The key value from the strategy (unused in this function).
rule_value (any): The value from the strategy.
"""
# cannot deduce additional days from color rule key
return 0

def additional_days_from_rule_value(self, rule_value: any) -> int:
"""Calculate the additional days required from rule value."""
if len(rule_value.keys()) == 0:
raise StrategyIndicatorError(f'{self.indicator_symbol} key: {rule_key} must have at least one color child '
f'key')
raise StrategyIndicatorError(f'Color rules must have at least one color child!')

additional_days = 0
for sub_key in rule_value.keys():
Expand Down

0 comments on commit db65c04

Please sign in to comment.