Examples
First automation
Buy one share of AAPL, no logic. This is the simplest automation you can build. Every time you run this it will generate one order => buy one share of AAPL
(def symbol "AAPL")
(buy {symbol} 1)
;;=> {symbol: "AAPL", units: 1, side: "long", ...}Some logic
This automation has some logic. Calculates Simple Moving Average for the last 21 days and buys one share only if the asset current price is over SMA21 if not closes all positions
(def asset "MSFT") ;; define asset
(def sma21 (sma 21 asset)) ;; calculates SMA21
(def closePrice (:close {asset})) ;; gets asset close price
(if (> closePrice sma21)
(buy {asset} 1) ;; yes => Buy one share
(closePositions openPositions) ;; no => Close all open positions
)Multiple assets
This automation sorts a list of assets by CMR (cumulative total return) and picks top 2 to invest.
Last updated
Was this helpful?