backtrader2 / backtrader

Python Backtesting library for trading strategies
https://www.backtrader.com
GNU General Public License v3.0
227 stars 54 forks source link

Added enhancement support for Inverse Perpetual Contract and Truncation Precision in backtrader/comminfo.py #77

Closed viper7882 closed 3 years ago

viper7882 commented 3 years ago

Hi Admin,

Background: When I was trying to enable Inverse Perpetual Contract for cryptocurrency, it has been discovered that the formula to calculate size, value and commission are inversed of the regular contract. Hence I've decided to invest time to bring up support for Inverse Perpetual Contract. You may find the mentioned backtrader/comminfo.py changes @ 61882ae but leave the other two commits as it is (as they are meant for my local use).

61882ae changes have been tested in my development environment where user could run Backtrader with Inverse Perpetual Contract in cryptocurrency and return the result with proper precision matching with need of cryptocurrency exchanges. The added precision constraint will not affect other instruments such as stocks and future products.

I hope you would consider to pick up 61882ae changes.