Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    BTFD (Buy The F... Dip)

    Blog
    2
    9
    2640
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      backtrader administrators last edited by

      Use the link below to go the original post

      Click here to see the full blog post

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        Should I just run the script as python btfd.py? Or something need to be prepared first? I am asking because I don't see any output after I run the script.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators last edited by

          The script produces no output, it was only meant to produce charts with --plot

          In the post it is executed with:

          ./btfd.py --plot --strat approach="'closeclose'"
          

          and

          ./btfd.py --plot --strat approach="'highlow'"
          

          It only creates charts because it is comparing itself to a the BTFD chart from dark-bid

          1 Reply Last reply Reply Quote 0
          • A
            ab_trader last edited by ab_trader

            My bad. I've expected that even by default the script will print or plot something. I am still struggling with your argument parsing approach. :)

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 0
            • A
              ab_trader last edited by

              Could you please clarify how does this script identify position size? As I remember default position size is 1, here you did't define position size directly, but it buys 2x cash at broker account. What if I want to buy for 1.5x broker cash or 3x broker cash? Will it work?

              • If my answer helped, hit reputation up arrow at lower right corner of the post.
              • Python Debugging With Pdb
              • New to python and bt - check this out
              1 Reply Last reply Reply Quote 0
              • B
                backtrader administrators last edited by

                The script doesn't identify position size, just if a position exists

                if self.position:
                

                The sizing is controlled with:

                 self.order_target_percent(target=self.p.target)
                

                where the default value for self.p.target is 1.0 (or 100%)

                And leverage is controlled by setting a default commission scheme in the broker with:

                cerebro.broker.setcommission(**eval('dict(' + args.comminfo + ')'))
                

                Pass --comminfo leverage=3.5 to play with a 3.5x leverage

                1 Reply Last reply Reply Quote 0
                • A
                  ab_trader last edited by

                  Thank you!

                  • If my answer helped, hit reputation up arrow at lower right corner of the post.
                  • Python Debugging With Pdb
                  • New to python and bt - check this out
                  1 Reply Last reply Reply Quote 0
                  • A
                    ab_trader last edited by ab_trader

                    Sorry to bother you with additional requests/complaints.

                    Now broker value is calculated as cash + open position and gives bursts of values when leverage isused. With this bursts all the drawdown calcs, sharpe (I think all the stats calculated based on equity) are incorrect. Usually the broker value in case of leverage is cash(=0) + open position - loan. In this case only gains/losses are added to broker value for open positions, not the full cost of position.

                    is there any way to fulfill such approach (apply loan on the broker value for open positions) in the bt in the baseline code?

                    Here is the link to picture https://yadi.sk/i/oLQA7-P235ZyDh
                    It is not shown in the post.

                    • If my answer helped, hit reputation up arrow at lower right corner of the post.
                    • Python Debugging With Pdb
                    • New to python and bt - check this out
                    1 Reply Last reply Reply Quote 0
                    • B
                      backtrader administrators last edited by

                      Such calculation is probably what's already being done: the unleveraged value.

                      The idea seems to be to swap the current value with the current unleveraged value, so that the actual value curve doesn't spike. The leveraged value would still be accessible.

                      It makes sense

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors