Python and floating point
-
Ran across this bit of code today in QSTrader. https://github.com/mhallsmoore/qstrader/blob/master/qstrader/price_parser.py
MHM is going to an incredible amount of effort there to avoid floating point arithmetic. I'm curious if anyone here thinks this is really necessary with our current toolset?
-
That module is only a trick which works until precision x (for x number of decimals)
No floating point uncertainty would require the use of Binary Coded Decimals (python has a built-in module) which is certain going to kill any performance.
The output of indicators of the indicators developed for backtrader was checked down to the 4th decimal against the output of two commercial platforms (this also revealed flaws in the implementation of some indicators in those platforms, sometimes for example as to what the initial conditions have to fulfill)
-
Thank you. Good to know.