AutoTrader icon indicating copy to clipboard operation
AutoTrader copied to clipboard

Add brokerage fees

Open Salyut9 opened this issue 2 years ago • 1 comments

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!

Salyut9 avatar Dec 18 '21 09:12 Salyut9

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 avatar Dec 18 '21 10:12 kieran-mackle

@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!

kieran-mackle avatar Aug 13 '22 00:08 kieran-mackle