Skip to content

Commit d58e15d

Browse files
authored
Refactor SubscriptionType to remove SUPPORTED_DURATIONS
Removed the SUPPORTED_DURATIONS constant and updated the time_aligned method to check if the duration is a multiple of the number of seconds in a day.
1 parent 9867e82 commit d58e15d

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

  • crates/binary_options_tools/src/pocketoption

crates/binary_options_tools/src/pocketoption/candle.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@ impl BaseCandle {
283283
}
284284

285285
impl SubscriptionType {
286-
const SUPPORTED_DURATIONS: &[u64] = &[
287-
5, 15, 30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 7200, 10800, 14400,
288-
];
289-
290286
pub fn none() -> Self {
291287
SubscriptionType::None
292288
}
@@ -308,13 +304,13 @@ impl SubscriptionType {
308304
}
309305

310306
pub fn time_aligned(duration: Duration) -> PocketResult<Self> {
311-
if !Self::SUPPORTED_DURATIONS.contains(&duration.as_secs()) {
307+
if !(24 * 60 * 60 % duration.as_secs() == 0) {
312308
warn!(
313309
"Unsupported duration for time-aligned subscription: {:?}",
314310
duration
315311
);
316312
return Err(PocketError::General(format!(
317-
"Unsupported duration for time-aligned subscription: {duration:?}"
313+
"Unsupported duration for time-aligned subscription: {duration:?}, duration should be a multiple of the number of seconds in a day"
318314
)));
319315
}
320316
Ok(SubscriptionType::TimeAligned {

0 commit comments

Comments
 (0)