title: Compute Simple Moving Average in Mongo Shell
body: <p>I am developing a financial application with Nodejs. I wonder would it be possible to compute simple moving average which is the average last N days of price directly in Mongo Shell than reading it and computing it in Node js.</p>
  
  <p>Document Sample.</p>
  
  <pre><code>[{code:'0001',price:0.10,date:'2014-07-04T00:00:00.000Z'},
  {code:'0001',price:0.12,date:'2014-07-05T00:00:00.000Z'},{code:'0001',price:0.13,date:'2014-07-06T00:00:00.000Z'},
  {code:'0001',price:0.12,date:'2014-07-07T00:00:00.000Z'}]
  </code></pre>