OPEN-SOURCE SCRIPT
Multivariate Kalman Filter

🙏🏻 I see no1 ever posted an open source Multivariate Kalman filter on TV, so here it is, for you. Tested and mathematically correct implementation, with numerical safeties in place that do not affect the final results at all. That’s the main purpose of this drop, just to make the tool available here. Linear algebra everywhere, Neo would approve 4 sure.
...
Personally I haven't found any real use case of it for myself, aside from a very specific one I will explain later, but others usually do…
Almost every1 in the quant industry who uses Kalman is in fact misusing it, because by its real definition, it should be applied to Not the exact known values (e.g as real ticks provided by transparent audited regulated exchange), but “measurements” of those ‘with errors’.
If your measurements don’t have errors or you have real precise data, by its internal formulas Kalman will output the exact inputs. So most who use it come up with some imaginary errors of sorts, like from some kind of imaginary fair price etc. The important easy to miss point, the errors of your measurements have to be symmetric around its mean ‘at least’, if errors are biased, Kalman won’t provide.
For most tasks there are better tools, including other state space models, but still Multivariate Kalman is a very powerful instrument, you can make it do all kinds of stuff. Also as a state space model it can also provide confidence & prediction intervals without explicit calculations of dem.
...
In this script I included 2 example use cases, the first one is the classic tho perfectly working misuse, the second one is what I do with it:
One
Naive, estimates “hidden” adaptive moving regression endpoint. The result you can see on the chart above. You can imagine that your real datapoints are in fact non perfect measures of some hidden state, and by defining measurement noise and process noise, and by constructing the input matrixes in certain ways, you can express what that state should be.
Two
Upscaling tick lattice, aka modelling prices as if native tick size would’ve been lower. Kinda very specific task, mostly needed in HFT or just for analytical purposes. Some like ZN have huge tick sizes, they are traded a lot but barely do more than 20 ticks range in a session. The idea is to model raw data as AR2 process, learn the phi1 and phi2, make one point forecasts based on dem, and the process noise would be the variance of errors from these forecasts. The measurement noise here is legit, it’s quantization noise based on tick size, no need in olympic gold in mental gymnastics xd

^^ artificially upscaling ZN futures tick lattice
...
I really made it available there so You guys can take it and some crazy ish with it, just let state space models abduct your conciseness and never look back
∞
...
Personally I haven't found any real use case of it for myself, aside from a very specific one I will explain later, but others usually do…
Almost every1 in the quant industry who uses Kalman is in fact misusing it, because by its real definition, it should be applied to Not the exact known values (e.g as real ticks provided by transparent audited regulated exchange), but “measurements” of those ‘with errors’.
If your measurements don’t have errors or you have real precise data, by its internal formulas Kalman will output the exact inputs. So most who use it come up with some imaginary errors of sorts, like from some kind of imaginary fair price etc. The important easy to miss point, the errors of your measurements have to be symmetric around its mean ‘at least’, if errors are biased, Kalman won’t provide.
For most tasks there are better tools, including other state space models, but still Multivariate Kalman is a very powerful instrument, you can make it do all kinds of stuff. Also as a state space model it can also provide confidence & prediction intervals without explicit calculations of dem.
...
In this script I included 2 example use cases, the first one is the classic tho perfectly working misuse, the second one is what I do with it:
One
Naive, estimates “hidden” adaptive moving regression endpoint. The result you can see on the chart above. You can imagine that your real datapoints are in fact non perfect measures of some hidden state, and by defining measurement noise and process noise, and by constructing the input matrixes in certain ways, you can express what that state should be.
Two
Upscaling tick lattice, aka modelling prices as if native tick size would’ve been lower. Kinda very specific task, mostly needed in HFT or just for analytical purposes. Some like ZN have huge tick sizes, they are traded a lot but barely do more than 20 ticks range in a session. The idea is to model raw data as AR2 process, learn the phi1 and phi2, make one point forecasts based on dem, and the process noise would be the variance of errors from these forecasts. The measurement noise here is legit, it’s quantization noise based on tick size, no need in olympic gold in mental gymnastics xd
^^ artificially upscaling ZN futures tick lattice
...
I really made it available there so You guys can take it and some crazy ish with it, just let state space models abduct your conciseness and never look back
∞
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Gor Dragongor
t.me/synchro1_channel
linkedin.com/company/synchro1
t.me/synchro1_channel
linkedin.com/company/synchro1
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Gor Dragongor
t.me/synchro1_channel
linkedin.com/company/synchro1
t.me/synchro1_channel
linkedin.com/company/synchro1
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。