Refactor, and added strategy with risk
This commit is contained in:
@@ -5,3 +5,4 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
pulse-macros = { workspace = true }
|
||||
serde = { version = "1.0.229", features = ["serde_derive"] }
|
||||
|
||||
@@ -2,7 +2,7 @@ use pulse_macros::pwp;
|
||||
|
||||
use crate::{
|
||||
PulseWire,
|
||||
units::{Symbol, USD},
|
||||
units::{Direction, Symbol, USD},
|
||||
};
|
||||
|
||||
#[pwp]
|
||||
@@ -20,9 +20,11 @@ pub enum Volatility {
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub enum Direction {
|
||||
Buy,
|
||||
Sell,
|
||||
pub enum LogKind {
|
||||
Info,
|
||||
Warn,
|
||||
Err,
|
||||
Debug,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
@@ -36,14 +38,6 @@ pub struct Signal {
|
||||
pub stop_loss: USD,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub enum LogKind {
|
||||
Info,
|
||||
Warn,
|
||||
Err,
|
||||
Debug,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub struct EventLog {
|
||||
pub kind: LogKind,
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub mod general;
|
||||
pub mod strategy;
|
||||
pub mod terminal;
|
||||
pub mod units;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::PulseWire;
|
||||
pub use crate::general::*;
|
||||
pub use crate::server_path;
|
||||
pub use crate::strategy::*;
|
||||
pub use crate::terminal::*;
|
||||
pub use crate::units::*;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
use crate::{PulseWire, units::TimeFrame};
|
||||
use pulse_macros::pwp;
|
||||
|
||||
#[pwp]
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
pub struct Strategy {
|
||||
name: String,
|
||||
timeframes: Vec<TimeFrame>,
|
||||
description: String,
|
||||
author: String,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
pub struct Risk {
|
||||
name: String,
|
||||
max_loss: u8,
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
PulseWire,
|
||||
general::{EventLog, MarketTrend, Position, Signal, Volatility},
|
||||
strategy::{Risk, Strategy},
|
||||
units::{Symbol, USD},
|
||||
};
|
||||
use pulse_macros::pwp;
|
||||
@@ -100,6 +101,12 @@ pub enum Feed {
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub struct StrategyView {
|
||||
strategy: Strategy,
|
||||
risk: Risk,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for AlertLevel {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use pulse_macros::pwp;
|
||||
|
||||
use crate::PulseWire;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -6,6 +8,34 @@ pub struct Symbol(pub String);
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct USD(pub f64);
|
||||
|
||||
#[pwp]
|
||||
#[derive(Copy, serde::Deserialize, serde::Serialize)]
|
||||
pub enum TimeFrame {
|
||||
M1,
|
||||
M3,
|
||||
M5,
|
||||
M15,
|
||||
M30,
|
||||
|
||||
H1,
|
||||
H2,
|
||||
H4,
|
||||
H8,
|
||||
H12,
|
||||
|
||||
D1,
|
||||
D3,
|
||||
|
||||
W1,
|
||||
Month1,
|
||||
}
|
||||
|
||||
#[pwp]
|
||||
pub enum Direction {
|
||||
Buy,
|
||||
Sell,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Symbol {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "\x1b[35m{}\x1b[0m", self.0)
|
||||
|
||||
Reference in New Issue
Block a user