Skip to content

Commit e153d81

Browse files
committed
Added is_continuous field to instrument object and internal variant to Vendors enum.
1 parent f0bfb01 commit e153d81

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

rust/src/symbols.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub struct Instrument {
3030
pub first_available: u64,
3131
/// first date available in database
3232
pub expiration_date: u64,
33+
/// Coninuous Flag
34+
pub is_continuous: bool,
3335
/// Active status
3436
pub active: bool,
3537
}
@@ -45,6 +47,7 @@ impl Instrument {
4547
last_available: u64,
4648
first_available: u64,
4749
expiration_date: u64,
50+
is_continuous: bool,
4851
active: bool,
4952
) -> Self {
5053
Self {
@@ -57,6 +60,7 @@ impl Instrument {
5760
last_available,
5861
first_available,
5962
expiration_date,
63+
is_continuous,
6064
active,
6165
}
6266
}
@@ -205,6 +209,7 @@ mod tests {
205209
1730419200000000000,
206210
1730419200000000000,
207211
1730419200000000000,
212+
false,
208213
true,
209214
);
210215
// Test
@@ -231,6 +236,7 @@ mod tests {
231236
1730419200000000000,
232237
1730419200000000000,
233238
1730419200000000000,
239+
false,
234240
true,
235241
);
236242
// Test
@@ -258,6 +264,7 @@ mod tests {
258264
1,
259265
1,
260266
1730419200000000000,
267+
false,
261268
true,
262269
);
263270

@@ -291,6 +298,7 @@ mod tests {
291298
1,
292299
1,
293300
1730419200000000000,
301+
false,
294302
true,
295303
);
296304

rust/src/vendors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use pyo3::pyclass;
1717
Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq, TryFromPrimitive, IntoPrimitive,
1818
)]
1919
pub enum Vendors {
20+
Internal = 0,
2021
Databento = 1,
2122
Yfinance = 2,
2223
}
@@ -32,6 +33,7 @@ impl TryFrom<i8> for Vendors {
3233

3334
fn try_from(value: i8) -> Result<Self> {
3435
match value {
36+
0 => Ok(Vendors::Internal),
3537
1 => Ok(Vendors::Databento),
3638
2 => Ok(Vendors::Yfinance),
3739
_ => Err(Error::CustomError("Invalid value for Vendor".into())),
@@ -42,6 +44,7 @@ impl TryFrom<i8> for Vendors {
4244
impl Vendors {
4345
pub const fn as_str(&self) -> &'static str {
4446
match self {
47+
Vendors::Internal => "internal",
4548
Vendors::Databento => "databento",
4649
Vendors::Yfinance => "yfinance",
4750
}
@@ -53,6 +56,7 @@ impl FromStr for Vendors {
5356

5457
fn from_str(value: &str) -> Result<Self> {
5558
match value {
59+
"internal" => Ok(Vendors::Internal),
5660
"databento" => Ok(Vendors::Databento),
5761
"yfinance" => Ok(Vendors::Yfinance),
5862
_ => Err(Error::CustomError(format!(
@@ -65,6 +69,7 @@ impl FromStr for Vendors {
6569
impl fmt::Display for Vendors {
6670
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6771
match self {
72+
Vendors::Internal => write!(f, "internal"),
6873
Vendors::Databento => write!(f, "databento"),
6974
Vendors::Yfinance => write!(f, "yfinance"),
7075
}
@@ -73,20 +78,23 @@ impl fmt::Display for Vendors {
7378

7479
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7580
pub enum VendorData {
81+
Internal,
7682
Databento(DatabentoData),
7783
Yfinance(YfinanceData),
7884
}
7985

8086
impl VendorData {
8187
pub fn encode(&self) -> u64 {
8288
match &self {
89+
VendorData::Internal => return 0,
8390
VendorData::Databento(data) => return data.encode(),
8491
VendorData::Yfinance(data) => return data.encode(),
8592
}
8693
}
8794

8895
pub fn decode(raw: u64, vendor: &Vendors) -> Self {
8996
match vendor {
97+
Vendors::Internal => return VendorData::Internal,
9098
Vendors::Databento => return VendorData::Databento(DatabentoData::decode(raw)),
9199
Vendors::Yfinance => return VendorData::Yfinance(YfinanceData::decode(raw)),
92100
}

0 commit comments

Comments
 (0)