enzoampil / fastquant

fastquant — Backtest and optimize your ML trading strategies with only 3 lines of code!
MIT License
1.54k stars 239 forks source link

Not able to optimize the stop loss and other floating parameters. #401

Closed YASHGUPTA2611 closed 2 years ago

YASHGUPTA2611 commented 2 years ago

issue

mikeejazmines commented 2 years ago

Hi! Could you share more of the code? I can't fully analyze the issue.

Looking at the error message, it is mainly due to you using floats instead of integer which is what the value expects. It isn't due to stop loss or floating params.

YASHGUPTA2611 commented 2 years ago

1 2

I have applied a range function(the circled one) on af params for optimizing my strategy but it is giving some error.

mikeejazmines commented 2 years ago

If you see the error below it says TypeError: float object cannot be interpreted as an integer. If you run range(0.02, 0.1, 0.02) it actually gives an error.

>>> range(0.02, 0.1, 0.02)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'float' object cannot be interpreted as an integer

This is an error in the range function. You can also manually add an array instead.

YASHGUPTA2611 commented 2 years ago

1 2 3 giving the values as an array and now it is giving the error : - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

mikeejazmines commented 2 years ago

This is the same issue as what you raised previously in this issue https://github.com/enzoampil/fastquant/issues/393#issuecomment-993367593

When you are backtesting with a range, you need to make the value of plot=False. That ValueError means that there are too many values to plot (given that you are backtesting over a range) and it is ambiguous. Thus plot=False is the solution

YASHGUPTA2611 commented 2 years ago

Thanks @mikeejazmines , it worked