File size: 823 Bytes
d53dc44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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!')