diff --git a/Evaluator/Strategies/move_signals_strategy_evaluator.py b/Evaluator/Strategies/move_signals_strategy_evaluator.py index 76deb66e8..75203bac8 100644 --- a/Evaluator/Strategies/move_signals_strategy_evaluator.py +++ b/Evaluator/Strategies/move_signals_strategy_evaluator.py @@ -26,7 +26,7 @@ class MoveSignalsStrategyEvaluator(MixedStrategiesEvaluator): MEDIUM_PERIOD_WEIGHT = 0.30 LONG_PERIOD_WEIGHT = 0.30 - SIGNAL_MINIMUM_THRESHOLD = 0.35 + SIGNAL_MINIMUM_THRESHOLD = 0.15 DESCRIPTION = "MoveSignalsStrategyEvaluator is a fractal strategy (strategy using different time frames to " \ "balance decisions). It is using KlingerOscillatorMomentumEvaluator (momentum evaluator) " \ diff --git a/Evaluator/TA/momentum_evaluator.py b/Evaluator/TA/momentum_evaluator.py index 286bc0951..6f486df62 100644 --- a/Evaluator/TA/momentum_evaluator.py +++ b/Evaluator/TA/momentum_evaluator.py @@ -303,17 +303,19 @@ def eval_impl(self): zero_crossing_indexes = TrendAnalysis.get_threshold_change_indexes(ema_difference, 0) current_difference = ema_difference[-1] - significant_move_threshhold = numpy.std(ema_difference) + significant_move_threshold = numpy.std(ema_difference) + + factor = 0.2 if TrendAnalysis.peak_has_been_reached_already(ema_difference[zero_crossing_indexes[-1]:]): - if abs(current_difference) > significant_move_threshhold: + if abs(current_difference) > significant_move_threshold: factor = 1 else: factor = 0.5 - eval_proposition = current_difference*factor/(significant_move_threshhold) + eval_proposition = current_difference*factor/significant_move_threshold - if abs(eval_proposition) > 1: - eval_proposition = 1 if eval_proposition > 0 else -1 + if abs(eval_proposition) > 1: + eval_proposition = 1 if eval_proposition > 0 else -1 self.eval_note = eval_proposition diff --git a/Evaluator/Util/trend_analysis.py b/Evaluator/Util/trend_analysis.py index 8611db657..c12033e65 100644 --- a/Evaluator/Util/trend_analysis.py +++ b/Evaluator/Util/trend_analysis.py @@ -47,7 +47,10 @@ def peak_has_been_reached_already(data): min_val = min(data) max_val = max(data) current_val = data[-1] / 0.8 - return current_val > min_val or current_val < max_val + if current_val > 0: + return current_val < max_val + else: + return current_val > min_val else: return False diff --git a/Trading/Mode/signal_trading_mode.py b/Trading/Mode/signal_trading_mode.py index 4af1d11cc..718867d1f 100644 --- a/Trading/Mode/signal_trading_mode.py +++ b/Trading/Mode/signal_trading_mode.py @@ -30,7 +30,21 @@ def create_creators(self, symbol, symbol_evaluator): class SignalTradingModeCreator(DailyTradingModeCreator): - pass + def __init__(self, trading_mode): + super().__init__(trading_mode) + + self.STOP_LOSS_ORDER_MAX_PERCENT = 0.99 + self.STOP_LOSS_ORDER_MIN_PERCENT = 0.95 + + self.QUANTITY_MIN_PERCENT = 0.1 + self.QUANTITY_MAX_PERCENT = 0.9 + + self.QUANTITY_MARKET_MIN_PERCENT = 0.5 + self.QUANTITY_MARKET_MAX_PERCENT = 1 + self.QUANTITY_BUY_MARKET_ATTENUATION = 0.2 + + self.BUY_LIMIT_ORDER_MAX_PERCENT = 0.995 + self.BUY_LIMIT_ORDER_MIN_PERCENT = 0.99 class SignalTradingModeDecider(DailyTradingModeDecider): @@ -38,8 +52,8 @@ def __init__(self, trading_mode, symbol_evaluator, exchange): super().__init__(trading_mode, symbol_evaluator, exchange) # If final_eval not is < X_THRESHOLD --> state = X - self.VERY_LONG_THRESHOLD = -0.9 - self.LONG_THRESHOLD = -0.45 - self.NEUTRAL_THRESHOLD = 0.45 - self.SHORT_THRESHOLD = 0.9 + self.VERY_LONG_THRESHOLD = -0.88 + self.LONG_THRESHOLD = -0.4 + self.NEUTRAL_THRESHOLD = 0.4 + self.SHORT_THRESHOLD = 0.88 self.RISK_THRESHOLD = 0.15 diff --git a/tests/Evaluator/Strategies/test_move_signals_strategy_evaluator.py b/tests/Evaluator/Strategies/test_move_signals_strategy_evaluator.py index 862438fa8..79535c094 100644 --- a/tests/Evaluator/Strategies/test_move_signals_strategy_evaluator.py +++ b/tests/Evaluator/Strategies/test_move_signals_strategy_evaluator.py @@ -16,28 +16,28 @@ class TestMoveSignalsStrategyEvaluator(AbstractStrategyTest): @staticmethod def test_default_run(strategy_tester): - strategy_tester.run_test_default_run(-13) + strategy_tester.run_test_default_run(-8) @staticmethod def test_slow_downtrend(strategy_tester): - strategy_tester.run_test_slow_downtrend(-13, -5, -17.5, 0) + strategy_tester.run_test_slow_downtrend(-8, -7, -22, 0) @staticmethod def test_sharp_downtrend(strategy_tester): - strategy_tester.run_test_sharp_downtrend(-12, -18) + strategy_tester.run_test_sharp_downtrend(-9.5, -15) @staticmethod def test_flat_markets(strategy_tester): - strategy_tester.run_test_flat_markets(-3, -0.5, -15, -6) + strategy_tester.run_test_flat_markets(-2, 1, -13.5, 0.1) @staticmethod def test_slow_uptrend(strategy_tester): - strategy_tester.run_test_slow_uptrend(-4, 5) + strategy_tester.run_test_slow_uptrend(-2, 2.5) @staticmethod def test_sharp_uptrend(strategy_tester): - strategy_tester.run_test_sharp_uptrend(20, 14) + strategy_tester.run_test_sharp_uptrend(27, 14) @staticmethod def test_up_then_down(strategy_tester): - strategy_tester.run_test_up_then_down(-3.5) + strategy_tester.run_test_up_then_down(-6) diff --git a/tests/Evaluator/TA/test_klinger_TA_evaluator.py b/tests/Evaluator/TA/test_klinger_TA_evaluator.py index 8cfe867d3..6eb5d3039 100644 --- a/tests/Evaluator/TA/test_klinger_TA_evaluator.py +++ b/tests/Evaluator/TA/test_klinger_TA_evaluator.py @@ -20,35 +20,35 @@ def test_stress_test(evaluator_tester): @staticmethod def test_reactions_to_dump(evaluator_tester): - evaluator_tester.run_test_reactions_to_dump(0.1, START_PENDING_EVAL_NOTE, -1, -1, -1) + evaluator_tester.run_test_reactions_to_dump(0, 0, -0.2, -0.4, -0.55) @staticmethod def test_reactions_to_pump(evaluator_tester): - evaluator_tester.run_test_reactions_to_pump(-0.1, -0.1, START_PENDING_EVAL_NOTE, 0.2, 0.5, - START_PENDING_EVAL_NOTE, -1) + evaluator_tester.run_test_reactions_to_pump(-0.1, -0.1, 0, 0.1, 0.2, + 0, -0.5) @staticmethod def test_reaction_to_rise_after_over_sold(evaluator_tester): - evaluator_tester.run_test_reactions_to_rise_after_over_sold(-0.3, -1, -1, -1, START_PENDING_EVAL_NOTE) + evaluator_tester.run_test_reactions_to_rise_after_over_sold(-0.2, -0.6, -1, -1, 0.1) @staticmethod def test_reaction_to_over_bought_then_dip(evaluator_tester): - evaluator_tester.run_test_reactions_to_over_bought_then_dip(-1, START_PENDING_EVAL_NOTE, 1, 1, -1, -1) + evaluator_tester.run_test_reactions_to_over_bought_then_dip(-1, 0, 0.5, 0.5, -0.8, -1) @staticmethod def test_reaction_to_flat_trend(evaluator_tester): evaluator_tester.run_test_reactions_to_flat_trend( # eval_start_move_ending_up_in_a_rise, - START_PENDING_EVAL_NOTE, + 0.9, # eval_reaches_flat_trend, eval_first_micro_up_p1, eval_first_micro_up_p2, - 1, 1, 0.3, + 0.7, 0.55, 0.3, # eval_micro_down1, eval_micro_up1, eval_micro_down2, eval_micro_up2, - -1, -0.25, -0.4, -0.1, + -0.3, -0.25, -0.4, -0.1, # eval_micro_down3, eval_back_normal3, eval_micro_down4, eval_back_normal4, - 0, -0.2, 0.1, 0.1, + 0, -0.1, 0.1, 0.1, # eval_micro_down5, eval_back_up5, eval_micro_up6, eval_back_down6, - -0.4, -0.1, 0.2, 0.25, + -0.1, -0.1, 0.1, 0.25, # eval_back_normal6, eval_micro_down7, eval_back_up7, eval_micro_down8, - 0, 0.1, -0.2, START_PENDING_EVAL_NOTE, + 0, 0.1, -0.2, 0, # eval_back_up8, eval_micro_down9, eval_back_up9 - 0.1, -0.2, 0.25) + 0, 0, 0.1)