Skip to content

Commit

Permalink
juan date ui
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Nov 24, 2023
1 parent b6f33f5 commit 5c12bab
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 17 deletions.
9 changes: 7 additions & 2 deletions app/juan/src/juan/app.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
(into {})
(reset! fxcm-dict)))

(defn fxcm-data-for-symbol [s]
(get @fxcm-dict s))


(defn fxcm-last-price [s]
(when-let [data (get @fxcm-dict s)]
(:Bid data)))
Expand Down Expand Up @@ -52,7 +56,7 @@
(defonce realtime-seq (atom []))

(defn calculate-realtime []
(->> (calc-realtime get-core fxcm-last-price)
(->> (calc-realtime get-core fxcm-data-for-symbol)
(reset! realtime-seq)))

(defn get-realtime []
Expand Down Expand Up @@ -80,7 +84,8 @@

(refresh-fxcm-dict)
(fxcm-last-price "AUDJPY")

(fxcm-data-for-symbol "AUDJPY")

(refresh-sentiment-dict)
(get-sentiment "EURNOK")

Expand Down
2 changes: 1 addition & 1 deletion app/juan/src/juan/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
; usd pairs emerging
;{:fx "BRLUSD" :future "BR"} ; no sentiment numbers
{:fx "USDMXN" :future "PX" :pip 0.01}
{:fx "USDRUB" :future "RU" :pip 0.1}
;{:fx "USDRUB" :future "RU" :pip 0.1} ; no fxcm data
{:fx "USDZAR" :future "RA" :pip 0.01}
; eur pairs
{:fx "EURAUD" :future "EAD" :pip 0.001}
Expand Down
21 changes: 12 additions & 9 deletions app/juan/src/juan/realtime.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
nil)))


(defn calc-realtime-symbol [fxcm-last-price {:keys [symbol close atr sentiment-signal pivots] :as core}]
(let [price (fxcm-last-price symbol)
(defn calc-realtime-symbol [fxcm-data-for-symbol {:keys [symbol close atr sentiment-signal pivots] :as core}]
(let [fxcm (fxcm-data-for-symbol symbol)
price (:Bid fxcm)
time (:Time fxcm)
change (when (and price close)
(- price close))
spike-atr-min-prct (:spike-atr-min-prct settings)
Expand Down Expand Up @@ -52,6 +54,7 @@
;(println "pivot max pip distance: " pivot-max-pip-distance)
(assoc core
:price price
:time time
:change change
:change-atr-prct change-atr-prct
:spike-signal spike-signal
Expand All @@ -62,22 +65,22 @@
:pivot-short pivot-short)))


(defn calc-realtime [get-core fxcm-last-price]
(map #(calc-realtime-symbol fxcm-last-price %) (get-core)))
(defn calc-realtime [get-core fxcm-data-for-symbol]
(map #(calc-realtime-symbol fxcm-data-for-symbol %) (get-core)))


(comment

(require '[juan.app :refer [get-core fxcm-last-price]])
(require '[juan.app :refer [get-core fxcm-data-for-symbol]])
(get-core)
(fxcm-last-price "EURNOK")
(fxcm-data-for-symbol "EURNOK")

(calc-realtime get-core fxcm-last-price)
(calc-realtime get-core fxcm-data-for-symbol)

(require '[clojure.pprint :refer [print-table]])

(->> (calc-realtime get-core fxcm-last-price)
(print-table [:symbol :close :change-atr-prct
(->> (calc-realtime get-core fxcm-data-for-symbol)
(print-table [:symbol :close :time :change-atr-prct
:spike-signal :sentiment-signal :setup-signal :pivot-signal]))


Expand Down
3 changes: 2 additions & 1 deletion app/juan/src/juan/scheduler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@

(defn start! [& args] ; make it compatible with clip
(info "Juan Start .. ")
; we dont download series; as this could take a long time. Worst case we use out of day series
; awb99: we dont download series; as this could take a long time. Worst case we use out of day series
; awb99: had to downlaod series, as otherwise calc errors woudl fuck up quant site.
(app/task-day)
(app/task-hour)
(app/task-minute)
Expand Down
30 changes: 26 additions & 4 deletions app/juan/src/juan/ui.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[re-frame.core :as rf]
[goog.string]
[spaces]
[tick.goldly :refer [dt-format]]
[rtable.rtable :refer [rtable]]))

(defonce juan-table (r/atom []))
Expand Down Expand Up @@ -36,6 +37,26 @@
nr
(goog.string/format "%.1f" nr))))

(defn dt-yyyymmdd [dt]
;(println "dt-yyyymmdd: " dt)
(if (nil? dt)
""
(if (string? dt)
dt
(dt-format "YYYY-MM-dd" dt)
;(str dt)
)))

(defn dt-yyyymmdd-hhmm [dt]
;(println "dt-yyyymmdd: " dt)
(if (nil? dt)
""
(if (string? dt)
dt
(dt-format "YYYY-MM-dd HH:mm" dt)
;(str dt)
)))

(defn format-signal [s]
(println "format-signal: " (pr-str s))
(cond
Expand Down Expand Up @@ -71,9 +92,10 @@
:border "3px solid green"}}
[{:path :symbol :header "Symbol" :format format-symbol}
{:path :close :header "PClose"}
{:path :price :header "PCurrent"
;:format icon
}
{:path :close-dt :header "PClose" :format dt-yyyymmdd}

{:path :price :header "PCurrent"}
{:path :time :header "PTime"}
{:path :change :header "chg" :format fmt-digits}
{:path :change-atr-prct :header "chg-atr%" :format fmt-0digits}
{:path :sentiment-long-prct :header "SentLong%"}
Expand Down Expand Up @@ -132,7 +154,7 @@
(->> (filter #(= s (:symbol %)) @juan-table)
first))
pivots (when data
(-> data :pivots pivot-map->table))
(->> data :pivots pivot-map->table (sort-by :price) reverse))
data-no-pivots (when data (dissoc data :pivots))]
[:div
(if s
Expand Down

0 comments on commit 5c12bab

Please sign in to comment.