clojure-quant / quanta

quantitative technical analysis in clojure
13 stars 4 forks source link

calendar iter functions with instants #42

Closed wizard50 closed 1 month ago

wizard50 commented 1 month ago
(defn prior-open-dt
  "prior open (excluding interval boundary)"
  [calendar dt]
  (if (and (day-open? calendar dt) (not (before-trading-hours? calendar dt true)))
    (trading-open-time calendar (t/date dt))
    (prior-open calendar dt)))

for example the iter function above does not work with instants with a timezone != calendar type this is because (t/date dt) will produce a local-date and this date can be in the wrong day when the timezone does not match.

=> make the calendar iteration api working for instants too. no problem for zoned-date-time.

wizard50 commented 1 month ago

same for other functions, like (t/now) etc.

wizard50 commented 1 month ago

quanta.calendar.core iteration functions should be save now.

be careful with quanta.calendar.helper functions!