debot_position_manager/
lib.rs

1mod position_manager;
2use std::fmt;
3
4pub use position_manager::*;
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
8pub enum PositionType {
9    #[default]
10    Long,
11    Short,
12}
13
14impl fmt::Display for PositionType {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        match self {
17            PositionType::Long => write!(f, "Long"),
18            PositionType::Short => write!(f, "Short"),
19        }
20    }
21}
22
23impl PositionType {
24    pub fn opposite(&self) -> PositionType {
25        match self {
26            PositionType::Long => PositionType::Short,
27            PositionType::Short => PositionType::Long,
28        }
29    }
30}