Improve timeframe and other stuff
This commit is contained in:
+2
-1
@@ -21,7 +21,7 @@ hypersdk = "0.2.14"
|
|||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
rand = "0.8.7"
|
rand = "0.8.7"
|
||||||
toml = "1.1.3"
|
toml = "1.1.3"
|
||||||
serde = { version = "1.0.229", features = ["serde_derive"] }
|
serde = { workspace = true }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["pulse-macros", "pulse-ui", "pulse-wire"]
|
members = ["pulse-macros", "pulse-ui", "pulse-wire"]
|
||||||
@@ -33,6 +33,7 @@ pulse-wire = { path = "pulse-wire", version = "0.1.0-alpha.0" }
|
|||||||
|
|
||||||
tokio = "1.52.3"
|
tokio = "1.52.3"
|
||||||
crossterm = "0.29.0"
|
crossterm = "0.29.0"
|
||||||
|
serde = { version = "1.0.229", features = ["serde_derive"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "pulse-trader"
|
name = "pulse-trader"
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pulse-macros = { workspace = true }
|
pulse-macros = { workspace = true }
|
||||||
serde = { version = "1.0.229", features = ["serde_derive"] }
|
serde = { workspace = true }
|
||||||
|
|||||||
@@ -12,13 +12,6 @@ pub enum MarketTrend {
|
|||||||
Neutral,
|
Neutral,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pwp]
|
|
||||||
pub enum Volatility {
|
|
||||||
Low,
|
|
||||||
Medium,
|
|
||||||
High,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[pwp]
|
#[pwp]
|
||||||
pub enum LogKind {
|
pub enum LogKind {
|
||||||
Info,
|
Info,
|
||||||
@@ -53,15 +46,6 @@ pub struct Position {
|
|||||||
pub profit: USD,
|
pub profit: USD,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
impl std::fmt::Display for MarketTrend {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
@@ -72,15 +56,6 @@ impl std::fmt::Display for MarketTrend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
impl std::fmt::Display for LogKind {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
PulseWire,
|
PulseWire,
|
||||||
general::{EventLog, MarketTrend, Position, Signal, Volatility},
|
general::{EventLog, MarketTrend, Position, Signal},
|
||||||
strategy::{Risk, Strategy},
|
strategy::{Risk, Strategy},
|
||||||
units::{Symbol, USD},
|
units::{Symbol, USD, Volatility},
|
||||||
};
|
};
|
||||||
use pulse_macros::pwp;
|
use pulse_macros::pwp;
|
||||||
|
|
||||||
|
|||||||
@@ -11,22 +11,36 @@ pub struct USD(pub f64);
|
|||||||
#[pwp]
|
#[pwp]
|
||||||
#[derive(Copy, serde::Deserialize, serde::Serialize)]
|
#[derive(Copy, serde::Deserialize, serde::Serialize)]
|
||||||
pub enum TimeFrame {
|
pub enum TimeFrame {
|
||||||
|
#[serde(rename = "1m")]
|
||||||
M1,
|
M1,
|
||||||
|
#[serde(rename = "3m")]
|
||||||
M3,
|
M3,
|
||||||
|
#[serde(rename = "5m")]
|
||||||
M5,
|
M5,
|
||||||
|
#[serde(rename = "15m")]
|
||||||
M15,
|
M15,
|
||||||
|
#[serde(rename = "30m")]
|
||||||
M30,
|
M30,
|
||||||
|
|
||||||
|
#[serde(rename = "1h")]
|
||||||
H1,
|
H1,
|
||||||
|
#[serde(rename = "2h")]
|
||||||
H2,
|
H2,
|
||||||
|
#[serde(rename = "4h")]
|
||||||
H4,
|
H4,
|
||||||
|
#[serde(rename = "8h")]
|
||||||
H8,
|
H8,
|
||||||
|
#[serde(rename = "12h")]
|
||||||
H12,
|
H12,
|
||||||
|
|
||||||
|
#[serde(rename = "1d")]
|
||||||
D1,
|
D1,
|
||||||
|
#[serde(rename = "3d")]
|
||||||
D3,
|
D3,
|
||||||
|
|
||||||
|
#[serde(rename = "1w")]
|
||||||
W1,
|
W1,
|
||||||
|
#[serde(rename = "1M")]
|
||||||
Month1,
|
Month1,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +50,13 @@ pub enum Direction {
|
|||||||
Sell,
|
Sell,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[pwp]
|
||||||
|
pub enum Volatility {
|
||||||
|
Low,
|
||||||
|
Medium,
|
||||||
|
High,
|
||||||
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Symbol {
|
impl std::fmt::Display for Symbol {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "\x1b[35m{}\x1b[0m", self.0)
|
write!(f, "\x1b[35m{}\x1b[0m", self.0)
|
||||||
@@ -126,3 +147,46 @@ pub fn format_f64(value: f64) -> String {
|
|||||||
|
|
||||||
formatted
|
formatted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TimeFrame {
|
||||||
|
pub fn as_str(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::M1 => "1m",
|
||||||
|
Self::M3 => "3m",
|
||||||
|
Self::M5 => "5m",
|
||||||
|
Self::M15 => "15m",
|
||||||
|
Self::M30 => "30m",
|
||||||
|
|
||||||
|
Self::H1 => "1h",
|
||||||
|
Self::H2 => "2h",
|
||||||
|
Self::H4 => "4h",
|
||||||
|
Self::H8 => "8h",
|
||||||
|
Self::H12 => "12h",
|
||||||
|
|
||||||
|
Self::D1 => "1d",
|
||||||
|
Self::D3 => "3d",
|
||||||
|
|
||||||
|
Self::W1 => "1w",
|
||||||
|
Self::Month1 => "1M",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user