binary_option_tools/pocketoption/parser/
basic.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4use crate::pocketoption::{
5 error::PocketResult, types::update::float_time, utils::basic::get_index,
6};
7
8#[derive(Debug, Deserialize)]
9#[allow(unused)]
10pub struct UpdateStream {
11 active: String,
12 #[serde(with = "float_time")]
13 time: DateTime<Utc>,
14 value: f64,
15}
16
17#[derive(Debug, Deserialize)]
18#[serde(rename_all = "lowercase")]
19enum AssetType {
20 Stock,
21 Currency,
22 Commodity,
23 Cryptocurrency,
24 Index,
25}
26
27#[derive(Debug, Serialize, Deserialize, Clone)]
28pub struct LoadHistoryPeriod {
29 pub asset: String,
30 pub period: i64,
31 pub time: i64,
32 pub index: u64,
33 pub offset: i64,
34}
35
36impl LoadHistoryPeriod {
37 pub fn new(asset: impl ToString, time: i64, period: i64, offset: i64) -> PocketResult<Self> {
38 Ok(LoadHistoryPeriod {
39 asset: asset.to_string(),
40 period,
41 time,
42 index: get_index()?,
43 offset,
44 })
45 }
46}