Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/rust/target
/examples/*.log
.qodo
/target
/target
.venv
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +1 to +3
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename 'asyncronous.py' contains a spelling error. It should be 'asynchronous.py' to correctly spell 'asynchronous'.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rick-29 will fix this later

from datetime import timedelta


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .asyncronous import PocketOptionAsync
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename 'asyncronous.py' contains a spelling error. It should be 'asynchronous.py'. Update the import to match the correct spelling: from .asynchronous import PocketOptionAsync

Suggested change
from .asyncronous import PocketOptionAsync
from .asynchronous import PocketOptionAsync

Copilot uses AI. Check for mistakes.
from BinaryOptionsToolsV2.config import Config
from BinaryOptionsToolsV2.validator import Validator
from ..config import Config
from ..validator import Validator
from datetime import timedelta

import asyncio
Expand Down
31 changes: 21 additions & 10 deletions crates/binary_options_tools/src/pocketoption/types.rs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la verdad no me cambia que uses el 60 * ...

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<u32> = 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::<Vec<_>>()
all_available
)));
}
Ok(())
Expand Down
21 changes: 21 additions & 0 deletions tests/test-get-data.py
Original file line number Diff line number Diff line change
@@ -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))

Loading