Cooldown config
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct RiskManifest {
|
|||||||
version: String,
|
version: String,
|
||||||
|
|
||||||
max_loss: u8,
|
max_loss: u8,
|
||||||
cooldown: String,
|
cooldown: CandleInterval,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pwp]
|
#[pwp]
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ pub enum Mode {
|
|||||||
#[pwp]
|
#[pwp]
|
||||||
pub enum ItemState {
|
pub enum ItemState {
|
||||||
Running,
|
Running,
|
||||||
Off,
|
Stopped,
|
||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ impl std::fmt::Display for ItemState {
|
|||||||
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 {
|
||||||
Self::Running => write!(f, "\x1b[92mRUNNING\x1b[0m"),
|
Self::Running => write!(f, "\x1b[92mRUNNING\x1b[0m"),
|
||||||
Self::Off => write!(f, "\x1b[90mOFF\x1b[0m"),
|
Self::Stopped => write!(f, "\x1b[90mSTOPPED\x1b[0m"),
|
||||||
Self::Error => write!(f, "\x1b[91mERROR\x1b[0m"),
|
Self::Error => write!(f, "\x1b[91mERROR\x1b[0m"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ impl Engine {
|
|||||||
loop {
|
loop {
|
||||||
refresh.tick().await;
|
refresh.tick().await;
|
||||||
|
|
||||||
let watch_list = &self.config.lock().await.watchlist.symbols;
|
let watch_list = &self.config.lock().await.watchlist;
|
||||||
|
|
||||||
match crate::fetch::fetch_watch_list(&client, watch_list).await {
|
match crate::fetch::fetch_watch_list(&client, watch_list).await {
|
||||||
Ok(watch_list) => {
|
Ok(watch_list) => {
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
#[derive(Debug, Default, serde::Serialize, serde::Deserialize)]
|
use hypersdk::hypercore::CandleInterval;
|
||||||
pub struct WatchList {
|
|
||||||
pub symbols: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub watchlist: WatchList,
|
pub watchlist: Vec<String>,
|
||||||
pub strategy: String,
|
pub strategy: String,
|
||||||
pub risk: String,
|
pub risk: String,
|
||||||
|
pub cooldown: CandleInterval,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
watchlist: vec!["BTC".to_string(), "SOL".to_string(), "ETH".to_string()],
|
||||||
|
strategy: String::new(),
|
||||||
|
risk: String::new(),
|
||||||
|
cooldown: CandleInterval::ThirtyMinutes,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ impl TerminalServer {
|
|||||||
risk: engine.strategy.risk.manifest.lock().await.clone(),
|
risk: engine.strategy.risk.manifest.lock().await.clone(),
|
||||||
mode: Mode::Auto,
|
mode: Mode::Auto,
|
||||||
state: ItemState::Running,
|
state: ItemState::Running,
|
||||||
cooldown: hypersdk::hypercore::CandleInterval::ThirtyMinutes,
|
cooldown: engine.config.lock().await.cooldown,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user