For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

leverage doesn't affect returns in backtesting



  • I'm a bit confused with the leverage,

    I ran my strategy twice, first time setting leverage 400, second time leverage 800, here's how I set the leverage:

    cerebro.broker.setcommission(commission=0.0, leverage=400)
    

    then pprinted the bt.analyzers.TradeAnalyzer with:

         print('TradeAnalyzer :')
         stats[0].analyzers.TradeAnalyzer.pprint()
    

    In both cases I get a bunch of stats about my analyzer, but what is strange is that the analysis I get is absolutely the same, numbers are an exact match for both leverages.

    Also my broker cash and broker value are the same.



  • If you have same trade stats for both cases, than (as a guess) you didn't increase position size to use that increased leverage.


  • administrators

    @ab_trader said in leverage doesn't affect returns in backtesting:

    If you have same trade stats for both cases, than (as a guess) you didn't increase position size to use that increased leverage.

    Right.

    @dongiulio said in leverage doesn't affect returns in backtesting:

    I get is absolutely the same, numbers are an exact match for both leverages

    You are confusing leverage with multiplier(which is used for example with Futures).

    • leverage gives you more buying potential. But it is a potential and the decision as to how much of that potential to use is yours

    • multiplier: affects directly the returns. Unfortunately assets in real-life have a fixed multiplier and you cannot choose it.



  • thanks, now it makes more sense.


 

});