Refactored types
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
use pulse_macros::pwp;
|
||||
|
||||
use crate::PulseWire;
|
||||
|
||||
#[pwp]
|
||||
pub enum MarketTrend {
|
||||
Bullish,
|
||||
Bearish,
|
||||
Neutral,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub enum Volatility {
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub enum Direction {
|
||||
Buy,
|
||||
Sell,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub struct Signal {
|
||||
pub symbol: String,
|
||||
pub kind: Direction,
|
||||
pub confidence: f32,
|
||||
pub size: f64,
|
||||
pub price: f64,
|
||||
pub take_profit: f64,
|
||||
pub take_stop_loss: f64,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub enum LogKind {
|
||||
Info,
|
||||
Warn,
|
||||
Err,
|
||||
Debug,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub struct EventLog {
|
||||
pub kind: LogKind,
|
||||
pub name: String,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub struct Position {
|
||||
pub symbol: String,
|
||||
pub size: f64,
|
||||
pub entry_price: f64,
|
||||
pub profit: f64,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Direction {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Buy => write!(f, "BUY"),
|
||||
Self::Sell => write!(f, "SELL"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl std::fmt::Display for MarketTrend {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Bullish => write!(f, "Bullish"),
|
||||
Self::Bearish => write!(f, "Bearish"),
|
||||
Self::Neutral => write!(f, "Neutral"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Volatility {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Low => write!(f, "Low"),
|
||||
Self::Medium => write!(f, "Medium"),
|
||||
Self::High => write!(f, "High"),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for LogKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Info => write!(f, "INFO"),
|
||||
Self::Warn => write!(f, "WARN"),
|
||||
Self::Err => write!(f, "ERR"),
|
||||
Self::Debug => write!(f, "DEBUG"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user