diff --git a/apps/website/src/utils/historic/calculateDiff.ts b/apps/website/src/utils/historic/calculateDiff.ts new file mode 100644 index 0000000..2dd95f2 --- /dev/null +++ b/apps/website/src/utils/historic/calculateDiff.ts @@ -0,0 +1,9 @@ +const calculateHistoricDiff = (currentPrice: number, percent: number) => { + let indexChange = Math.abs(percent) / 100 + const dif = currentPrice * indexChange + const sign = Math.sign(percent) * -1 + + return currentPrice + sign * dif +} + +export default calculateHistoricDiff