a bug in code?



  • in bbroker.py:

    line 642:

            if closedvalue > 0:  # long position closed
                closecash /= comminfo.get_leverage()  # inc cash with lever
    

    line 674:

            if openedvalue > 0:  # long position being opened
                opencash /= comminfo.get_leverage()  # dec cash with level
    

    It seems that you forget to handle the condition of short position closed.

    line 642:

            if closedvalue > 0:  # long position closed
                closecash /= comminfo.get_leverage()  # inc cash with lever
            else:  # short position closed
                closecash /= comminfo.get_leverage()  # inc cash with lever
                closecash = -closecash
    

    line 674:

            if openedvalue > 0:  # long position being opened
                opencash /= comminfo.get_leverage()  # dec cash with level
            else:  # long position being opened
                opencash /= comminfo.get_leverage()  # dec cash with level
                opencash = -opencash

  • administrators

    The code is for sure prone to contain bugs, but rather than isolated code lines

    • Do you have a small test sample that shows that there is a bug there?

Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.