Open stash86 opened 2 months ago
Considering qtpylib is a vendored library we use (mostly) "as is" - I'd rather prefer to not mess with it too much.
We've disabled a few methods we know are lookahead-biased - but that's about it. It's also importable from 2 separate sources (it's vendored both here and in freqtrade itself) - which doesn't simplify things in this regards (this could be solved - but it'll still remain a vendored file).
If we see us being disturbed by that - i think it should be reworked completely - as i think it does some things a bit oddly - not necessarily in a way you'd do it if you're looking at it from a pure performance point of view) (numpy_rolling_mean
is effectively ta.SMA - but expressed / implemented in a very verbose and nested way).
To be quite fair - raising ValueError
in case of an invalid input doesn't seem wrong - why suggest that "it worked but you get nothing" if the user provided invalid inputs?
For example. If you are doing ta.SMA of 100 but you have only 50 rows, it would just give you NaN for all the rows, so I assume same thing can be applied here? Getting NaN should equate to "the calculation failed".
Ofc this is a very rare case, when we throw less than 34 rows of data to the awesome_oscilator, but it can happen when one trying to test lookahead by cutting the timerange to just 10 candles and the strategy using no startup_candle_count 😁
I'll look at another way of dealing with the issue then, and not changing the lib.
well my point is - IF we assume that we'll take over qtpylib's indicators (we vendor them - but upstream has been archived earlier this year, so there won't be any fixes anymore) - then we'll need to
np.rolling(x).mean()
When function numpy_rolling_window is called, if length of data is less than the supplied
window
value, this error will be thrownThe error above was thrown when I tried to calculate qptylib.awesome_oscilator with the default fast and slow values. The issue is the supplied data was only 10 rows. When I changed the
slow
parameter to something less than 10 (for example 7), there was no error,Is is possible to add a check at the beginning of numpy_rolling_window and maybe return NaN when the length of data is smaller than the
window
value?