Updated layout
This commit is contained in:
+4
-11
@@ -1,5 +1,5 @@
|
|||||||
use crate::types::{
|
use crate::types::{
|
||||||
Account, ActivePosition, EventLog, LogKind, Signal, SignalKind, System, WatchListItem,
|
ActivePosition, EventLog, LogKind, MarketOverview, Signal, SignalKind, Status, WatchListItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Formatted {
|
pub trait Formatted {
|
||||||
@@ -78,20 +78,13 @@ impl Formatted for ActivePosition {
|
|||||||
|
|
||||||
pub struct Property(&'static str, String);
|
pub struct Property(&'static str, String);
|
||||||
|
|
||||||
impl Formatted for Account {
|
impl Formatted for MarketOverview {
|
||||||
fn get_formatted(&self) -> Vec<String> {
|
fn get_formatted(&self) -> Vec<String> {
|
||||||
vec![
|
vec![Property("Equity", format_f64(1.0))].get_formatted()
|
||||||
Property("Equity", format_f64(self.equity)),
|
|
||||||
Property("Liquid", format_f64(self.liquid)),
|
|
||||||
Property("Unreal", format_f64(self.unreal)),
|
|
||||||
Property("Realized", format_f64(self.realized)),
|
|
||||||
Property("Margin", format_f64(self.margin)),
|
|
||||||
]
|
|
||||||
.get_formatted()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Formatted for System {
|
impl Formatted for Status {
|
||||||
fn get_formatted(&self) -> Vec<String> {
|
fn get_formatted(&self) -> Vec<String> {
|
||||||
vec![
|
vec![
|
||||||
Property("Feed", format!("{:?}", self.feed)),
|
Property("Feed", format!("{:?}", self.feed)),
|
||||||
|
|||||||
+22
-21
@@ -5,14 +5,21 @@ use std::any::Any;
|
|||||||
|
|
||||||
use chrono::{Local, Utc};
|
use chrono::{Local, Utc};
|
||||||
use pulse_ui::{
|
use pulse_ui::{
|
||||||
App, layout::{LayoutItem, layout}, state::{Refresh, State}, unit::Size, widget::{
|
App,
|
||||||
align::{Center, End}, input::{Input, InputState}, outline::{Outline, VLine}, spaced::SpacedColumns,
|
layout::{LayoutItem, layout},
|
||||||
|
state::{Refresh, State},
|
||||||
|
unit::Size,
|
||||||
|
widget::{
|
||||||
|
align::End,
|
||||||
|
input::{Input, InputState},
|
||||||
|
outline::{Outline, VLine},
|
||||||
|
spaced::SpacedColumns,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
formatting::{Formatted, apply_padding},
|
formatting::{Formatted, apply_padding},
|
||||||
types::{Account, ActivePosition, EventLog, Signal, System, WatchListItem},
|
types::{ActivePosition, EventLog, MarketOverview, Signal, Status, WatchListItem},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PulseTradeApp {
|
pub struct PulseTradeApp {
|
||||||
@@ -21,8 +28,8 @@ pub struct PulseTradeApp {
|
|||||||
active_positions: State<Vec<ActivePosition>>,
|
active_positions: State<Vec<ActivePosition>>,
|
||||||
logs: State<Vec<EventLog>>,
|
logs: State<Vec<EventLog>>,
|
||||||
signals: State<Vec<Signal>>,
|
signals: State<Vec<Signal>>,
|
||||||
account: State<Account>,
|
market_overview: State<MarketOverview>,
|
||||||
system: State<System>,
|
status: State<Status>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App for PulseTradeApp {
|
impl App for PulseTradeApp {
|
||||||
@@ -188,8 +195,8 @@ impl App for PulseTradeApp {
|
|||||||
(
|
(
|
||||||
LayoutItem::Widget(Size::Flex(1)),
|
LayoutItem::Widget(Size::Flex(1)),
|
||||||
Box::new(format![
|
Box::new(format![
|
||||||
" ACCOUNT\n{}",
|
" MARKET OVERVIEW\n{}",
|
||||||
apply_padding(self.account.lock().await.get_formatted()).join("\n")
|
apply_padding(self.market_overview.lock().await.get_formatted()).join("\n")
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
@@ -198,10 +205,6 @@ impl App for PulseTradeApp {
|
|||||||
layout.draw(
|
layout.draw(
|
||||||
4,
|
4,
|
||||||
SpacedColumns(vec![
|
SpacedColumns(vec![
|
||||||
(
|
|
||||||
LayoutItem::Widget(Size::Flex(1)),
|
|
||||||
Box::new(vec![" ACTIVE STRATEGIES"].join("\n")),
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
LayoutItem::Widget(Size::Flex(1)),
|
LayoutItem::Widget(Size::Flex(1)),
|
||||||
Box::new(format!(
|
Box::new(format!(
|
||||||
@@ -209,11 +212,15 @@ impl App for PulseTradeApp {
|
|||||||
apply_padding(self.signals.lock().await.get_formatted()).join("\n")
|
apply_padding(self.signals.lock().await.get_formatted()).join("\n")
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
LayoutItem::Widget(Size::Flex(1)),
|
||||||
|
Box::new(vec![" INSPECTOR"].join("\n")),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
LayoutItem::Widget(Size::Flex(1)),
|
LayoutItem::Widget(Size::Flex(1)),
|
||||||
Box::new(format![
|
Box::new(format![
|
||||||
" SYSTEM\n{}",
|
" STATUS\n{}",
|
||||||
apply_padding(self.system.lock().await.get_formatted()).join("\n")
|
apply_padding(self.status.lock().await.get_formatted()).join("\n")
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
@@ -239,14 +246,8 @@ async fn main() {
|
|||||||
active_positions: ctx.use_state(Vec::new()),
|
active_positions: ctx.use_state(Vec::new()),
|
||||||
signals: ctx.use_state(Vec::new()),
|
signals: ctx.use_state(Vec::new()),
|
||||||
logs: ctx.use_state(Vec::new()),
|
logs: ctx.use_state(Vec::new()),
|
||||||
account: ctx.use_state(Account {
|
market_overview: ctx.use_state(MarketOverview {}),
|
||||||
equity: 25_483.21,
|
status: ctx.use_state(Status {
|
||||||
liquid: 11_928.43,
|
|
||||||
unreal: 483.12,
|
|
||||||
realized: 2_182.49,
|
|
||||||
margin: 0.0,
|
|
||||||
}),
|
|
||||||
system: ctx.use_state(System {
|
|
||||||
feed: types::Feed::Connected,
|
feed: types::Feed::Connected,
|
||||||
exchange: "Binance".to_string(),
|
exchange: "Binance".to_string(),
|
||||||
dex: "DEX SCREENER".to_string(),
|
dex: "DEX SCREENER".to_string(),
|
||||||
|
|||||||
+2
-8
@@ -10,13 +10,7 @@ pub struct ActivePosition {
|
|||||||
pub amount: f64,
|
pub amount: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Account {
|
pub struct MarketOverview {}
|
||||||
pub equity: f64,
|
|
||||||
pub liquid: f64,
|
|
||||||
pub unreal: f64,
|
|
||||||
pub realized: f64,
|
|
||||||
pub margin: f64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Feed {
|
pub enum Feed {
|
||||||
@@ -26,7 +20,7 @@ pub enum Feed {
|
|||||||
Failed,
|
Failed,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct System {
|
pub struct Status {
|
||||||
pub feed: Feed,
|
pub feed: Feed,
|
||||||
pub exchange: String,
|
pub exchange: String,
|
||||||
pub dex: String,
|
pub dex: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user