Time-dependent commission, i.e. short-sell fee #1304
dmueller-dev
started this conversation in
Ideas
Replies: 0 comments
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.
-
Hi everyone,
I recently used the package to backtest an algo system of mine. I quickly discovered that I was missing the possibility to accurately calculate borrow costs / short-sell fees that were dependent on the holding period of a position. For example: A broker charges x% per annum for selling a stock short. The actual commission is charged when the postion is closed.
I believe this can be integrated into backtesting.py by additionally passing the Trade object into the custom commission function
func(order_size: int, price: float) -> float
. (The Trade includes the entry and exit times required to calculate how long the short position was open.) Alternatively, passStrategy.closed_trades
(or the most recent addition to .closed_trades only), if calculating the commission after the trade was closed.Would this be of interest to the maintainers / the community? If so, I would like to give it a try and propose an implementation.
Many thanks,
Dominik
Beta Was this translation helpful? Give feedback.
All reactions