Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. eprice122
    3. Best
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    E
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Best 2
    • Groups 0

    Best posts made by eprice122

    • RE: How to create pyfolio round trip tearsheet?

      @balibou Currently I have it set up so the timeframe I am testing is pulled from a DB (similar to pulling the data from a csv) and turned into the benchmark.

      """
          You can assume parsed is a dict with datetime keys and close values
          parsed = {
              datetime.datetime(2014, 2, 3, 9, 30):176.74
              datetime.datetime(2014, 2, 3, 9, 31): 177.01
              ...
          }
          """
          benchmark = (
              pd.DataFrame.from_dict(parsed, orient="index")
              .pct_change()
              .fillna(0)
              .replace([np.inf, -np.inf], float("NaN"))
              .dropna()
          ) # All these functions on the datafame were involved in the quantstat util functions I mentioned
      

      If your's isn't working as expected, I found it helpful to call _prepare_benchmark("SPY")
      then turn it to a dict and see how the benchmark dataframe would look with TimeFrame.Days.

      Also your df_values dataframe should have the same length, start & end dates as the benchmark.

      Hopefully this helps.

      posted in Indicators/Strategies/Analyzers
      E
      eprice122
    • RE: How to create pyfolio round trip tearsheet?

      I did some debugging and found that a reason some functions don't work in quantstats is because the 'benchmark' it uses is yahoo finance data with a one day timeframe.

      If you try and run this on another timeframe, the returns and benchmark dataframes are different sizes. I had success with these functions by making my own benchmark dataframe with my timeframe.

      Look at the functions: _prepare_benchmark and download_returns in the quantstats utils file to accomplish this.

      posted in Indicators/Strategies/Analyzers
      E
      eprice122
    • 1 / 1