import sys with open('backtester/strategies.py', 'r', encoding='utf-8') as f: text = f.read() replacement = """ short_score = np.where(perfect_short_setup, 5.0, 0.0) # ???? Only trade WITH the daily trend (strict filter) ???? trend_allows_long = daily_trend >= 0.3 trend_allows_short = daily_trend <= -0.3 signals = pd.DataFrame(index=df.index) signals["entry"] = 0 signals.loc[(long_score >= min_confidence) & good_time & trend_allows_long, "entry"] = 1 signals.loc[(short_score >= min_confidence) & good_time & trend_allows_short, "entry"] = -1 # Tie-break""" text = text.replace(" short_score = np.where(perfect_short_setup, 5.0, 0.0)\n # Tie-break", replacement) with open('backtester/strategies.py', 'w', encoding='utf-8') as f: f.write(text) print('Done!')