New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behaviour with replace-missing, first value propagated up despite :down strategy #305
Comments
Yes for sure - I agree behavior is wrong |
@genmeblog - Will fixing this the suggested way cause regressions in TC? |
Yeah, it caused a regression. However I need to check why I initially implemented it this way. The proposed behavior is actually the proper one. |
Additionally I think the other functionality is removed. Just
I propose to keep this path. |
Got it. Yep - makes sense. |
Thanks. To summarize:
|
Updated with the proximally above specification with the addition that value is taken into consideration even when using updown or downup in that if the value is provided it overrides the secondary direction. Release 6.090. |
Hi Chris,
replace-missing
is very useful especially with time series data, when used with strategy:down
it typically means "if market was closed for this particular security on this day, use the previous day". Howeverreplace-missing
behaves unexpectedly when the column starts with nil values: it propagates the first value into the past. So[nil nil 5 3 nil 2 4]
becomes[5 5 5 3 3 2 4]
instead of[nil nil 5 3 3 2 4]
(latter is also the pandas behaviour). In real life thenil
at the beginning means "the security didn't exist yet".Would it be possible to add a strategy that does the above? I've tried looking into the code but it's too complex for me... of course a low performance version would be
(reduce (fn [a b] (conj a (if (nil? b) (peek a) b))) [] coll)
Thank you!
The text was updated successfully, but these errors were encountered: