forked from jjttjj/trateg
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Jul 4, 2024
1 parent
8c3addc
commit 899e73c
Showing
4 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(ns quanta.notebook.calendar-debug | ||
(:require | ||
[taoensso.timbre :as timbre :refer [info warn error]] | ||
[ta.calendar.core :refer [calendar-seq-instant]])) | ||
|
||
|
||
(->> (calendar-seq-instant [:crypto :d]) | ||
(take 3)) | ||
|
||
(->> (calendar-seq-instant [:crypto :h]) | ||
(take 3)) | ||
|
||
(->> (calendar-seq-instant [:crypto :m15]) | ||
(take 3)) | ||
|
||
(->> (calendar-seq-instant [:crypto :m]) | ||
(take 3)) | ||
|
||
|
||
(defn next-dt [calendar] | ||
(let [[market interval] calendar] | ||
(let [dt (->> (calendar-seq-instant calendar) | ||
first)] | ||
[interval dt]))) | ||
|
||
(defn next-market [market] | ||
(let [intervals [:d :h :m30 :m15 :m] | ||
calendars (map (fn [int] | ||
[market int]) intervals)] | ||
(->> (map next-dt calendars) | ||
(into {})) | ||
;calendars | ||
)) | ||
|
||
(next-dt [:crypto :d]) | ||
(next-dt [:crypto :h]) | ||
(next-dt [:crypto :m]) | ||
(next-dt [:crypto :m30]) | ||
|
||
|
||
(next-market :crypto) | ||
;; => {:d #inst "2024-07-02T23:59:59.000000000-00:00", | ||
;; :h #inst "2024-07-04T02:00:00.000000000-00:00", | ||
;; :m30 #inst "2024-07-04T02:30:00.000000000-00:00", | ||
;; :m15 #inst "2024-07-04T02:45:00.000000000-00:00", | ||
;; :m #inst "2024-07-04T02:51:00.000000000-00:00"} | ||
|
||
;; day should be one day later. |
10 changes: 8 additions & 2 deletions
10
lib/calendar/resources/quanta/notebook/calendar_live_time.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
(ns quanta.notebook.calendar-live-time | ||
(:require | ||
[taoensso.timbre :as timbre :refer [info warn error]] | ||
[ta.calendar.core :refer [calendar-seq-instant]] | ||
[manifold.stream :as s] | ||
[ta.calendar.generator :as ct])) | ||
|
||
(def s (ct/create-live-calendar-time-generator)) | ||
|
||
(ct/add-calendar s [:us :m]) | ||
(ct/add-calendar s [:crypto :m]) | ||
(ct/add-calendar s [:crypto :m15]) | ||
(ct/add-calendar s [:crypto :m30]) | ||
(ct/add-calendar s [:crypto :h]) | ||
(ct/add-calendar s [:forex :m]) | ||
(ct/add-calendar s [:eu :m]) | ||
|
||
(s/consume | ||
(fn [msg] | ||
(info "time event: " msg)) | ||
(warn "time event: " msg)) | ||
(ct/get-time-stream s)) | ||
|
||
(ct/remove-calendar s [:eu :m]) | ||
|
||
(ct/show-calendars s) | ||
(ct/show-calendars s) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters