Update examples to use StreamNode and Series with lookback
The `PipelineNode` has been refactored into `StreamNode`. This commit updates the example files to reflect this change and also updates the `series` constructor to accept a lookback parameter. The `PipelineNode` was an artifact of a previous implementation and is no longer needed. The `StreamNode` is the appropriate type for representing the output of a pipe operation. The `series` function now requires a `lookback` argument to specify the maximum number of items to store. This makes the behavior of series more explicit and prevents accidental unbounded memory growth.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;; Benchmark: 2.1us
|
||||
;; Benchmark-Repeat: 921
|
||||
;; Output: PipelineNode[last: Some(110.45243843391206)]
|
||||
;; Benchmark: 2.1us
|
||||
;; Benchmark-Repeat: 921
|
||||
;; Output: <StreamNode>
|
||||
|
||||
(do
|
||||
(def src1 (create-random-ohlc 42 3))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;; Benchmark: 3.2us
|
||||
;; Benchmark-Repeat: 613
|
||||
;; Output: PipelineNode[last: Some(110.45243843391206)]
|
||||
;; Output: <StreamNode>
|
||||
|
||||
(do
|
||||
;; Set the random seed to match the existing test output exactly
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
;; Benchmark: 1.5us
|
||||
;; Benchmark-Repeat: 1348
|
||||
;; Benchmark: 1.5us
|
||||
;; Benchmark-Repeat: 1348
|
||||
;; Test Record SoA specialization in Pipelines
|
||||
;; Dank der neuen Spezialisierung wird hierfür im Hintergrund
|
||||
;; eine SharedRecordSeries mit SoA-Layout (Float-Puffer für mid und range) erstellt.
|
||||
|
||||
;; Output: PipelineNode[last: Some({:mid 101.35623617501585, :range 0.9314056584827455})]
|
||||
|
||||
;; Output: <StreamNode>
|
||||
|
||||
(do
|
||||
(def ohlc_stream (create-random-ohlc 42 10))
|
||||
|
||||
|
||||
+17
-7
@@ -1,12 +1,22 @@
|
||||
#use rtl
|
||||
|
||||
(do
|
||||
(def src (create-random-ohlc 42 200))
|
||||
(def src (create-random-ohlc 42 20000))
|
||||
|
||||
(macro printx [s] `(fn [x] (print ~s x)))
|
||||
|
||||
; (pipe src print)
|
||||
; (pipe [(pipe [(.close src)] (SMA 20))] (printx "sma20="))
|
||||
; (pipe [(pipe [(.close src)] (SMA 5))] (printx "sma5="))
|
||||
; (pipe [(pipe [(.close src)] (SMA 100))] (printx "sma100="))
|
||||
|
||||
(macro printx [s] `(fn [x] (print ~s x)))
|
||||
(macro cache [lookback type src] `(do (def data (series ~lookback ~type)) (pipe [~src] (fn [s] (do (push data s)))) data))
|
||||
|
||||
(pipe src print)
|
||||
(pipe [(pipe [(.close src)] (SMA 20))] (printx "sma20="))
|
||||
(pipe [(pipe [(.close src)] (SMA 5))] (printx "sma5="))
|
||||
(pipe [(pipe [(.close src)] (SMA 100))] (printx "sma100="))
|
||||
)
|
||||
|
||||
|
||||
; (def bars (series 20 :float))
|
||||
; (pipe [src] (fn [s] (do (push bars (.close s)))))
|
||||
|
||||
(cache 20 :float src)
|
||||
|
||||
)
|
||||
@@ -2,7 +2,7 @@
|
||||
;; Benchmark: 1.4us
|
||||
;; Benchmark-Repeat: 1406
|
||||
(do
|
||||
(def my_ticks (series {:price :float :volume :int :msg :text}))
|
||||
(def my_ticks (series 100 {:price :float :volume :int :msg :text}))
|
||||
|
||||
(push my_ticks {:price 10.5 :volume 100 :msg "A"})
|
||||
(push my_ticks {:price 11.2 :volume 200 :msg "B"})
|
||||
|
||||
Reference in New Issue
Block a user