I forgot to mention that there is also a trading fee for opening and closing a trade of 0.04%
Posts made by toinou222
RE: Commission schemes with funding fees for crypto futures
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!
RE: Add Supertrend Indicator to Backtrader
Thanks for your indicator!
How do you use it in order to compute a backtest?
Do you use it with cerebro.addstrategy or cerebro.add_signal?
I tried both but can't manage to make it work...
Thanks for your help!
Bt on AWS, jupyter notebook crash
I'm coding on a t2.micro instance on AWS ec2 running on Amazon Linux 2 os. I built a strategy with 2 data feeds and everything works well but when I try to plot it, my jupyter notebook kernel stay busy forever... I cant even stop jupyter, I have to close the cmd and reboot my instance in order to use it again.
Anyone faced the same issue or have a solution?
RE: I introduce myself. I am French. My name is Pierre Rougier and I am interested in Backtrader since today.
@kaber-mobile Hi, I may have a few question as I am trying to develop an algo trading system for crypto based on ML. How can I contact you?
RE: Sizer for CryptoCurrencies
Maybe this will help someone... I had the same issue and solved it by using a percentage of my portfolio
class Antoine_sizer(bt.Sizer): params = (('prop', 0.1),) def _getsizing(self, comminfo, cash, data, isbuy): """Returns the proper sizing""" if isbuy: # Buying target = self.broker.getvalue() * self.params.prop # Ideal total value of the position price = data.close size_net = target / price # How many shares are needed to get target size = size_net * 0.99 if size * price > cash: return 0 # Not enough money for this trade else: return size else: # Selling return self.broker.getposition(data).size # Clear the position