-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Time-dependent commission, i.e. short-sell fee #1304
-
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, pass Strategy.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.