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/

    Sharpe ratio with seconds-resolution data

    Indicators/Strategies/Analyzers
    3
    4
    140
    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
      benmercerdev last edited by

      I'm using a custom data set

      Date,Ask,Bid,Volume,Close
      2020-04-16 09:29:00,3779.4,3778.2,1133760.0,3778.8
      2020-04-16 09:30:00,3781.0,3777.8,1133731.7857142857,3779.4
      2020-04-16 09:30:00,3779.4,3778.0,1133717.7721518988,3778.7
      2020-04-16 09:30:01,3779.2,3778.2,1133700.3956043955,3778.7
      

      Resampling with this:

      cerebro.resampledata(
              data1, timeframe=bt.TimeFrame.Seconds, compression=1)
      

      And trying to add Sharpe ration calculation like this:

      cerebro.addanalyzer(btanalyzers.SharpeRatio, _name='mysharpe',
                              timeframe=bt.TimeFrame.Seconds, factor=252, compression=60)
      

      I'm a bit unclear about the factor and the compression parameters for the SharpeRatio analyzer and what they should be for my timeframe?

      Thanks ahead of time for any help!

      1 Reply Last reply Reply Quote 0
      • S
        soulmachine last edited by

        @benmercerdev Your compression is incorrect, you should use the following:

        cerebro.addanalyzer(btanalyzers.SharpeRatio, _name='mysharpe',
                                timeframe=bt.TimeFrame.Seconds, factor=252, compression=60*60*24)
        
        1 Reply Last reply Reply Quote 0
        • S
          soulmachine last edited by

          @benmercerdev See my another post https://community.backtrader.com/topic/2747/how-to-initialize-bt-analyzers-sharperatio/

          1 Reply Last reply Reply Quote 0
          • run-out
            run-out last edited by

            There's a current thread on this topic here

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
            $(document).ready(function () { app.coldLoad(); }); }