Control the Analyzer to start
tomcpli.update last edited by
I have 3 years of data adding to the cerebro. I only interest on the performance from the 2nd year to the end of the data. Is there a way to tell the Analyzer to start from the 2nd year?
Without knowing the details it would seem that even if you want the analyzer (which?) to look at the data from the 2nd and later years, you are actually doing something (trades) during the 1st year.
Analyzers are actually looking all the time at whatever it happens in the system (for example at the current value of the portfolio to calculate returns)
TimeReturnprovides a parameter (
_doprenext) to actually only calculate returns from the point at which the strategy could formally start trading (when
nextis called) This is especially useful when using it as
Benchmark(@dimitar-petrov found an issue with resampled data and this hook a couple of days ago), because benchmarking against a data or some other asset only happens when
With that in mind and if
TimeReturnis in use you could add an indicator to the strategy which forces
prenextto be called until the end of the 1st year. Setting
_doprenext=Falsewould achieve the effect.
Yes, the problem is that such an indicator which may for for example be
pto be calculated in advance at the start for it to be completely generic (you can always set a fixed value if you use the same data feed several times), which is not possible if the code has to work with data feeds of unknown length.
tomcpli.update last edited by tomcpli.update
Thank you very much. _doprenext=False is working in my case. Is it also apply to other built-in analyzer ? it looks like analyzers.SharpeRatio does not support _doprenext. Any suggestion?
SharpeRatioanalyzer doesn't do rolling calculations, it does the calculation when everything is over.
You can subclass it, override
__init__and create the sub analyzer
TimeReturnanalyzer with your