Commission schemes with funding fees for crypto futures
I read the docs about custom commission schemes and credit interest but not sure I understand it correctly.
Some context: I'm trading on crypto exchange Binance on BTCUSDT futures market, my strategy use 4h data to compute long and short signal. Binance has a funding fee that has to be paid if a position is open at 0-8-16h00 and is approximatly 0.03% daily (0.01% per funding interval) + a premium (that I will ignore)
"Binance uses a flat interest rate component, with the assumption that holding cash equivalent returns a higher interest than BTC equivalent. The difference is stipulated to be 0.03% per day by default (0.01% per funding interval since funding occurs every 8 hours)"
import backtrader as bt class MyCommissionInfo(bt.CommInfo): def _get_credit_interest(self, size, price, days, dt0, dt1): ''' This method returns the cost in terms of credit interest charged by the broker. In the case of ``size > 0`` this method will only be called if the parameter to the class ``interest_long`` is ``True`` The formulat for the calculation of the credit interest rate is: The formula: ``days * price * abs(size) * (interest / 365)`` Params: - ``data``: data feed for which interest is charged - ``size``: current position size. > 0 for long positions and < 0 for short positions (this parameter will not be ``0``) - ``price``: current position price - ``days``: number of days elapsed since last credit calculation (this is (dt0 - dt1).days) - ``dt0``: (datetime.datetime) current datetime - ``dt1``: (datetime.datetime) datetime of previous calculation ``dt0`` and ``dt1`` are not used in the default implementation and are provided as extra input for overridden methods ''' return days * abs(size) * price * (self.p.interest / 365.0)
Not sure how to modify this to have what I want.
Thanks for your help and let me know if more informations are needed!
I forgot to mention that there is also a trading fee for opening and closing a trade of 0.04%
Nobody's trying to do the same? No one's backtesting on crypto futures?
Would really appreciate some help here