Skip to content

Instantly share code, notes, and snippets.

@nathanvy
Created July 9, 2023 20:50
Show Gist options
  • Save nathanvy/277392d6776f895d6558266fa90992e3 to your computer and use it in GitHub Desktop.
Save nathanvy/277392d6776f895d6558266fa90992e3 to your computer and use it in GitHub Desktop.
Predicate to determine if market is open today
(defun run-today-p ()
"Should we run zalgo today?"
(local-time:with-decoded-timestamp
(:day-of-week weekday :day today-day) (local-time:now)
(when (or (= weekday 0) (= weekday 6)) (return-from run-today-p nil))
(let ((markets-list (get-markets-list)))
(loop for market in markets-list
do (if (string= (gethash "name" market) "NYSE")
(local-time:with-decoded-timestamp
(:day d) (local-time:parse-timestring (gethash "startTime" market))
(if (= today-day d) (return-from run-today-p t) nil)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment