-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Is it possible to optimize based on multiple variables? #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Constraint is a function that takes parameter combination (e.g. specific values of I think what you want is def maximize(stats):
if stats['Max. Drawdown [%]'] < -20:
return -np.inf # i.e. worst
return stats['Return [%]']
stats = bt.optimize(..., maximize=maximize) |
So if I use this maximize function, I would only get returns where the Max. Drawdown is higher than -30? def maximize(stats):
if stats['Max. Drawdown [%]'] > -30:
return stats['Return [%]']
stats, heatmap = bt.optimize(
p1=range(1,6,1),
p2=range(1,11,1),
p3=range(3,20,1),
maximize=maximize,
return_heatmap=True)
print(heatmap.sort_values().iloc[-20:]) Also, when I try to run this optimization and sort the heatmap I get a TypeError:
|
No, with maximize function as above, you have an |
Uh oh!
There was an error while loading. Please reload this page.
Is it possible to optimize based on multiple variables? Or set the constraint to a value from the results?
Example:
The text was updated successfully, but these errors were encountered: