BTFD (Buy The F... Dip)


  • administrators

    Use the link below to go the original post

    Click here to see the full blog post



  • 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.


  • administrators

    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



  • 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. :)



  • 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?


  • administrators

    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



  • Thank you!



  • 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.


  • administrators

    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


Log in to reply
 

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