diff --git a/bar/eww/eww.scss b/bar/eww/eww.scss index cb7e88c..c1492c5 100644 --- a/bar/eww/eww.scss +++ b/bar/eww/eww.scss @@ -1,34 +1,9 @@ @import "./theme.scss"; @import "./bar/style.scss"; @import "./timer/style.scss"; +@import "./freqtrade/style.scss"; * { all: unset; font-family: "FiraCode Nerd Font"; } - -.trades-box { - margin: 12px; - padding: 8px; - background-color: #121212; - border-radius: 8px; -} - -.profit { - background-color: #121212; - border: solid 4px; - border-color: #12bb7b; - border-radius: 5px; - - padding: 3px; - margin-left: 8px; - - &.loss { - border-color: red; - } - - .arrow { - margin-left: 6px; - font-size: 18px; - } -} diff --git a/bar/eww/eww.yuck b/bar/eww/eww.yuck index bd56765..78cf2ae 100644 --- a/bar/eww/eww.yuck +++ b/bar/eww/eww.yuck @@ -1,62 +1,5 @@ (include "./bar/widget.yuck") (include "./timer/widget.yuck") +(include "./freqtrade/widget.yuck") -(defpoll bots - :initial `[]` - :interval "3s" - `curl http://localhost:42667/list` -) -(defpoll absolute_profit - :interval "1s" - :initial 0 - `echo $((RANDOM % 11))` -) - -(defwidget profit-box [percent price] - (box :class {price >= 0 ? "profit" : "profit loss"} :space-evenly false - (label :text {price >= 0 ? "▲" : "▼"} :class "arrow" :halign "start") - (label :text "${round(percent, 2)}% (${round(price, 2)})" :class "price" :justify "center" :hexpand true) - ) -) - -(defwidget trades-box [] - (box :orientation "v" :class "trades-box" - (box :orientation "h" :style "margin: 2px; font-weight: bold" - (label :text "Freqtrade" :style "font-family: Arial; font-size: 24px") - (label :text "Open profit") - (label :text "Closed profit") - ) - (for bot in bots - (box :orientation "h" :style "margin: 2px" - (label :text "${bot.name}" :halign "start" :style "font-weight: bold; margin-right: 8px") - (profit-box :percent {bot.open_profit_pct} :price {bot.open_profit}) - (profit-box :percent {bot.closed_profit_pct} :price {bot.closed_profit}) - ) - ) - ) -) - -(defwidget profits-graph [] - (box :class "trades-box" - (graph - :value {arraylength(bots) > 1 ? -bots[2].open_profit_pct * 2.0 : 0} - :time-range "40m" - :thickness 2 - :line-style "round" - :dynamic true - ) - ) -) - -(defwindow freqtrade - :monitor 0 - :stacking "bg" - :geometry (geometry :x "0%" - :anchor "top right" - ) - (box :orientation "v" - (trades-box) - (profits-graph) - ) -) diff --git a/bar/eww/freqtrade/style.scss b/bar/eww/freqtrade/style.scss new file mode 100644 index 0000000..22cb3e7 --- /dev/null +++ b/bar/eww/freqtrade/style.scss @@ -0,0 +1,25 @@ +.trades-box { + margin: 12px; + padding: 8px; + background-color: #121212; + border-radius: 8px; +} + +.profit { + background-color: #121212; + border: solid 4px; + border-color: #12bb7b; + border-radius: 5px; + + padding: 3px; + margin-left: 8px; + + &.loss { + border-color: red; + } + + .arrow { + margin-left: 6px; + font-size: 18px; + } +} diff --git a/bar/eww/freqtrade/widget.yuck b/bar/eww/freqtrade/widget.yuck new file mode 100644 index 0000000..26a3724 --- /dev/null +++ b/bar/eww/freqtrade/widget.yuck @@ -0,0 +1,59 @@ +(defpoll bots + :initial `[]` + :interval "3s" + `curl http://localhost:42667/list` +) + +(defpoll absolute_profit + :interval "1s" + :initial 0 + `echo $((RANDOM % 11))` +) + +(defwidget profit-box [percent price] + (box :class {price >= 0 ? "profit" : "profit loss"} :space-evenly false + (label :text {price >= 0 ? "▲" : "▼"} :class "arrow" :halign "start") + (label :text "${round(percent, 2)}% (${round(price, 2)})" :class "price" :justify "center" :hexpand true) + ) +) + +(defwidget trades-box [] + (box :orientation "v" :class "trades-box" + (box :orientation "h" :style "margin: 2px; font-weight: bold" + (label :text "Freqtrade" :style "font-family: Arial; font-size: 24px") + (label :text "Open profit") + (label :text "Closed profit") + ) + (for bot in bots + (box :orientation "h" :style "margin: 2px" + (label :text "${bot.name}" :halign "start" :style "font-weight: bold; margin-right: 8px") + (profit-box :percent {bot.open_profit_pct} :price {bot.open_profit}) + (profit-box :percent {bot.closed_profit_pct} :price {bot.closed_profit}) + ) + ) + ) +) + +(defwidget profits-graph [] + (box :class "trades-box" + (graph + :value {arraylength(bots) > 1 ? -bots[2].open_profit_pct * 2.0 : 0} + :time-range "40m" + :thickness 2 + :line-style "round" + :dynamic true + ) + ) +) + +(defwindow freqtrade + :monitor 0 + :stacking "bg" + :geometry (geometry :x "0%" + :anchor "top right" + ) + (box :orientation "v" + (trades-box) + (profits-graph) + ) +)