Skip to content

Commit

Permalink
kibot realtime-snapshot-bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Sep 18, 2023
1 parent 38751e9 commit 9176db5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 116 deletions.
3 changes: 1 addition & 2 deletions app/demo/src/demo/goldly/page/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
[:h1.text-xl.text-red-600 "joseph"]
[link-href "/joseph" "tradingview"]
[link-dispatch [:bidi/goto 'joseph.page.nav/page-joseph-nav] "nav"]
[link-dispatch [:bidi/goto 'joseph.page.live/page-joseph-live] "live"]
[link-dispatch [:bidi/goto 'joseph.page.live2/page-live-trading] "live v2"]]
[link-dispatch [:bidi/goto 'joseph.page.live2/page-live-trading] "live"]]

[:div.bg-blue-300.m-5
[:h1.text-xl.text-red-600 "gann tools"]
Expand Down
3 changes: 1 addition & 2 deletions app/joseph/resources/ext/joseph.edn
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

:cljs-routes {"joseph" {"" joseph.page.tradingview/tradingview-trades-page
"/nav" joseph.page.nav/page-joseph-nav
"/live" joseph.page.live/page-joseph-live
"/live2" joseph.page.live2/page-live-trading}}
"/live" joseph.page.live2/page-live-trading}}

:sci-cljs-ns [; lib
joseph.lib.live-pl
Expand Down
20 changes: 10 additions & 10 deletions app/joseph/src/joseph/lib/quote_table.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
(defn quote-table [quotes]
[aggrid {:box :fl
:data quotes
:columns [{:field :symbol :width 50}
{:field :date :width 50}
{:field :time :width 50}
:columns [{:field :symbol :width 80}
{:field :date :width 100}
{:field :time :width 80}
;{:field :timezone}
{:field :open :width 50}
{:field :high :width 50}
{:field :low :width 50}
{:field :close :width 50}
{:field :volume :width 50}
{:field :changepercent :width 50}
{:field :open :width 70 :type "rightAligned"}
{:field :high :width 70 :type "rightAligned"}
{:field :low :width 70 :type "rightAligned"}
{:field :close :width 70 :type "rightAligned"}
{:field :volume :width 80 :type "rightAligned"}
{:field :changepercent :width 50 :type "rightAligned"}
;{:field :lastprice}
;{:field :lastvolume}
]

:autosize-columns false
:pagination :false
:paginationAutoPageSize false}])
69 changes: 0 additions & 69 deletions app/joseph/src/joseph/page/live.cljs

This file was deleted.

21 changes: 9 additions & 12 deletions app/joseph/src/joseph/realtime.clj
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
(ns joseph.realtime
(:require
[taoensso.timbre :refer [trace debug info warnf error]]
;[ta.helper.date :refer [parse-date]]
;[tick.core :as t]
[tablecloth.api :as tc]
[ ta.warehouse.symbol-db :as db]
[tablecloth.api :as tc]
[ta.warehouse.symbol-db :as db]
[ta.data.api-ds.kibot :as kibot]
[ta.helper.ds :refer [ds->map]]))

(defn realtime-snapshot [symbols]
(let [data (kibot/get-snapshot symbols)
data-ok (if data
(ds->map data)
[{:symbol "DAX0" :close 17000.0}
{:symbol "INTC" :close 40.0}])
]
[])]
(info "realtime snapshot symbols: " (map :symbol data-ok))
data-ok))


(defn get-last-daily [symbol]
(info "get-last-daily: " symbol)
(-> (kibot/get-series symbol "D" 1 {})
(tc/add-column :symbol symbol)
))
(-> (kibot/get-series symbol "D" 3 {})
(tc/add-column :symbol symbol)
(tc/select-rows [-1])))


(defn get-last-daily-snapshot [symbols]
(let [[symbol-first & symbols-rest] symbols
Expand All @@ -49,8 +46,7 @@

(defn realtime-snapshot-stocks [symbols]
(let [stocks (filter stock? symbols)]
(realtime-snapshot stocks)
))
(realtime-snapshot stocks)))

(defn daily-snapshot-futures-raw [symbols]
(let [futures (remove stock? symbols)
Expand Down Expand Up @@ -98,6 +94,7 @@
(daily-snapshot-futures-raw)
(print-range :all))

(kibot/get-series "NG0" "D" 2 {})
(daily-snapshot-futures-raw [])
(daily-snapshot-futures-raw ["NG0"])
(daily-snapshot-futures ["NG0"])
Expand Down
9 changes: 6 additions & 3 deletions lib/data/src/ta/data/api_ds/kibot.clj
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
(= range :full)
{:period 100000}

(= range 1)
{:period 1}
(int? range)
{:period range}

:else
{:startdate (fmt-yyyymmdd start)} ; :startdate "2023-09-01"
Expand Down Expand Up @@ -170,7 +170,10 @@
"D"
{:start (parse-date "2023-09-06")}
{})


(get-series "MSFT" "D" 10 {})
(get-series "NG0" "D" 3 {})

(symbol->provider "EURUSD")
(get-series "EURUSD"
"D"
Expand Down
36 changes: 18 additions & 18 deletions lib/trateg/src/ta/viz/trades_table.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
(defn trades-table [trades]
[aggrid {:box :fl
:data trades
:columns [{:field :symbol}
{:field :side :headerName "side"}
{:field :qty}
{:field :entry-date :format fmt-yyyymmdd :headerName "dt-E"}
{:field :entry-vol :format #(round-number-digits 0 %) :headerName "dt-E"}
{:field :exit-date :format fmt-yyyymmdd :headerName "dt-X"}
{:field :entry-price :headerName "px-E"}
{:field :exit-price :headerName "px-X"}
{:field :pl :format #(round-number-digits 0 %) :type "rightAligned"}]
:columns [{:field :symbol :width 50}
{:field :side :headerName "side" :width 50}
{:field :qty :width 50}
{:field :entry-date :format fmt-yyyymmdd :headerName "dt-E" :width 50}
{:field :entry-vol :format #(round-number-digits 0 %) :headerName "dt-E" :width 50}
{:field :exit-date :format fmt-yyyymmdd :headerName "dt-X" :width 50}
{:field :entry-price :headerName "px-E" :width 50}
{:field :exit-price :headerName "px-X" :width 50}
{:field :pl :format #(round-number-digits 0 %) :type "rightAligned" :width 50}]
:pagination :false
:paginationAutoPageSize true}])

(defn trades-table-live [trades]
[aggrid {:box :fl
:data trades
:columns [{:field :account}
{:field :symbol}
{:field :side :headerName "side"}
{:field :qty}
{:field :entry-date :format fmt-yyyymmdd :headerName "dt-E"}
{:field :entry-price :headerName "px-E"}
{:field :entry-vol :format #(round-number-digits 0 %) :headerName "dt-E"}
:columns [{:field :account :width 80}
{:field :symbol :width 80}
{:field :side :headerName "side" :width 70}
{:field :qty :width 70 :type "rightAligned"}
{:field :entry-date :format fmt-yyyymmdd :headerName "dt-E" :width 100}
{:field :entry-price :headerName "px-E" :width 80 :type "rightAligned" }
{:field :entry-vol :format #(round-number-digits 0 %) :headerName "dt-E" :width 80 :type "rightAligned" }

{:field :current-price :type "rightAligned" }
{:field :current-pl :type "rightAligned"}
{:field :current-price :type "rightAligned" :width 80}
{:field :current-pl :type "rightAligned" :width 80}
]
:pagination :false
:paginationAutoPageSize true}])

0 comments on commit 9176db5

Please sign in to comment.