diff --git a/.gitignore b/.gitignore index 3315737..4e9cd4a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /rust/target /examples/*.log .qodo -/target \ No newline at end of file +/target +.venv \ No newline at end of file diff --git a/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/asyncronous.py b/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/asyncronous.py index 43b27ca..fbbaf3c 100644 --- a/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/asyncronous.py +++ b/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/asyncronous.py @@ -1,6 +1,6 @@ -from BinaryOptionsToolsV2.validator import Validator -from BinaryOptionsToolsV2.config import Config -from BinaryOptionsToolsV2 import RawPocketOption, Logger +from ..validator import Validator +from ..config import Config +from .. import RawPocketOption, Logger from datetime import timedelta diff --git a/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/syncronous.py b/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/syncronous.py index 5cbaac4..1c0d5f6 100644 --- a/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/syncronous.py +++ b/BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/syncronous.py @@ -1,6 +1,6 @@ from .asyncronous import PocketOptionAsync -from BinaryOptionsToolsV2.config import Config -from BinaryOptionsToolsV2.validator import Validator +from ..config import Config +from ..validator import Validator from datetime import timedelta import asyncio diff --git a/crates/binary_options_tools/src/pocketoption/types.rs b/crates/binary_options_tools/src/pocketoption/types.rs index c34840a..683f648 100644 --- a/crates/binary_options_tools/src/pocketoption/types.rs +++ b/crates/binary_options_tools/src/pocketoption/types.rs @@ -334,16 +334,22 @@ pub enum AssetType { } impl Asset { - const DEFAULT_CANDLE_LENGTHS: [CandleLength; 9] = [ + const DEFAULT_CANDLE_LENGTHS: [CandleLength; 15] = [ CandleLength::new(5), CandleLength::new(15), CandleLength::new(30), CandleLength::new(60), - CandleLength::new(60 * 3), - CandleLength::new(60 * 5), - CandleLength::new(60 * 30), - CandleLength::new(60 * 60), - CandleLength::new(60 * 60 * 4), + CandleLength::new(120), + CandleLength::new(180), + CandleLength::new(300), + CandleLength::new(600), + CandleLength::new(900), + CandleLength::new(1800), + CandleLength::new(2700), + CandleLength::new(3600), + CandleLength::new(7200), + CandleLength::new(10800), + CandleLength::new(14400), ]; pub fn is_otc(&self) -> bool { @@ -369,12 +375,17 @@ impl Asset { if !self.allowed_candles.contains(&CandleLength::from(time)) && !Self::DEFAULT_CANDLE_LENGTHS.contains(&CandleLength::from(time)) { + let mut all_available: Vec = self.allowed_candles() + .iter() + .map(|c| c.duration()) + .collect(); + all_available.extend(Self::DEFAULT_CANDLE_LENGTHS.iter().map(|c| c.duration())); + all_available.sort(); + all_available.dedup(); + return Err(PocketError::InvalidAsset(format!( "Time is not in allowed candle durations, available {:?}", - self.allowed_candles() - .iter() - .map(|c| c.duration()) - .collect::>() + all_available ))); } Ok(()) diff --git a/tests/test-get-data.py b/tests/test-get-data.py new file mode 100644 index 0000000..609fd52 --- /dev/null +++ b/tests/test-get-data.py @@ -0,0 +1,21 @@ +from BinaryOptionsToolsV2.pocketoption import PocketOptionAsync +from BinaryOptionsToolsV2.tracing import start_logs +from datetime import timedelta + +import asyncio + +# Main part of the code +async def main(ssid: str): + # The api automatically detects if the 'ssid' is for real or demo account + start_logs(".", "INFO") + api = PocketOptionAsync(ssid) + stream = await api.subscribe_symbol_timed("EURUSD_otc", timedelta(seconds=5)) # Returns a candle obtained from combining candles that are inside a specific time range + + # This should run forever so you will need to force close the program + async for candle in stream: + print(f"Candle: {candle}") # Each candle is in format of a dictionary + +if __name__ == '__main__': + ssid = input('Please enter your ssid: ') + asyncio.run(main(ssid)) + \ No newline at end of file