Maximization with a user-defined function #310
Unanswered
sabrivaran
asked this question in
Q&A
Replies: 2 comments 1 reply
-
final_price_in_try = data.Close.iloc[-1]
stats, heatmap = bt.optimize(..., maximize=lambda stats: stats['Equity Final [$]'] / final_price_in_try) |
Beta Was this translation helpful? Give feedback.
1 reply
-
That's what USDTRY currency is. If you want to trade the inverse (and have stats based in USD), just feed the strategy with: data[['Open', 'High', 'Low', 'Close']] = 1 / data[['Open', 'High', 'Low', 'Close']] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am working on a simple ema crossover strategy in a currency USDTRY and I come up with the "problem" that:
When optimizing my strategy with maximize='Equity Final [$]' ; equity is calculated in TRY not in USD.
Hence I need your help for defining an optimization function which will be based on the value Equity/ data.Close, so that I think it will be in USD. Defining such a function is easy probably but I could not figure it out how it will work with the strategy.
thanks from now.
I am definitely new to Python and Backtesting so any idea, help or recommendation is really valuable for me
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions