more functions !!!!!
This commit is contained in:
parent
c1255c5a88
commit
c8510755e0
@ -533,6 +533,14 @@ Otherwise, acts as a NOOP"
|
|||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state dec [stack] stack)))
|
(make-instruction state dec [stack] stack)))
|
||||||
|
|
||||||
|
;; Pushes the square of the top item of the stack
|
||||||
|
(def _square
|
||||||
|
"Pushes the square of the top item of the stack"
|
||||||
|
^{:stacks #{}
|
||||||
|
:name "_square"}
|
||||||
|
(fn [stack state]
|
||||||
|
(make-instruction state #(* % %) [stack] stack)))
|
||||||
|
|
||||||
(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
|
||||||
@ -541,7 +549,8 @@ Otherwise, acts as a NOOP"
|
|||||||
_gt_buy_sell _gt_buy_hold _gt_sell_buy _gt_sell_hold _gt_hold_buy _gt_hold_sell
|
_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
|
_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
|
_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])
|
_lte_buy_sell _lte_buy_hold _lte_sell_buy _lte_sell_hold _lte_hold_buy _lte_hold_sell
|
||||||
|
_square])
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; FLOAT Instructions only
|
;; FLOAT Instructions only
|
||||||
@ -579,24 +588,17 @@ Otherwise, acts as a NOOP"
|
|||||||
;; Pushes the square root of the top FLOAT. Makes the value
|
;; Pushes the square root of the top FLOAT. Makes the value
|
||||||
;; absolute first.
|
;; absolute first.
|
||||||
(def-instruction
|
(def-instruction
|
||||||
:float_tan
|
:float_sqrt
|
||||||
^{:stacks #{:float}}
|
^{:stacks #{:float}}
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(make-instruction state #(math/sqrt (abs %)) [:float] :float)))
|
(make-instruction state #(math/sqrt (math/abs %)) [:float] :float)))
|
||||||
|
|
||||||
;; Pushes the log of the top FLOAT
|
;; Pushes the natural log of the top FLOAT
|
||||||
(def-instruction
|
(def-instruction
|
||||||
:float_tan
|
:float_log
|
||||||
^{:stacks #{:float}}
|
^{:stacks #{:float}}
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(make-instruction state #(if (zero? %) 1 (math/log (abs %))) [:float] :float)))
|
(make-instruction state #(if (zero? %) 1 (math/log (math/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
|
;; Pushes the floating point version of the top INTEGER
|
||||||
(def-instruction
|
(def-instruction
|
||||||
|
@ -6,3 +6,44 @@
|
|||||||
generate-instructions
|
generate-instructions
|
||||||
make-instruction]]))
|
make-instruction]]))
|
||||||
|
|
||||||
|
;; Changes the top signal from :buy to :sell if applicable
|
||||||
|
(def-instruction
|
||||||
|
:signal_swap_buy_sell
|
||||||
|
^{:stacks #{:signal}}
|
||||||
|
(fn [state]
|
||||||
|
(make-instruction state #(if (= :buy %) :sell :buy) [:signal] :signal)))
|
||||||
|
|
||||||
|
;; Changes the top signal from :buy to :hold if applicable
|
||||||
|
(def-instruction
|
||||||
|
:signal_swap_buy_hold
|
||||||
|
^{:stacks #{:signal}}
|
||||||
|
(fn [state]
|
||||||
|
(make-instruction state #(if (= :buy %) :hold :buy) [:signal] :signal)))
|
||||||
|
|
||||||
|
;; Changes the top signal from :sell to :buy if applicable
|
||||||
|
(def-instruction
|
||||||
|
:signal_swap_sell_buy
|
||||||
|
^{:stacks #{:signal}}
|
||||||
|
(fn [state]
|
||||||
|
(make-instruction state #(if (= :sell %) :buy :sell) [:signal] :signal)))
|
||||||
|
|
||||||
|
;; Changes the top signal from :sell to :hold if applicable
|
||||||
|
(def-instruction
|
||||||
|
:signal_swap_sell_hold
|
||||||
|
^{:stacks #{:signal}}
|
||||||
|
(fn [state]
|
||||||
|
(make-instruction state #(if (= :sell %) :hold :sell) [:signal] :signal)))
|
||||||
|
|
||||||
|
;; Changes the top signal from :hold to :buy if applicable
|
||||||
|
(def-instruction
|
||||||
|
:signal_swap_hold_buy
|
||||||
|
^{:stacks #{:signal}}
|
||||||
|
(fn [state]
|
||||||
|
(make-instruction state #(if (= :hold %) :buy :hold) [:signal] :signal)))
|
||||||
|
|
||||||
|
;; Changes the top signal from :hold to :sell if applicable
|
||||||
|
(def-instruction
|
||||||
|
:signal_swap_hold_sell
|
||||||
|
^{:stacks #{:signal}}
|
||||||
|
(fn [state]
|
||||||
|
(make-instruction state #(if (= :hold %) :sell :hold) [:signal] :signal)))
|
Loading…
x
Reference in New Issue
Block a user