diff --git a/lib/joseph/src/joseph/page/nav.cljs b/lib/joseph/src/joseph/page/nav.cljs index a18ec4d2..ee5eb5fb 100644 --- a/lib/joseph/src/joseph/page/nav.cljs +++ b/lib/joseph/src/joseph/page/nav.cljs @@ -2,16 +2,14 @@ (:require [tick.core :as t] [goldly.page :as page] - [demo.goldly.lib.loader :refer [clj->p]] - [ta.viz.nav-table :refer [nav-table]] + [container :refer [tab]] [ta.viz.nav-vega :refer [nav-vega]] - )) -(defn d [s] - (-> (str s "T00:00") - (t/date-time) - (t/inst))) + [ta.viz.nav-table :refer [nav-table]] + [ta.viz.trades-table :refer [trades-table]] + [demo.goldly.lib.loader :refer [clj->p]])) (defn hack-date [row] + ; inst converts a tick data to a javascript/date (update row :date t/inst)) (defn vega-data-hacks [nav] @@ -26,9 +24,16 @@ :loading [:p "loading"] :error [:p "error!"] :data [:div.w-screen.h-screen.flex.flex-cols - [:div.w.full.h-full.overflow-scroll - [nav-vega (vega-data-hacks (:nav(:data @nav)))]] - [nav-table (:nav (:data @nav))]] + ;vega nav chart + [:div.w-full.h-full.overflow-scroll + [nav-vega (vega-data-hacks (:nav (:data @nav)))]] + ;aggrid table (nav or trades) + [:div.w-full.h-full.overflow-scroll + [tab {:box :fl} + "nav" + [nav-table (:nav (:data @nav))] + "trades" + [trades-table (:trades (:data @nav))]]]] [:p "unknown: status:" (pr-str @nav)])))) diff --git a/lib/trateg/src/ta/viz/trades_table.cljs b/lib/trateg/src/ta/viz/trades_table.cljs new file mode 100644 index 00000000..495cb83b --- /dev/null +++ b/lib/trateg/src/ta/viz/trades_table.cljs @@ -0,0 +1,30 @@ +(ns ta.viz.trades-table + (:require + [goldly.js :refer [to-fixed]] + [tick.goldly] + [tick.core :as tick] + [ui.aggrid :refer [aggrid]])) + +(defn fmt-yyyymmdd [dt] + (if dt + (tick/format (tick/formatter "YYYY-MM-dd") dt) + "")) + +(defn round-number-digits + [digits number] ; digits is first parameter, so it can easily be applied (data last) + (if (nil? number) "" (to-fixed number digits))) + + +(defn trades-table [trades] + [aggrid {:data trades + :columns [{:field :symbol} + {:field :direction} + {:field :qty} + {:field :entry-date :format fmt-yyyymmdd} + {:field :exit-date :format fmt-yyyymmdd} + {:field :entry-price} + {:field :exit-price} + {:field :pl :format #(round-number-digits 0 %)}] + :box :fl + :pagination :false + :paginationAutoPageSize true}]) \ No newline at end of file