debot_position_manager/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mod position_manager;
use std::fmt;

pub use position_manager::*;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub enum PositionType {
    #[default]
    Long,
    Short,
}

impl fmt::Display for PositionType {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            PositionType::Long => write!(f, "Long"),
            PositionType::Short => write!(f, "Short"),
        }
    }
}

impl PositionType {
    pub fn opposite(&self) -> PositionType {
        match self {
            PositionType::Long => PositionType::Short,
            PositionType::Short => PositionType::Long,
        }
    }
}