Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Time-dependent commission, i.e. short-sell fee #1304

dmueller-dev started this conversation in Ideas
Discussion options

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

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /