A third refactor of the analytic functions

We'll refactor simple-moving-average, exponential-moving-average, and bollinger-band at the same time. At each point, we need to take the reduce block of code and change it to a lazy version that fits a function's process criteria:

(defn simple-moving-average [options tick-window tick-list] (let [start-index tick-window {input-key :input output-key :output etal-keys :etal :or {input-key :last-trade-price output-key :last-trade-price-average etal-keys [:last-trade-price :last-trade-time]}} options] (map (fn [ech] (let [tsum (reduce (fn [rr ee] (let [ltprice (:last-trade-price ee)] (+ ltprice rr))) 0 ech) taverage (/ tsum (count ech))] (merge (zipmap etal-keys (map #(% (last ech)) etal-keys)) {output-key ...

Get Clojure for Finance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.