binary_option_tools_core/pocketoption/utils/
basic.rs1use chrono::{Duration, Utc};
2use rand::{thread_rng, Rng};
3
4use crate::pocketoption::error::{PocketOptionError, PocketResult};
5
6pub fn get_index() -> PocketResult<u64> {
7 let mut rng = thread_rng();
12
13 let rand = rng.gen_range(10..99);
14 let time = (Utc::now() + Duration::hours(2)).timestamp();
15 format!("{}{}", time, rand)
16 .parse::<u64>()
17 .map_err(|e| PocketOptionError::GeneralParsingError(e.to_string()))
18}
19
20pub fn is_otc(symbol: &str) -> bool {
21 symbol.ends_with("otc")
22}