coin-unknown / Indicators

Technical indicators for cryptocurrencies, stocks and forex. To work with historical and real price data. One of the most efficient Javascript library implementations. The library has such indicators as: Relative Strength Index (RSI), Moving Average C / D (MACD), Average Directional Index (ADX), Stochastic Oscillator, Bollinger Bands, Average True Range (ATR) and many others
377 stars 54 forks source link

Add floating error correction algorythm #54

Open BusinessDuck opened 2 months ago

BusinessDuck commented 2 months ago

Instead of BigInt and other heavy libraries that other indicators using to solve floating error, we need to use https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html Goldberg correction algorithm

BusinessDuck commented 2 months ago

https://github.com/guipn/sinful.js/blob/master/sinful.js an exmple of multiplication and other math operations

BusinessDuck commented 2 months ago

Benchmarks:

https://medium.com/leaningtech/a-fast-bigint-js-in-an-evening-compiling-c-to-javascript-db61ae733512 image

Native BigInt also looks good

https://www.measurethat.net/Benchmarks/Show/10997/0/js-big-integers-v2#latest_results_block