more numeric instructions
Some checks are pending
CI / test-clj (push) Waiting to run
CI / test-cljs (push) Waiting to run

This commit is contained in:
Rowan Torbitzky-Lane 2025-03-14 01:41:50 -05:00
parent 90ff1c49de
commit c1255c5a88

View File

@ -50,6 +50,66 @@
(fn [stack state]
(make-instruction state #(if (> %1 %2) :hold nil) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is greater than the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _gt_buy_sell
"Pushes :buy onto the SIGNAL stack if the first item is greater
than the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gt_buy_sell"}
(fn [stack state]
(make-instruction state #(if (> %1 %2) :buy :sell) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is greater than the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _gt_buy_hold
"Pushes :buy onto the SIGNAL stack if the first item is greater
than the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gt_buy_hold"}
(fn [stack state]
(make-instruction state #(if (> %1 %2) :buy :hold) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is greater than the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _gt_sell_buy
"Pushes :sell onto the SIGNAL stack if the first item is greater
than the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gt_sell_buy"}
(fn [stack state]
(make-instruction state #(if (> %1 %2) :sell :buy) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is greater than the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _gt_sell_hold
"Pushes :sell onto the SIGNAL stack if the first item is greater
than the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gt_sell_buy"}
(fn [stack state]
(make-instruction state #(if (> %1 %2) :sell :hold) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is greater than the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _gt_hold_buy
"Pushes :hold onto the SIGNAL stack if the first item is greater
than the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gt_hold_buy"}
(fn [stack state]
(make-instruction state #(if (> %1 %2) :hold :buy) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is greater than the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _gt_hold_sell
"Pushes :hold onto the SIGNAL stack if the first item is greater
than the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gt_hold_buy"}
(fn [stack state]
(make-instruction state #(if (> %1 %2) :hold :sell) [stack stack] :signal)))
;; Pushes TRUE onto the BOOLEAN stack if the second item is greater than or
;; equal to the top item, and FALSE otherwise
(def _gte
@ -90,6 +150,66 @@
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :hold nil) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is greater than or equal to the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _gte_buy_sell
"Pushes :buy onto the SIGNAL stack if the first item is greater
than or equal to the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gte_buy_sell"}
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :buy :sell) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is greater than or equal to the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _gte_buy_hold
"Pushes :buy onto the SIGNAL stack if the first item is greater
than or equal to the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gte_buy_hold"}
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :buy :hold) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is greater than or equal to the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _gte_sell_buy
"Pushes :sell onto the SIGNAL stack if the first item is greater
than or equal to the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gte_sell_buy"}
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :sell :buy) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is greater than or equal to the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _gte_sell_hold
"Pushes :sell onto the SIGNAL stack if the first item is greater
than or equal to the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gte_sell_buy"}
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :sell :hold) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is greater than or equal to the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _gte_hold_buy
"Pushes :hold onto the SIGNAL stack if the first item is greater
than or equal to the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gte_hold_buy"}
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :hold :buy) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is greater than or equal to the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _gte_hold_sell
"Pushes :hold onto the SIGNAL stack if the first item is greater
than or equal to the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_gte_hold_buy"}
(fn [stack state]
(make-instruction state #(if (>= %1 %2) :hold :sell) [stack stack] :signal)))
;; Pushes TRUE onto the BOOLEAN stack if the second item is less than the top
;; item, and FALSE otherwise
(def _lt
@ -130,6 +250,66 @@
(fn [stack state]
(make-instruction state #(if (< %1 %2) :hold nil) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is less than the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _lt_buy_sell
"Pushes :buy onto the SIGNAL stack if the first item is less
than the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lt_buy_sell"}
(fn [stack state]
(make-instruction state #(if (< %1 %2) :buy :sell) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is less than the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _lt_buy_hold
"Pushes :buy onto the SIGNAL stack if the first item is less
than the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lt_buy_hold"}
(fn [stack state]
(make-instruction state #(if (< %1 %2) :buy :hold) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is less than the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _lt_sell_buy
"Pushes :sell onto the SIGNAL stack if the first item is less
than the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lt_sell_buy"}
(fn [stack state]
(make-instruction state #(if (< %1 %2) :sell :buy) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is less than the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _lt_sell_hold
"Pushes :sell onto the SIGNAL stack if the first item is less
than the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lt_sell_buy"}
(fn [stack state]
(make-instruction state #(if (< %1 %2) :sell :hold) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is less than the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _lt_hold_buy
"Pushes :hold onto the SIGNAL stack if the first item is less
than the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lt_hold_buy"}
(fn [stack state]
(make-instruction state #(if (< %1 %2) :hold :buy) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is less than the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _lt_hold_sell
"Pushes :hold onto the SIGNAL stack if the first item is less
than the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lt_hold_buy"}
(fn [stack state]
(make-instruction state #(if (< %1 %2) :hold :sell) [stack stack] :signal)))
;; Pushes TRUE onto the BOOLEAN stack if the second item is less than or equal
;; to the top item, and FALSE otherwise
(def _lte
@ -170,6 +350,66 @@
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :hold nil) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is less than or equal to the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _lte_buy_sell
"Pushes :buy onto the SIGNAL stack if the first item is less
than or equal to the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lte_buy_sell"}
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :buy :sell) [stack stack] :signal)))
;; Pushes :buy onto the SIGNAL stack if the first item is less than or equal to the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _lte_buy_hold
"Pushes :buy onto the SIGNAL stack if the first item is less
than or equal to the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lte_buy_hold"}
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :buy :hold) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is less than or equal to the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _lte_sell_buy
"Pushes :sell onto the SIGNAL stack if the first item is less
than or equal to the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lte_sell_buy"}
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :sell :buy) [stack stack] :signal)))
;; Pushes :sell onto the SIGNAL stack if the first item is less than or equal to the second
;; item, pushes :hold onto the SIGNAL stack otherwise.
(def _lte_sell_hold
"Pushes :sell onto the SIGNAL stack if the first item is less
than or equal to the second item, pushes :hold onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lte_sell_buy"}
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :sell :hold) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is less than or equal to the second
;; item, pushes :buy onto the SIGNAL stack otherwise.
(def _lte_hold_buy
"Pushes :hold onto the SIGNAL stack if the first item is less
than or equal to the second item, pushes :buy onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lte_hold_buy"}
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :hold :buy) [stack stack] :signal)))
;; Pushes :hold onto the SIGNAL stack if the first item is less than or equal to the second
;; item, pushes :sell onto the SIGNAL stack otherwise.
(def _lte_hold_sell
"Pushes :hold onto the SIGNAL stack if the first item is less
than or equal to the second item, pushes :sell onto the SIGNAL stack otherwise"
^{:stacks #{:signal}
:name "_lte_hold_buy"}
(fn [stack state]
(make-instruction state #(if (<= %1 %2) :hold :sell) [stack stack] :signal)))
;; Pushes the sum of the top two items onto the same stack
(def _add
"Pushes the sum of the top two items onto the same stack"
@ -297,7 +537,11 @@ Otherwise, acts as a NOOP"
[:float :integer]
[_gt _gte _lt _lte _add _subtract _mult _quot _mod _max _min _inc _dec
_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])
_gte_sell _gte_hold _lt_buy _lt_sell _lt_hold _lte_buy _lte_sell _lte_hold
_gt_buy_sell _gt_buy_hold _gt_sell_buy _gt_sell_hold _gt_hold_buy _gt_hold_sell
_gte_buy_sell _gte_buy_hold _gte_sell_buy _gte_sell_hold _gte_hold_buy _gte_hold_sell
_lt_buy_sell _lt_buy_hold _lt_sell_buy _lt_sell_hold _lt_hold_buy _lt_hold_sell
_lte_buy_sell _lte_buy_hold _lte_sell_buy _lte_sell_hold _lte_hold_buy _lte_hold_sell])
;; =============================================================================
;; FLOAT Instructions only
@ -332,6 +576,28 @@ Otherwise, acts as a NOOP"
(fn [state]
(make-instruction state math/tan [:float] :float)))
;; Pushes the square root of the top FLOAT. Makes the value
;; absolute first.
(def-instruction
:float_tan
^{:stacks #{:float}}
(fn [state]
(make-instruction state #(math/sqrt (abs %)) [:float] :float)))
;; Pushes the log of the top FLOAT
(def-instruction
:float_tan
^{:stacks #{:float}}
(fn [state]
(make-instruction state #(if (zero? %) 1 (math/log (abs %))) [:float] :float)))
;; Pushes the square of the top FLOAT
(def-instruction
:float_tan
^{:stacks #{:float}}
(fn [state]
(make-instruction state #(* % %) [:float] :float)))
;; Pushes the floating point version of the top INTEGER
(def-instruction
:float_from_integer