-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Why don't use adjusted_price when close a trade ? #149
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
The backtesting.py/backtesting/backtesting.py Lines 887 to 889 in b456400
Thus, the spread/commissions are accounted for already at trade entry time (the broker ain't gonna wait for its share). If we were to use adjusted_price also when reducing/closing existing trades, the spread/commissions would be accounted for twice!
|
In fact, it should be... for some exchange
|
I see. 😲 😅 Disregarding the irrelevance of this broker, since this is a commission on currency conversion, I guess they can charge it twice. (You convert EUR to GBP; here's our 0.004%. You convert GBP to EUR; here's our 0.004%.) It might be the same with some stock brokers. But, then again, this is certainly different from bid-ask spread charged by most spot brokers. 🤔 I think I'd prefer the commission applied once per round-trip, but certainly with a documentation note of the fact. And a suggestion to pass |
Thank you for your prompt reply. 👍 Currently, I am going to change the price to adjusted_price in almost every close_trade function and use my hacked version as a workaround to finished my work now. Maybe we need a param in the backtest for this scenario. backtesting.py/backtesting/backtesting.py Line 830 in b456400
But indeed, this is a very rare case. I think we should spend more time on this issue if someone else met the same problem. |
Are you referring to price fluctuation or the different volume? If the volume, the total commissions should even out by the time the whole position is closed, whereas the price fluctuation (specifically in currency) shouldn't be so large that it greatly affects commission percent (e.g. I count EURUSD spread ratio up to 0.00015 whenever I look). I guess there are cases where this is a valid point. Similarly to #113. Much rather than support every possible fee structure, I'd like to keep it simple, though. 😅 |
I am referring to price fluctuation.
I respect your idea. I think maybe we should close this issue. |
Is it possible to reopen this issue? I also encounter the same problem. In fact, not only the currency conversion has this issue, stock markets in other countries also charge the commission on both entry and exit. And also, is it possible to have the capability to define different commissions for entry? |
I am facing the same issue here. Trying to backtest a delta neutral hedging strategy with continuous rebalancing of an initial short position. On my exchange I am paying fee for every executed trade in both buy/sell at the actual market price of the execution. Another feature I think would be useful is to include the accrued fees in the final tear sheet. |
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
I think the exit_price in trades should be the adjusted_price.
backtesting.py/backtesting/backtesting.py
Line 873 in b456400
Actual Behavior
We are using the price right now. :)
Steps to Reproduce
The text was updated successfully, but these errors were encountered: