Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. darwinps
    3. Best
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 7
    • Best 1
    • Groups 0
    • Blog

    Best posts made by darwinps

    • single pass and multipass discrepancy

      Hi
      I have been trying to write a simple example with both single pass and multi pass just to understand them better. But I can't get them to produce the same result. Here is what I use:

      single pass version:

      import xarray as xr
      import qnt.ta as qnta
      import qnt.data as qndata
      
      data = qndata.futures_load_data(min_date='2006-01-01', max_date='2007-01-01', assets= ['F_ES'])
      
      close = data.sel(field='close')
      close_one_day_ago = qnta.shift(close, periods=1)
      
      _open = data.sel(field='open')
      open_one_day_ago = qnta.shift(_open, periods=1)
      
      weights = xr.where(open_one_day_ago < close_one_day_ago, 1, 0)
      

      The result looks like the following.
      singlepass.JPG

      multi pass version:

      import xarray as xr
      import qnt.ta as qnta
      import qnt.backtester as qnbt
      import qnt.data as qndata
      
      def load_data(period):
          return qndata.futures_load_data(tail=period, assets=['F_ES'])
      
      def strategy(data):
          close = data.sel(field='close')
          close_one_day_ago = qnta.shift(close, periods=1)
          _open = data.sel(field='open')
          open_one_day_ago = qnta.shift(_open, periods=1)
          weights = xr.where(open_one_day_ago < close_one_day_ago, 1, 0)
          return weights
      
      weights = qnbt.backtest(
          competition_type= 'futures',
          load_data= load_data,
          lookback_period= 365,
          start_date= '2006-01-01',
          end_date= '2007-01-01',
          strategy= strategy
      )
      

      The result look like the following.
      multipass.JPG

      Any help/hint/suggestion is greatly appreciated.

      posted in Support
      D
      darwinps
    • Documentation
    • About
    • Career
    • My account
    • Privacy policy
    • Terms and Conditions
    • Cookies policy
    Home
    Copyright © 2014 - 2021 Quantiacs LLC.
    Powered by NodeBB | Contributors