Created
July 18, 2018 00:42
-
-
Save twashing/8da19cb30ff7bca6ed346d2a9a97e699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require | |
'[clojure.core.async :refer [chan sliding-buffer <! go-loop onto-chan] :as async] | |
'[manifold.stream :as stream] | |
'[prpr.stream.cross :as stream.cross]) | |
(let [tick-list->macd-ch (chan (sliding-buffer 50)) | |
sma-list->macd-ch (chan (sliding-buffer 50)) | |
tick-list->MACD (->> tick-list->macd-ch | |
stream/->source | |
(stream.cross/event-source->sorted-stream :id)) | |
sma-list->MACD (->> sma-list->macd-ch | |
stream/->source | |
(stream.cross/event-source->sorted-stream :id)) | |
result (stream.cross/set-streams-union {:default-key-fn :id | |
:skey-streams {:tick-list tick-list->MACD | |
:sma-list sma-list->MACD}}) | |
connector-ch (chan (sliding-buffer 100))] | |
;; OK | |
#_(go-loop [r (<! tick-list->macd-ch)] | |
(info r) | |
(when r | |
(recur (<! tick-list->macd-ch)))) | |
;; OK | |
#_(stream/map (fn [r] | |
(prn ">> " r) | |
r) | |
sma-list->MACD) | |
(stream/connect @result connector-ch) | |
(go-loop [{:keys [tick-list sma-list] :as r} (<! connector-ch)] | |
(info "record: " r) | |
(if-not r | |
r | |
(recur (<! connector-ch)))) | |
(onto-chan tick-list->macd-ch [{:id :a :val 1} {:id :b :val 2} {:id :c :val 3}]) | |
(onto-chan sma-list->macd-ch [{:id :a :val 2} {:id :b :val 3} {:id :c :val 4}])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I seem to have gotten a bit further with
[employeerepublic/promisespromises "0.5"]
, which works with[manifold "0.1.7-alpha6"]
.