bitpanda_api/model/
ohlc.rs

1//! # Ohlc
2//!
3//! Api types for Open-high-low-close chart for assets
4
5use chrono::{DateTime, FixedOffset};
6use rust_decimal::Decimal;
7
8/// Open high low close chart type
9#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize)]
10pub struct OpenHighLowCloseChart {
11    pub chart: Vec<Ohlc>,
12    pub period: Period,
13}
14
15/// Defines an entry in the OHLC chart
16#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Deserialize)]
17pub struct Ohlc {
18    pub close: Decimal,
19    pub high: Decimal,
20    pub low: Decimal,
21    pub open: Decimal,
22    pub time: DateTime<FixedOffset>,
23}
24
25/// A period which identifies the OHLC chart
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Deserialize)]
27pub enum Period {
28    Day,
29    Week,
30    Month,
31    Year,
32    FiveYears,
33}
34
35impl ToString for Period {
36    fn to_string(&self) -> String {
37        match self {
38            Self::Day => "day",
39            Self::Month => "month",
40            Self::Week => "week",
41            Self::Year => "year",
42            Self::FiveYears => "five-years",
43        }
44        .to_string()
45    }
46}