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))
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))