Pulse wire crate
This commit is contained in:
Generated
+8
-1
@@ -319,8 +319,8 @@ version = "0.1.0-alpha.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossterm",
|
||||
"pulse-macros",
|
||||
"pulse-ui",
|
||||
"pulse-wire",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@@ -332,6 +332,13 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulse-wire"
|
||||
version = "0.1.0-alpha.0"
|
||||
dependencies = [
|
||||
"pulse-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.46"
|
||||
|
||||
+6
-3
@@ -4,18 +4,21 @@ version = "0.1.0-alpha.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.45"
|
||||
pulse-ui = { workspace = true }
|
||||
pulse-macros = { workspace = true }
|
||||
pulse-wire = { workspace = true }
|
||||
|
||||
chrono = "0.4.45"
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
|
||||
crossterm = { workspace = true }
|
||||
|
||||
[workspace]
|
||||
members = ["pulse-macros", "pulse-ui"]
|
||||
members = ["pulse-macros", "pulse-ui", "pulse-wire"]
|
||||
|
||||
[workspace.dependencies]
|
||||
pulse-macros = { path = "pulse-macros", version = "0.1.0-alpha.0" }
|
||||
pulse-ui = { path = "pulse-ui", version = "0.1.0-alpha.0" }
|
||||
pulse-wire = { path = "pulse-wire", version = "0.1.0-alpha.0" }
|
||||
|
||||
tokio = "1.52.3"
|
||||
crossterm = "0.29.0"
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "pulse-wire"
|
||||
version = "0.1.0-alpha.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
pulse-macros = { workspace = true }
|
||||
@@ -1,3 +1,5 @@
|
||||
pub mod terminal;
|
||||
|
||||
pub trait PulseCom {
|
||||
fn to_com(&self) -> Vec<u8>;
|
||||
fn from_com(_com: &mut Vec<u8>) -> Self;
|
||||
@@ -81,25 +83,3 @@ int_com!(usize);
|
||||
|
||||
int_com!(f64);
|
||||
int_com!(f32);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! p_com {
|
||||
(struct $name:ident { $($n:ident: $v:ty),* $(,)? }) => {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct $name { $(pub $n: $v),* }
|
||||
|
||||
impl PulseCom for $name {
|
||||
fn to_com(&self) -> Vec<u8> {
|
||||
let mut vec = Vec::new();
|
||||
$(vec.extend(self.$n.to_com());)*
|
||||
vec
|
||||
}
|
||||
|
||||
fn from_com(com: &mut Vec<u8>) -> Self {
|
||||
Self {
|
||||
$($n: <$v>::from_com(com),)*
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::PulseCom;
|
||||
use pulse_macros::p_com;
|
||||
|
||||
#[p_com]
|
||||
+4
-6
@@ -1,12 +1,10 @@
|
||||
pub mod ptc;
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
use ptc::PulseCom;
|
||||
use pulse_wire::PulseCom;
|
||||
|
||||
fn main() {
|
||||
let input = ptc::EventLog {
|
||||
kind: ptc::LogKind::Warn,
|
||||
let input = pulse_wire::terminal::EventLog {
|
||||
kind: pulse_wire::terminal::LogKind::Warn,
|
||||
name: "Test".to_string(),
|
||||
message: "Hello, WOrld".to_string(),
|
||||
};
|
||||
@@ -14,7 +12,7 @@ fn main() {
|
||||
let start = Instant::now();
|
||||
|
||||
let mut val = input.to_com();
|
||||
let out = ptc::EventLog::from_com(&mut val);
|
||||
let out = pulse_wire::terminal::EventLog::from_com(&mut val);
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
include!("../pc.rs");
|
||||
include!("../ptc.rs");
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{PulseTradeApp, ptc::EventLog};
|
||||
use crate::PulseTradeApp;
|
||||
|
||||
impl PulseTradeApp {
|
||||
pub async fn execute_command(&mut self, ctx: &pulse_ui::state::Context, command: &str) {
|
||||
@@ -18,8 +18,8 @@ impl PulseTradeApp {
|
||||
}
|
||||
|
||||
_ => {
|
||||
self.logs.lock().await.push(EventLog {
|
||||
kind: crate::ptc::LogKind::Err,
|
||||
self.logs.lock().await.push(pulse_wire::terminal::EventLog {
|
||||
kind: pulse_wire::terminal::LogKind::Err,
|
||||
name: "cmd".to_string(),
|
||||
message: format!("Command '{}' not found", command),
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::ptc::{
|
||||
use pulse_wire::terminal::{
|
||||
ActivePosition, Alert, AlertLevel, EventLog, InspectTarget, LogKind, MarketOverview, Signal,
|
||||
SignalKind, Status, WatchListItem,
|
||||
};
|
||||
|
||||
+17
-20
@@ -1,6 +1,5 @@
|
||||
pub mod command;
|
||||
pub mod formatting;
|
||||
pub mod ptc;
|
||||
|
||||
use std::any::Any;
|
||||
|
||||
@@ -18,12 +17,10 @@ use pulse_ui::{
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
formatting::{Formatted, apply_padding},
|
||||
ptc::{
|
||||
ActivePosition, Alert, EventLog, InspectTarget, MarketOverview, Signal, Status,
|
||||
WatchListItem,
|
||||
},
|
||||
use crate::formatting::{Formatted, apply_padding};
|
||||
|
||||
use pulse_wire::terminal::{
|
||||
ActivePosition, Alert, EventLog, InspectTarget, MarketOverview, Signal, Status, WatchListItem,
|
||||
};
|
||||
|
||||
pub struct PulseTradeApp {
|
||||
@@ -88,30 +85,30 @@ impl App for PulseTradeApp {
|
||||
let mut signals = self.signals.lock().await;
|
||||
|
||||
signals.push(Signal {
|
||||
kind: ptc::SignalKind::Buy,
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: ptc::SignalParameter::Lim,
|
||||
param: pulse_wire::terminal::SignalParameter::Lim,
|
||||
price: 118_800.0,
|
||||
});
|
||||
|
||||
signals.push(Signal {
|
||||
kind: ptc::SignalKind::Buy,
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: ptc::SignalParameter::Tap,
|
||||
param: pulse_wire::terminal::SignalParameter::Tap,
|
||||
price: 120_000.0,
|
||||
});
|
||||
|
||||
signals.push(Signal {
|
||||
kind: ptc::SignalKind::Buy,
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: ptc::SignalParameter::Stl,
|
||||
param: pulse_wire::terminal::SignalParameter::Stl,
|
||||
price: 118_000.0,
|
||||
});
|
||||
|
||||
let mut logs = self.logs.lock().await;
|
||||
|
||||
logs.push(EventLog {
|
||||
kind: ptc::LogKind::Warn,
|
||||
kind: pulse_wire::terminal::LogKind::Warn,
|
||||
name: "pulse.init".to_string(),
|
||||
message: "We're still not done yet ;)".to_string(),
|
||||
});
|
||||
@@ -119,17 +116,17 @@ impl App for PulseTradeApp {
|
||||
let mut market_overview = self.market_overview.lock().await;
|
||||
|
||||
market_overview.alerts.push(Alert {
|
||||
level: ptc::AlertLevel::High,
|
||||
level: pulse_wire::terminal::AlertLevel::High,
|
||||
message: "BTC funding rate elevated".to_string(),
|
||||
});
|
||||
|
||||
market_overview.alerts.push(Alert {
|
||||
level: ptc::AlertLevel::Medium,
|
||||
level: pulse_wire::terminal::AlertLevel::Medium,
|
||||
message: "Market volatility increasing".to_string(),
|
||||
});
|
||||
|
||||
market_overview.alerts.push(Alert {
|
||||
level: ptc::AlertLevel::Low,
|
||||
level: pulse_wire::terminal::AlertLevel::Low,
|
||||
message: "ETH volatility returning to normal".to_string(),
|
||||
});
|
||||
}
|
||||
@@ -282,13 +279,13 @@ async fn main() {
|
||||
logs: ctx.use_state(Vec::new()),
|
||||
inspect: ctx.use_state(InspectTarget::None),
|
||||
market_overview: ctx.use_state(MarketOverview {
|
||||
trend: ptc::MarketTrend::Bullish,
|
||||
volatility: ptc::Volatility::High,
|
||||
trend: pulse_wire::terminal::MarketTrend::Bullish,
|
||||
volatility: pulse_wire::terminal::Volatility::High,
|
||||
pressure: 0.324,
|
||||
alerts: Vec::new(),
|
||||
}),
|
||||
status: ctx.use_state(Status {
|
||||
feed: ptc::Feed::Connected,
|
||||
feed: pulse_wire::terminal::Feed::Connected,
|
||||
exchange: "Binance".to_string(),
|
||||
dex: "DEX SCREENER".to_string(),
|
||||
latency: 18,
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
include!("../pc.rs");
|
||||
include!("../ptc.rs");
|
||||
Reference in New Issue
Block a user