mkajnar / DailyBuyStrategy

GNU General Public License v3.0
26 stars 17 forks source link

Lookahead bias in Support and Resistance implemented strategy #10

Closed CharlesJ-ABu closed 6 months ago

CharlesJ-ABu commented 7 months ago

It's easy to solve bias in DCA and TF implemented strategy, but for Support & Resistance implemented strategy, the usage of support_resistance_dict will involve future supports and resistances. The original code below does not calculate the temporally nearest support, but instead calculates the value of the support that is numerically closest to the current price, and this will involve future information. dataframe['nearest_support'] = dataframe['close'].apply(lambda x: min([support for support in supports if support <= x], default=x, key=lambda support: abs(x - support))

mkajnar commented 6 months ago

Old version