Rare bug fix with SQN analyzer



  • Hey backtrader

    There is a rare bug that occurs with the SQN performance measure Analyzer.

    A division by zero exception is raised when the standard deviation of returns is zero. This is more likely to happen when there are just a few trades in a system.

    Although rare, it would be more elegant for a 'None' value to be returned.

    I have made the changes and tried to create a pull request via Github.
    Just before I did this, I improved my Kelly Analyzer (fixing a similar bug). Somehow the SQN pull request got added into the Kelly pull request.

    I'm new to Github and been trying for past hour to create a new seperate pull request but no joy. Doing my head in. Should I cancel pull request and try again? Please let me know (can drop a pm prob easier!) cheers mate


  • administrators

    Creating a separate pull-request is not possible because you pull-requests are done on a per-branch difference basis and not commit basis.

    The usual way to submit independent pull-requests is:

    • Fetch upstream_master (you can simply fetch-all), so you are synchronized with the main repository
    • Branch off upstream_master with a name of your choice like work-sqn-feature-001
    • Check-out work-sqn-feature-001 if needed (depends on the tool you use)
    • Do your job
    • Submit the pull-request asking to use work-sqn-feature-001 against backtrader/master (it is properly displayed in GitHub and should be the default)

    If you want to use your own patch for your own work, simply:

    • Merge your work-sqn-feture-001 with your own local master (which should be a copy of upstream_master)

    In case you wan to replicate the above with your existing code

    • Fetch upstream_master (you can simply fetch-all), so you are synchronized with the main repository
    • Branch off upstream_master with a name of your choice like work-sqn-feature-001
    • Check-out work-sqn-feature-001 if needed (depends on the tool you use)
    • Cherry pick the commit (or commits) that make up your changes, they will be merged in to the current branch work-sqn-feature-001
    • Submit the pull-request asking to use work-sqn-feature-001 against backtrader/master (it is properly displayed in GitHub and should be the default)

    And you can carry on as described above



  • @backtrader Hey thanks for explaining all that.. I've read through a couple of times. Ok I'll give it a shot this weekend see if I can get working. From sounds of it, I will need to cancel my current pull request (again!). Thanks again



  • @backtrader Ok, I'm trying to do this now. Not a clue what's going on. I've tried to do the above in GitHub but can't see how to do it.. so I'm assuming I will have to use command line with Git. Though I tried and got error messages like:
    'fatal: Not a git repository (or any of the parent directories):' prob something simple I'm doing wrong but hard to see as a beginner.

    My original set up was, I forked your repo to my Github account, then cloned my fork to my local computer and have been making changes there. Was this the right thing to do?

    I've sent a help question to the GitHub guys and I'll read some tutorials on this to figure it out. (If anyone knows any simple good tutorials for how to do things like the above, please let me know.) I want to get up to speed quickly on this as I have also written some basic trade statistics Analyzer I'd like to upload.
    Thank-you and stay tuned



  • Ok think I've cracked it now. I've submitted two seperate pull requests. One for SQN bug fix, another for Kelly Analyzer.
    I would like to create another shortly for another basic trade statistic analyzer. Stay tuned. Thankyou



  • Hi backtrader, just checking the canclled pull request.
    My code changes were this:
    0_1508350449050_SQN change 1.png

    Just checked yours and agree more elegant. Nice one.
    0_1508350517428_SQN change 2.png


Log in to reply
 

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