Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Calculation of trading strategies

    Strategy help
    3
    26
    1854
    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.
    • support
      support last edited by

      Hello, any indicator has some parameter dependence, for example a lookback period which defines a window of data values used for defining the indicator.

      The value of the indicator changes as the window rolls over time day by day.

      D 1 Reply Last reply Reply Quote 0
      • D
        dark.pidgeot @support last edited by

        @support Hi, my strategy was rejected : Not enough bid information. The strategy must trade from January 1st, 2006
        cae159e2-6b6a-4cc0-9c1d-c945dd4a361e-image.png

        support 1 Reply Last reply Reply Quote 0
        • support
          support @dark.pidgeot last edited by

          @dark-pidgeot Hello, does the strategy trade at all since 1 Jan 2006? It must trade, otherwise it is rejected.

          D 2 Replies Last reply Reply Quote 0
          • D
            dark.pidgeot @support last edited by

            @support
            Hello, it trades before 2006 but not after 2006. I don't understand the reason, however, in the backtest, it trades over the entire period.

            1 Reply Last reply Reply Quote 0
            • D
              dark.pidgeot @support last edited by

              @support When I backtest my strategy, the logs says : WARNING! There are not enough points in the data for the slippage calculation.
              Add 15 extra data points to the data head (load data more historical data).
              WARNING! There are not enough points in the output.
              The output series should start from 2006-01-01 or earlier instead of 2006-01-25

              support 1 Reply Last reply Reply Quote 0
              • support
                support @dark.pidgeot last edited by

                @dark-pidgeot Ok, thanks. For computing slippage the toolbox uses a fixed percentage of ATR(14), an indicator called the Average True Range, which is computed using the data points for the last 14 days. So to generate a position on 2 Jan 2006, let us say, you need data for the last 15 days also. Otherwise ATR will not be computed.

                D 1 Reply Last reply Reply Quote 0
                • D
                  dark.pidgeot @support last edited by

                  @support Hello,

                  thank you for your feedback,

                  how could I avoid this, please?

                  support 1 Reply Last reply Reply Quote 0
                  • support
                    support @dark.pidgeot last edited by

                    @dark-pidgeot

                    Could you send a code snippet showing how you load the data?

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      dark.pidgeot @support last edited by

                      @support Hi, the head on the strategy is :

                      import xarray as xr
                      import qnt.ta as qnta
                      import qnt.data as qndata
                      import qnt.output as qnout
                      import qnt.stats as qns
                      from IPython.display import display
                      import xarray as xr
                      import qnt.ta as qnta
                      import qnt.backtester as qnbt
                      import qnt.data as qndata

                      data = qndata.stocks.load_ndx_data(min_date="2000-01-01")

                      support 1 Reply Last reply Reply Quote 0
                      • support
                        support @dark.pidgeot last edited by

                        @dark-pidgeot Ok, thanks. It means that you are using a single-pass approach, not the built-in backtester.

                        Is your system generating trades since 1 Jan 2006 or you do not have any trade before?

                        D 1 Reply Last reply Reply Quote 0
                        • D
                          dark.pidgeot @support last edited by

                          @support Yes, i Use the single pass, I must change it on multi pass ?

                          support 1 Reply Last reply Reply Quote 0
                          • support
                            support @dark.pidgeot last edited by

                            @dark-pidgeot The single pass is ok. However, when the code is run, it will be automatically sliced and run in multi-pass fashion to avoid unintentional forward looking (example: usage of global means).

                            Here it seems that your system makes no trades at all before 1 Jan 2006. Can you check that visualizing the equity curve?

                            D 3 Replies Last reply Reply Quote 0
                            • D
                              dark.pidgeot @support last edited by

                              @support Hello,

                              when I do the test, it seems ok except on the last day

                              1 Reply Last reply Reply Quote 0
                              • D
                                dark.pidgeot @support last edited by

                                @support 098f8748-2b83-4aa6-af81-77314e896bc0-image.png

                                1 Reply Last reply Reply Quote 0
                                • D
                                  dark.pidgeot @support last edited by

                                  @support 354e802e-85e0-4891-a262-8741e6e449a6-image.png

                                  support 1 Reply Last reply Reply Quote 0
                                  • support
                                    support @dark.pidgeot last edited by

                                    @dark-pidgeot Ok, thanks. If you click on the logs button, there should be info explaining he reason for the failure on Sep 1st. Can you share it?

                                    D 3 Replies Last reply Reply Quote 0
                                    • D
                                      dark.pidgeot @support last edited by

                                      @support Hello, yes I can provide you with the logs without the code.
                                      I am still surprised, I followed the simulation. Everything is going well except for the last day. How is it possible that on the last day, it crashes

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        dark.pidgeot @support last edited by

                                        @support Calculation start...
                                        [NbConvertApp] Converting notebook strategy.ipynb to html
                                        [NbConvertApp] Executing notebook with kernel: python3
                                        [NbConvertApp] Writing 699954 bytes to strategy.html
                                        Calculation completed.
                                        Strategy body:

                                        In [1]:
                                        %%javascript
                                        window.IPython && (IPython.OutputArea.prototype._should_scroll = function
                                        (lines) { return false; })
                                        // run this cell for disabling widget scrolling
                                        In [2]:
                                        import xarray as xr
                                        import qnt.ta as qnta
                                        import qnt.data as qndata
                                        import qnt.output as qnout
                                        import qnt.stats as qns
                                        from IPython.display import display
                                        import xarray as xr
                                        import qnt.ta as qnta
                                        import qnt.backtester as qnbt
                                        import qnt.data as qndata
                                        data = qndata.stocks.load_ndx_data(min_date="2005-01-01")

                                        HIDDEN strategy CODE

                                        SINGLE PASS

                                        is_liquid = data.sel(field="is_liquid")
                                        weights = is_liquid*weights

                                        clean weights taking corner cases into account:

                                        weights = qnout.clean(weights, data, "stocks_nasdaq100")

                                        check before submission:

                                        qnout.check(weights, data, "stocks_nasdaq100")
                                        qnout.write(weights)

                                        calc stats

                                        stats = qns.calc_stat(data, weights.sel(time=slice("2000-01-01",None)))
                                        stats.to_pandas().tail()
                                        import qnt.graph as qngraph
                                        import qnt.stats as qnstats
                                        statistics = qnstats.calc_stat(data, weights)
                                        performance = statistics.to_pandas()['equity']
                                        qngraph.make_plot_filled(performance.index, performance, name='PnL (Equity)')

                                        qnout.check(weights, data)
                                        100% (35181 of 35181) |##################| Elapsed Time: 0:00:00 Time: 0:00:00
                                        100% (35957 of 35957) |##################| Elapsed Time: 0:00:00 Time: 0:00:00
                                        100% (14750756 of 14750756) |############| Elapsed Time: 0:00:00 Time: 0:00:00
                                        fetched chunk 1/6 1s
                                        100% (14750752 of 14750752) |############| Elapsed Time: 0:00:00 Time: 0:00:00
                                        fetched chunk 2/6 3s
                                        100% (14750720 of 14750720) |############| Elapsed Time: 0:00:00 Time: 0:00:00
                                        fetched chunk 3/6 4s
                                        100% (14750628 of 14750628) |############| Elapsed Time: 0:00:00 Time: 0:00:00
                                        fetched chunk 4/6 6s
                                        100% (14750720 of 14750720) |############| Elapsed Time: 0:00:00 Time: 0:00:00
                                        fetched chunk 5/6 7s
                                        100% (979196 of 979196) |################| Elapsed Time: 0:00:00 Time: 0:00:00
                                        fetched chunk 6/6 7s
                                        Data loaded 8s
                                        Output cleaning...
                                        fix uniq
                                        ffill if the current price is None...
                                        Check liquidity...
                                        Ok.
                                        Check missed dates...
                                        Ok.
                                        Normalization...
                                        Output cleaning is complete.
                                        Check liquidity...
                                        Ok.
                                        Check missed dates...
                                        Ok.
                                        Check the sharpe ratio...
                                        Period: 2006-01-01 - 2022-09-01
                                        Sharpe Ratio =#####
                                        Ok.
                                        Check correlation.
                                        correlation check disabled

                                        Ok. This strategy does not correlate with other strategies.
                                        Write output: /root/fractions.nc.gz
                                        Check liquidity...
                                        Ok.
                                        Check missed dates...
                                        Ok.
                                        Check the sharpe ratio...
                                        Period: 2006-01-01 - 2022-09-01
                                        Sharpe Ratio = #####
                                        Ok.
                                        Check correlation.
                                        correlation check disabled

                                        Ok. This strategy does not correlate with other strategies.
                                        In [3]:
                                        performance = statistics.to_pandas()['equity']
                                        qngraph.make_plot_filled(performance.index, performance, name='PnL (Equity)')
                                        Submit...
                                        Post task: https://stat.quantiacs.io/regular/task/343939393231303664343261616232333665666532323034343662653936326535353161353038306566633564333132613465326339326330653931646339363A313636323530313135303A37333730333736/regular/task
                                        {
                                        "submission_id": "7941751",
                                        "output": "H4sIAD3BF2MC/+y9X8xl1ZUnRiZmXBnSEjQVgxCGQUJqWtaIns...",
                                        "source": true,
                                        "html": "H4sIAEbBF2MC/+y9a5PcOK4g+t2/Iscdc9vurkynlG972mdmz2...",
                                        "state": null,
                                        "last_data": true
                                        }
                                        Task #7370376

                                        1 Reply Last reply Reply Quote 0
                                        • D
                                          dark.pidgeot @support last edited by

                                          @support The short description :

                                          INFO: 2022-09-06T21:52:30Z: pass started: 7962346
                                          INFO: 2022-09-06T21:53:13Z: pass completed: 7962346
                                          INFO: 2022-09-06T22:49:52Z: stats received light=false
                                          INFO: 2022-09-06T22:49:53Z: progress: 1.0
                                          INFO: 2022-09-06T22:49:53Z: checking: last pass
                                          INFO: 2022-09-06T22:49:53Z: filter passed: source exists
                                          INFO: 2022-09-06T22:49:53Z: filter passed: output html exists
                                          INFO: 2022-09-06T22:49:53Z: filter passed: output exists
                                          INFO: 2022-09-06T22:49:53Z: filter passed: strategy uses the last data
                                          INFO: 2022-09-06T22:49:53Z: filter passed: liquidity
                                          FAIL: 2022-09-06T22:49:53Z: filter failed: in sample period is too short:3417 < 3764

                                          support 1 Reply Last reply Reply Quote 0
                                          • support
                                            support @dark.pidgeot last edited by

                                            @dark-pidgeot ok, there are not enough trading days. Are you generating non-zero positions since 1 Jan 2006?

                                            D 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB | Contributors
                                            • Documentation
                                            • About
                                            • Career
                                            • My account
                                            • Privacy policy
                                            • Terms and Conditions
                                            • Cookies policy
                                            Home
                                            Copyright © 2014 - 2021 Quantiacs LLC.
                                            Powered by NodeBB | Contributors