diff --git a/app/juan/src/juan/app.clj b/app/juan/src/juan/app.clj index 567ba0fc..2f9a070a 100644 --- a/app/juan/src/juan/app.clj +++ b/app/juan/src/juan/app.clj @@ -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))) @@ -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 [] @@ -80,7 +84,8 @@ (refresh-fxcm-dict) (fxcm-last-price "AUDJPY") - + (fxcm-data-for-symbol "AUDJPY") + (refresh-sentiment-dict) (get-sentiment "EURNOK") diff --git a/app/juan/src/juan/data.clj b/app/juan/src/juan/data.clj index 8036a178..3ee95dd4 100644 --- a/app/juan/src/juan/data.clj +++ b/app/juan/src/juan/data.clj @@ -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} diff --git a/app/juan/src/juan/realtime.clj b/app/juan/src/juan/realtime.clj index 7d9d9a71..775c001a 100644 --- a/app/juan/src/juan/realtime.clj +++ b/app/juan/src/juan/realtime.clj @@ -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) @@ -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 @@ -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])) diff --git a/app/juan/src/juan/scheduler.clj b/app/juan/src/juan/scheduler.clj index c3c674ac..c999e97d 100644 --- a/app/juan/src/juan/scheduler.clj +++ b/app/juan/src/juan/scheduler.clj @@ -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) diff --git a/app/juan/src/juan/ui.cljs b/app/juan/src/juan/ui.cljs index 27cfaaf6..0502c182 100644 --- a/app/juan/src/juan/ui.cljs +++ b/app/juan/src/juan/ui.cljs @@ -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 [])) @@ -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 @@ -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%"} @@ -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