Skip to content
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

Add brokerage fees #16

Closed
Salyut9 opened this issue Dec 18, 2021 · 2 comments
Closed

Add brokerage fees #16

Salyut9 opened this issue Dec 18, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@Salyut9
Copy link

Salyut9 commented Dec 18, 2021

Is your feature request related to a problem? Please describe.
The profit and drawdown can be more accurate because the fees for each trade (open and close) are not taken into account.

Describe the solution you'd like
The possibility to add a custom value in the parameters for the broker fees depending on the type of entry (for example if the entries are in market and the exits in limit have the possibility to have different fees).
It would also be great to have the total number of fees paid in the backtest result like the example below.
Capture

PS : love your work!

@kieran-mackle kieran-mackle added the enhancement New feature or request label Dec 18, 2021
@kieran-mackle
Copy link
Owner

Very good suggestions! The commissions scheme is something I've been wanting to improve for a little while now, and what you have suggested is a great start. Commissions are currently calculated on both the open and closing trades of a position, but they do not take into account the trade type. The fees are also not applied until the trade is closed.

I will aim to implement your suggestions in a future release. For the meantime, I have added the total fees to the printout (you will need to update to v0.5.22):
image

The fee on each trade can also be viewed via the trade summary:

bot = at.bots_deployed[0]
bot.backtest_summary['trade_summary'].head()

                           Order_ID  Order_price  ... Trade_duration      Fees
2010-01-21 16:00:00+00:00         8      56062.5  ...      3369600.0  0.033692
2010-04-12 00:00:00+00:00        77      59887.5  ...      1944000.0  0.059327
2010-05-04 16:00:00+00:00        96      58637.5  ...      5702400.0  0.034278
2010-07-09 20:00:00+00:00       172      53712.5  ...      2822400.0  0.039106
2010-08-11 20:00:00+00:00       208      54375.0  ...      1958400.0  0.032663

Thank you so much, glad you like the project!

@kieran-mackle
Copy link
Owner

@Salyut9

Version 0.7 now allows specifying maker_commission and taker_commission arguments in the AutoTrader.virtual_account_config method. Additionally, trading costs will be calculated differently for market vs. limit orders.

Make sure to read the docs and changelog if upgrading, there have been a lot of changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants