buy,hold,sell comparison functions
This commit is contained in:
parent
4ff98629f9
commit
2ad54d8189
@ -28,7 +28,27 @@
|
|||||||
^{:stacks #{:signal}
|
^{:stacks #{:signal}
|
||||||
:name "_gt_buy"}
|
:name "_gt_buy"}
|
||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state #(if (%1 > %2) :buy nil) [stack stack] :signal)))
|
(make-instruction state #(if (> %1 %2) :buy nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :sell onto the SIGNAL stack if the first item is greater than the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _gt_sell
|
||||||
|
"Pushes :sell onto the SIGNAL stack if the first item is greater
|
||||||
|
than the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_gt_sell"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (> %1 %2) :sell nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :hold onto the SIGNAL stack if the first item is greater than the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _gt_hold
|
||||||
|
"Pushes :hold onto the SIGNAL stack if the first item is greater
|
||||||
|
than the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_gt_hold"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (> %1 %2) :hold nil) [stack stack] :signal)))
|
||||||
|
|
||||||
;; Pushes TRUE onto the BOOLEAN stack if the second item is greater than or
|
;; Pushes TRUE onto the BOOLEAN stack if the second item is greater than or
|
||||||
;; equal to the top item, and FALSE otherwise
|
;; equal to the top item, and FALSE otherwise
|
||||||
@ -40,6 +60,36 @@
|
|||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state >= [stack stack] :boolean)))
|
(make-instruction state >= [stack stack] :boolean)))
|
||||||
|
|
||||||
|
;; Pushes :buy onto the SIGNAL stack if the first item is greater than or equal to the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _gte_buy
|
||||||
|
"Pushes :buy onto the SIGNAL stack if the first item is greater
|
||||||
|
than or equal to the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_gte_buy"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (>= %1 %2) :buy nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :sell onto the SIGNAL stack if the first item is greater than or equal to the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _gte_sell
|
||||||
|
"Pushes :sell onto the SIGNAL stack if the first item is greater
|
||||||
|
than or equal to the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_gte_sell"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (>= %1 %2) :sell nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :hold onto the SIGNAL stack if the first item is greater than or equal to the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _gte_hold
|
||||||
|
"Pushes :hold onto the SIGNAL stack if the first item is greater
|
||||||
|
than or equal to the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_gte_hold"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (>= %1 %2) :hold nil) [stack stack] :signal)))
|
||||||
|
|
||||||
;; Pushes TRUE onto the BOOLEAN stack if the second item is less than the top
|
;; Pushes TRUE onto the BOOLEAN stack if the second item is less than the top
|
||||||
;; item, and FALSE otherwise
|
;; item, and FALSE otherwise
|
||||||
(def _lt
|
(def _lt
|
||||||
@ -50,6 +100,36 @@
|
|||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state < [stack stack] :boolean)))
|
(make-instruction state < [stack stack] :boolean)))
|
||||||
|
|
||||||
|
;; Pushes :buy onto the SIGNAL stack if the first item is less than the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _lt_buy
|
||||||
|
"Pushes :buy onto the SIGNAL stack if the first item is less
|
||||||
|
than the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_lt_buy"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (< %1 %2) :buy nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :sell onto the SIGNAL stack if the first item is less than the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _lt_sell
|
||||||
|
"Pushes :sell onto the SIGNAL stack if the first item is less
|
||||||
|
than the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_lt_sell"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (< %1 %2) :sell nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :hold onto the SIGNAL stack if the first item is less than the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _lt_hold
|
||||||
|
"Pushes :hold onto the SIGNAL stack if the first item is less
|
||||||
|
than the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_lt_hold"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (< %1 %2) :hold nil) [stack stack] :signal)))
|
||||||
|
|
||||||
;; Pushes TRUE onto the BOOLEAN stack if the second item is less than or equal
|
;; Pushes TRUE onto the BOOLEAN stack if the second item is less than or equal
|
||||||
;; to the top item, and FALSE otherwise
|
;; to the top item, and FALSE otherwise
|
||||||
(def _lte
|
(def _lte
|
||||||
@ -60,6 +140,36 @@
|
|||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state <= [stack stack] :boolean)))
|
(make-instruction state <= [stack stack] :boolean)))
|
||||||
|
|
||||||
|
;; Pushes :buy onto the SIGNAL stack if the first item is less than or equal to the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _lte_buy
|
||||||
|
"Pushes :buy onto the SIGNAL stack if the first item is less
|
||||||
|
than or equal to the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_lte_buy"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (<= %1 %2) :buy nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :sell onto the SIGNAL stack if the first item is less than or equal to the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _lte_sell
|
||||||
|
"Pushes :sell onto the SIGNAL stack if the first item is less
|
||||||
|
than or equal to the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_lte_sell"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (<= %1 %2) :sell nil) [stack stack] :signal)))
|
||||||
|
|
||||||
|
;; Pushes :hold onto the SIGNAL stack if the first item is less than or equal to the second
|
||||||
|
;; item, and acts as a no-op otherwise.
|
||||||
|
(def _lte_hold
|
||||||
|
"Pushes :hold onto the SIGNAL stack if the first item is less
|
||||||
|
than or equal to the second item, and acts as a no-op otherwise"
|
||||||
|
^{:stacks #{:signal}
|
||||||
|
:name "_lte_hold"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(if (<= %1 %2) :hold nil) [stack stack] :signal)))
|
||||||
|
|
||||||
;; Pushes the sum of the top two items onto the same stack
|
;; Pushes the sum of the top two items onto the same stack
|
||||||
(def _add
|
(def _add
|
||||||
"Pushes the sum of the top two items onto the same stack"
|
"Pushes the sum of the top two items onto the same stack"
|
||||||
@ -186,7 +296,8 @@ Otherwise, acts as a NOOP"
|
|||||||
(generate-instructions
|
(generate-instructions
|
||||||
[:float :integer]
|
[:float :integer]
|
||||||
[_gt _gte _lt _lte _add _subtract _mult _quot _mod _max _min _inc _dec
|
[_gt _gte _lt _lte _add _subtract _mult _quot _mod _max _min _inc _dec
|
||||||
_from_boolean _from_char _from_string, _gt_buy])
|
_from_boolean _from_char _from_string _gt_buy _gt_sell _gt_hold _gte_buy
|
||||||
|
_gte_sell _gte_hold _lt_buy _lt_sell _lt_hold _lte_buy _lte_sell _lte_hold])
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; FLOAT Instructions only
|
;; FLOAT Instructions only
|
||||||
|
Loading…
x
Reference in New Issue
Block a user