longbridge/alert/
types.rs1#![allow(missing_docs)]
2
3use rust_decimal::Decimal;
4use serde::{Deserialize, Serialize};
5
6use crate::utils::counter::deserialize_counter_id_as_symbol;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct AlertList {
11 pub lists: Vec<AlertSymbolGroup>,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct AlertSymbolGroup {
18 #[serde(
20 rename = "counter_id",
21 deserialize_with = "deserialize_counter_id_as_symbol"
22 )]
23 pub symbol: String,
24 pub code: String,
26 pub market: String,
28 pub name: String,
30 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
32 pub price: Option<Decimal>,
33 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
35 pub chg: Option<Decimal>,
36 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
38 pub p_chg: Option<Decimal>,
39 #[serde(default)]
41 pub product: String,
42 pub indicators: Vec<AlertItem>,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct AlertItem {
49 pub id: String,
51 pub indicator_id: String,
53 pub enabled: bool,
55 pub frequency: i32,
57 pub scope: i32,
59 pub text: String,
61 #[serde(default)]
63 pub state: Vec<i32>,
64 pub value_map: serde_json::Value,
66}
67
68#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
70pub enum AlertCondition {
71 #[serde(rename = "1")]
73 PriceRise = 1,
74 #[serde(rename = "2")]
76 PriceFall = 2,
77 #[serde(rename = "3")]
79 PercentRise = 3,
80 #[serde(rename = "4")]
82 PercentFall = 4,
83}
84
85#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
87pub enum AlertFrequency {
88 #[serde(rename = "1")]
90 Daily = 1,
91 #[serde(rename = "2")]
93 EveryTime = 2,
94 #[serde(rename = "3")]
96 Once = 3,
97}