Skip to content

Instantly share code, notes, and snippets.

@brulint
brulint / rolling-map.lisp
Last active June 4, 2020 13:33
function to calculate moving average, bollinger bands and so on
(defun rolling-map (n func list &optional (sequence '()) (return '()))
(cond ((eq list '()) return)
(t (setq sequence (append sequence (list (car list))))
(if (> (length sequence) n) (setq sequence (cdr sequence)))
(setq return (append return (list (apply func sequence))))
(rolling-map n func (cdr list) sequence return))))
(defun average (&rest list) (/ (apply '+ list) (length list)))
(rolling-map 3 'list '(1 1 2 3 5 8 13 21 34))
@brulint
brulint / kraken.lisp
Last active January 6, 2021 19:30
Access Kraken API with Common Lisp
(ql:quickload :cl-kraken)
(setq cl-kraken/src/globals::*api-key* "my api key")
(setq cl-kraken/src/globals::*api-secret* "my api secret")
; public market data
(cl-kraken::request "Time")
(cl-kraken::request "Ticker" :params '(("pair" . "XXBTZEUR")))
; private user data
(cl-kraken::request "Balance" :post t)
(cl-kraken::request "TradeBalance" :params '(("asset" . "ZEUR")) :post t)