deribit_http/model/
funding.rs1use pretty_simple_display::{DebugPretty, DisplaySimple};
7use serde::{Deserialize, Serialize};
8
9#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
11pub struct FundingChartData {
12 pub current_interest: f64,
14 pub interest_8h: f64,
16 pub data: Vec<FundingDataPoint>,
18}
19
20impl FundingChartData {
21 pub fn new() -> Self {
23 Self {
24 current_interest: 0.0,
25 interest_8h: 0.0,
26 data: Vec::new(),
27 }
28 }
29}
30
31impl Default for FundingChartData {
32 fn default() -> Self {
33 Self::new()
34 }
35}
36
37#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
39pub struct FundingDataPoint {
40 pub index_price: f64,
42 pub interest_8h: f64,
44 pub timestamp: u64,
46}
47
48impl FundingDataPoint {
49 pub fn new(index_price: f64, interest_8h: f64, timestamp: u64) -> Self {
51 Self {
52 index_price,
53 interest_8h,
54 timestamp,
55 }
56 }
57}
58
59#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
61pub struct FundingRateData {
62 pub timestamp: u64,
64 pub index_price: f64,
66 pub interest_8h: f64,
68 pub interest_1h: f64,
70 pub prev_index_price: f64,
72}
73
74impl FundingRateData {
75 pub fn new(
77 timestamp: u64,
78 index_price: f64,
79 interest_8h: f64,
80 interest_1h: f64,
81 prev_index_price: f64,
82 ) -> Self {
83 Self {
84 timestamp,
85 index_price,
86 interest_8h,
87 interest_1h,
88 prev_index_price,
89 }
90 }
91}