Skip to content

Instantly share code, notes, and snippets.

@sjl sjl/test.lisp
Last active Oct 27, 2017

What would you like to do?
(defun instrument-candles (&key
((:instrument instrument))
((:price price) "M")
((:granularity granularity) "S5")
((:count count) 500)
((:from from)
(local-time:timestamp- (local-time::now) 5 :minute))))
((:to to)
(local-time:timestamp-to-unix (local-time::now))))
((:smooth smooth) nil)
((:include-first include-first) T)
((:daily-alignment daily-alignment) 17)
((:alignment-timezone alignment-timezone) "America/New_York")
((:weekly-alignment weekly-alignment) "Friday"))
(if (null instrument)
(format t "You need to specify an instrument!")
(let* ((endpoint (quri:render-uri
(quri:make-uri :defaults (concatenate 'string
:query `(("price" . ,price)
("granularity" . ,granularity)
,@(if (not (null count))
`(("count" . ,count))
`(("from" . ,from) ("to" . ,to)))
("smooth" . ,smooth)
("includeFirst" . ,(if include-first
("dailyAlignment" . ,daily-alignment)
("alignmentTimezone" . ,alignment-timezone)
("weeklyAlignment" . ,weekly-alignment)))))
(authorization (concatenate 'string "Bearer " key))
(result-json nil)
(result-parsed nil)
(account nil))
(setf result-json (dex:get endpoint
:headers `(("Content-Type" . "application/json")
("X-Accept-Datetime-Format" . "UNIX")
("Authorization" . ,authorization))
:verbose t))
(setf result-parsed (jonathan:parse result-json :as :hash-table)))
(dexador.error:http-request-forbidden (err)
(format t "error!: ~a~%" err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.