Refer to the relevant section of the stock_analytic module.