forked from jjttjj/trateg
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Sep 10, 2023
1 parent
29594c0
commit d6201f4
Showing
2 changed files
with
45 additions
and
10 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
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,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}]) |