Moving Average Implementation

Overview

The example code given uses the following sample dataset.

A moving average is a smoothed representation of a time series.

(async function(){ let ma = await import('/code/moving-average/v1.0.0/moving-average.mjs') let data = await $url({ url:"/data/sample/fixedtimeseries.json" }); let mas = ma.movingAverage(data.map(p=>p.price), 10); let madata = data.map((p,i)=>({...p,ma:mas[i]})); $val.set('data', madata); })();