Risk config
This commit is contained in:
@@ -1,10 +1,20 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use pulse_sdk::general::Allocation;
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct RiskConfig {
|
||||
pub risk_per_trade: Allocation,
|
||||
pub max_open_positions: u32,
|
||||
pub max_daily_loss: Allocation,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Config {
|
||||
pub description: Option<String>,
|
||||
pub watchlist: Vec<String>,
|
||||
pub strategy: String,
|
||||
pub risk: RiskConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
@@ -15,12 +25,23 @@ pub struct ConfigManager {
|
||||
pub configs: HashMap<String, Config>,
|
||||
}
|
||||
|
||||
impl Default for RiskConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
risk_per_trade: Allocation::Percent(10.into()),
|
||||
max_daily_loss: Allocation::Percent(20.into()),
|
||||
max_open_positions: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
description: None,
|
||||
watchlist: vec!["BTC".to_string(), "SOL".to_string(), "ETH".to_string()],
|
||||
strategy: String::new(),
|
||||
risk: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user