Skip to content

Conversation

@davidantoon
Copy link

@davidantoon davidantoon commented Jul 7, 2025

📝 Description

  • Added support for loadHistoryPeriodFast in get_candle to handle new API message format.
  • Exposed get_candles_advanced for fetching candles by time and offset.
  • Updated enums and parsing logic for compatibility with fast-history mode.
  • Adjusted event emission to include loadHistoryPeriodFast under "candles_received".
  • Cleaned up Cargo.toml to exclude duplicate JS/Py libs.

✅ Ensures compatibility with updated Pocket Option API.

Fixes: #17

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added support for faster historical data retrieval with enhanced candle data queries.
    • Introduced new methods to fetch advanced candle data and current server time.
    • Improved message handling to support additional message types when processing updates in the application.

The get_candle function was failing due to a 16s timeout. The receiver was waiting for a LoadHistoryPeriod stream, which should have been matched by MessageInfo::LoadHistoryPeriod. However, in the updated Pocket Option WebSocket API, the response format changed and was instead caught as MessageInfo::UpdateStream.

Updated the parsing logic to handle this case by attempting to deserialize LoadHistoryPeriodResult under UpdateStream:

rust
Copy
Edit
MessageInfo::UpdateStream => {
    if let Ok(stream) = from_str::<UpdateStream>(&data) {
        return Self::UpdateStream(stream);
    }
    if let Ok(stream) = from_str::<LoadHistoryPeriodResult>(&data) {
        return Self::LoadHistoryPeriod(stream);
    }
}
This ensures compatibility with the new API response structure and prevents the timeout issue.
@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

"""

Walkthrough

The change adds support for a new LoadHistoryPeriodFast message variant in the PocketOption WebSocket message parsing and handling logic, including enum variants, parsing context, message info mapping, and display formatting. It also introduces new candle variants with timestamp handling, extends the client to handle the "loadHistoryPeriodFast" event, and adds advanced candle retrieval methods in the Rust and TypeScript PocketOption client APIs. The workspace configuration excludes two packages.

Changes

File(s) Change Summary
crates/binary_options_tools/src/pocketoption/parser/message.rs, types/info.rs, types/update.rs Added LoadHistoryPeriodFast variant to enums and parsing; added new candle variants ProcessedNew and UpdateNew with timestamp conversion and aggregation logic.
crates/core/data/client_enhanced.rs Added handling for "loadHistoryPeriodFast" event to emit candles_received event.
BinaryOptionsToolsJs/src/pocketoption.rs, BinaryOptionsToolsJs/index.d.ts Added get_candles_advanced and getServerTime methods to PocketOption client (Rust and TypeScript).
Cargo.toml Added exclude field to workspace configuration to exclude BinaryOptionsToolsJs; added BinaryOptionsToolsV2 to members.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant WebSocketHandler
    participant EventEmitter

    Client->>WebSocketHandler: receive JSON message
    alt event == "loadHistoryPeriod" or "loadHistoryPeriodFast"
        WebSocketHandler->>EventEmitter: emit candles_received with event data
    else
        WebSocketHandler->>EventEmitter: handle other events
    end
Loading
sequenceDiagram
    participant User
    participant PocketOptionClient

    User->>PocketOptionClient: call get_candles_advanced(asset, time, period, offset)
    PocketOptionClient->>PocketOptionClient: send request to fetch candles with parameters
    PocketOptionClient-->>User: return candle data JSON
Loading

Assessment against linked issues

Objective Addressed Explanation
Improve/fix data fetching and parsing for PocketOption WebSocket messages (#17)

Poem

🐇 Through websockets swift and fast,
New messages parsed at last!
Candles counted, data flows,
Advanced queries now arose.
From Rust to JS, the methods grow,
Fetching history in a flow.
Hop along, the code does dance,
In every byte, a chance! 🌟
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.86.0)
Updating crates.io index

warning: failed to write cache, path: /usr/local/registry/index/index.crates.io-1949cf8c6b5b557f/.cache/ch/ro/chrono, error: Permission denied (os error 13)
Locking 273 packages to latest compatible versions
Downloading crates ...
Downloaded parking_lot_core v0.9.11
error: failed to create directory /usr/local/registry/cache/index.crates.io-1949cf8c6b5b557f

Caused by:
Permission denied (os error 13)

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@theshadow76
Copy link
Contributor

Let me review it with @Rick-29

@Rick-29
Copy link
Contributor

Rick-29 commented Jul 7, 2025

it looks good but currently i am working on a 100% rework on the core of the crate and the data handling methods.
if you want you can take a look at the new core that will replace the old one and tell me what you think:
https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/tree/master/crates/core-pre
(hopefully today i will make a new commit with progess on supporting more features of pocket option).

@davidantoon
Copy link
Author

davidantoon commented Jul 8, 2025

it looks good but currently i am working on a 100% rework on the core of the crate and the data handling methods. if you want you can take a look at the new core that will replace the old one and tell me what you think: https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/tree/master/crates/core-pre (hopefully today i will make a new commit with progess on supporting more features of pocket option).

@Rick-29
Make sure to include the new loadHistoryPeriodFast, which is triggered after 7 loadHistoryPeriod events.

I’ll add it to this PR.

Screenshot 2025-07-08 at 3 18 35

@Rick-29
Copy link
Contributor

Rick-29 commented Jul 8, 2025

Ok, good to know, currently i am implementing supoort for buying and selling, then i will work on checking trade results, i will work on receiving the data.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fce8fe and f60a053.

📒 Files selected for processing (7)
  • BinaryOptionsToolsJs/index.d.ts (2 hunks)
  • BinaryOptionsToolsJs/src/pocketoption.rs (1 hunks)
  • Cargo.toml (1 hunks)
  • crates/binary_options_tools/src/pocketoption/parser/message.rs (5 hunks)
  • crates/binary_options_tools/src/pocketoption/types/info.rs (1 hunks)
  • crates/binary_options_tools/src/pocketoption/types/update.rs (2 hunks)
  • crates/core/data/client_enhanced.rs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • crates/core/data/client_enhanced.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • Cargo.toml
  • crates/binary_options_tools/src/pocketoption/parser/message.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
BinaryOptionsToolsJs/src/pocketoption.rs (4)
crates/binary_options_tools/src/pocketoption/pocket_client.rs (1)
  • get_candles_advanced (441-477)
BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/syncronous.py (1)
  • get_candles_advanced (146-169)
BinaryOptionsToolsV2/BinaryOptionsToolsV2/pocketoption/asyncronous.py (1)
  • get_candles_advanced (248-271)
BinaryOptionsToolsV2/src/pocketoption.rs (1)
  • get_candles_advanced (173-187)
🔇 Additional comments (6)
crates/binary_options_tools/src/pocketoption/types/info.rs (1)

28-28: LGTM! Clean enum variant addition.

The new LoadHistoryPeriodFast variant is correctly placed and follows the existing naming conventions.

BinaryOptionsToolsJs/src/pocketoption.rs (1)

281-306: LGTM! Well-implemented method with comprehensive documentation.

The get_candles_advanced method follows established patterns for async methods in this file. The documentation includes a clear example, and error handling is consistent with other methods.

BinaryOptionsToolsJs/index.d.ts (2)

283-302: LGTM! Accurate TypeScript declarations with good documentation.

The getCandlesAdvanced method declaration correctly reflects the Rust implementation with proper parameter types and comprehensive documentation.


581-582: LGTM! Simple and correct method declaration.

The getServerTime method declaration is accurate and follows the established pattern.

crates/binary_options_tools/src/pocketoption/types/update.rs (2)

39-39: LGTM! Consistent enum variant addition.

The new ProcessedNew variant follows the established pattern and naming convention.


43-51: LGTM! Well-structured candle data representation.

The ProcessedCandleNew struct properly uses i64 for the timestamp to avoid precision issues, and the OHLC fields are appropriately typed as f64.

@davidantoon
Copy link
Author

@Rick-29

I figured out why the get_candle result was returning an UpdateStream type. The issue was caused by a missing LoadHistoryPeriodFast handler, which led the data to be marked as UpdateStream. After adding support for LoadHistoryPeriodFast, it now works as expected without needing the case patch on UpdateStream.

I also exposed get_candle_advanced to provide an option for retrieving candles based on time and offset without relying on server time. Additionally, I fixed the Cargo.toml file to exclude the JS and Python libraries, preventing duplication issues when working with Rust.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/JsPublish.yml (2)

28-32: Explicit pinning to macos-13 is sensible but may age quickly

Pinning the Intel runner to macos-13 guarantees determinism today, yet GitHub often deprecates older macOS images with short notice. Keep an eye on deprecation emails and be prepared to move to macos-14 (or later) to avoid sudden job failures.


48-51: Consider pinning the Apple-silicon runner to a concrete image

While the comment clarifies that this leg builds on ARM64, leaving the host as macos-latest means the image will float (currently macos-14-arm64). A future bump (e.g., macos-15) could introduce SDK or tool-chain surprises.

-          - host: macos-latest # (arm64 processor)
+          - host: macos-14 # (arm64 processor, Apple Silicon)

Pinning avoids unwelcome CI breakage at release time.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0ab615 and 20d7f4d.

📒 Files selected for processing (1)
  • .github/workflows/JsPublish.yml (3 hunks)
🔇 Additional comments (1)
.github/workflows/JsPublish.yml (1)

214-217: Align test matrix with build matrix for stability

You pinned the build job to macos-13 but left tests previously on the floating runner; updating tests to the same pinned image keeps parity—good move. As above, watch for deprecation announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2958cdd and 06d2de3.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .github/workflows/CI.yml (1 hunks)
  • .github/workflows/JsPublish.yml (5 hunks)
  • BinaryOptionsToolsV2/Cargo.toml (1 hunks)
  • Cargo.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • BinaryOptionsToolsV2/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (2)
  • Cargo.toml
  • .github/workflows/JsPublish.yml

Comment on lines 56 to 60
# 🛠 Enable vendored OpenSSL for all platforms as fallback
- name: Set OPENSSL vendored fallback
run: |
echo "OPENSSL_NO_VENDOR=0" >> $GITHUB_ENV
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

OPENSSL_NO_VENDOR here disables – not enables – vendored OpenSSL

The comment says “Enable vendored OpenSSL”, but merely setting OPENSSL_NO_VENDOR (even to 0) disables vendoring in the openssl crate.
Remove it and keep only OPENSSL_STATIC=1 (or switch to OPENSSL_VENDOR=1 if you need to force vendoring).

-          echo "OPENSSL_NO_VENDOR=0" >> $GITHUB_ENV
           echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
+          # Leave OPENSSL_NO_VENDOR unset so the build can fall back to the vendored copy
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# 🛠 Enable vendored OpenSSL for all platforms as fallback
- name: Set OPENSSL vendored fallback
run: |
echo "OPENSSL_NO_VENDOR=0" >> $GITHUB_ENV
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
# 🛠 Enable vendored OpenSSL for all platforms as fallback
- name: Set OPENSSL vendored fallback
run: |
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
# Leave OPENSSL_NO_VENDOR unset so the build can fall back to the vendored copy
🤖 Prompt for AI Agents
In .github/workflows/CI.yml around lines 56 to 60, the environment variable
OPENSSL_NO_VENDOR is incorrectly set to 0, which disables vendored OpenSSL
instead of enabling it. To fix this, remove the line setting OPENSSL_NO_VENDOR
entirely and keep only the line setting OPENSSL_STATIC=1, or alternatively
replace it with OPENSSL_VENDOR=1 if you want to explicitly enable vendored
OpenSSL.

Comment on lines 44 to 55
- name: Setup cross-compilation for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libssl-dev:armhf pkg-config
echo "OPENSSL_DIR=/usr/arm-linux-gnueabihf" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV
echo "CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing Rust target & incorrect linker env name break the armv7 build

maturin will invoke cargo, but rustup is never told to install the armv7-unknown-linux-gnueabihf target, and Cargo will look for CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER, not CC_armv7_unknown_linux_gnueabihf.
Without both, the cross-compile step will fail at link time.

@@
-          sudo apt-get install -y gcc-arm-linux-gnueabihf libssl-dev:armhf pkg-config
+          sudo apt-get install -y gcc-arm-linux-gnueabihf libssl-dev:armhf pkg-config
+
+          # Install the Rust std lib for the target
+          rustup target add armv7-unknown-linux-gnueabihf
@@
-          echo "CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
+          echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup cross-compilation for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libssl-dev:armhf pkg-config
echo "OPENSSL_DIR=/usr/arm-linux-gnueabihf" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV
echo "CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: Setup cross-compilation for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libssl-dev:armhf pkg-config
# Install the Rust std lib for the target
rustup target add armv7-unknown-linux-gnueabihf
echo "OPENSSL_DIR=/usr/arm-linux-gnueabihf" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
🤖 Prompt for AI Agents
In .github/workflows/CI.yml around lines 44 to 55, the Rust target
armv7-unknown-linux-gnueabihf is not installed via rustup, and the environment
variable for the linker is incorrectly named CC_armv7_unknown_linux_gnueabihf
instead of CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER. Fix this by adding
a step to install the Rust target using rustup and rename the linker environment
variable to CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER with the correct
linker command.

@Rick-29
Copy link
Contributor

Rick-29 commented Jul 9, 2025

@davidantoon if you want to help on developping this crate (for which i am really glad), i would prefer if you checked the pocketoption_pre folder since it's where i am working currently, my new architecture is composed of 2 kind of modules (mainly), the lightweight modules that are automatic systems for example a keep alive module that sends a ping each 20 seconds, an update balance module that listens for messages of the server, and the api modules, that are composed of 1 module that is run in it's own thread and a handle that comunicates with the module, the handle is intended to be used by the user in functions like buy sell, check_results, etc...
My goal with this new architecture is to have each component of the support for a platform separated, so if there is a change made on the platform (like currently on pocket option) only one module fails while the rest continues to work well.
If you want we can talk on discord, i would really like feedback on this new architecture (since while i like that it's easier to implement and work on, it's probably less optimized at least currently as the data is shared across multiple threads and i feel that for bigger platforms the route function of the Router will not be enouph as it is (it has like 3 for loops)).

Also I updated on github the latest code i have and will not work on it untill tomorrow afternoon.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (3)
.github/workflows/CI.yml (3)

147-151: Condition still checks env.PYPI_API_TOKEN – step will never run

The env: block is applied after the if: is evaluated, so this is always empty.
Use the secret directly (identical to the past review).

-        if: env.PYPI_API_TOKEN != ''
+        if: secrets.PYPI_API_TOKEN != ''

184-188: Same if: issue on macOS publish step – apply the fix here as well.


227-230: Release job uses the same fragile guard – switch to secrets.PYPI_API_TOKEN and you can drop the intermediate env: indirection entirely.

🧹 Nitpick comments (1)
.github/workflows/CI.yml (1)

58-63: Perl-dependency step runs for every Linux target

Only armv7 requires the vendored OpenSSL tool-chain; running apt-get, cpanm, etc. on x86_64, aarch64 … wastes minutes. Guard it the same way as the OpenSSL step:

-      - name: Install perl dependencies for OpenSSL
+      - name: Install perl dependencies for OpenSSL
+        if: matrix.platform.target == 'armv7'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38f284c and 4f5f9c1.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/CI.yml (7 hunks)
  • BinaryOptionsToolsJs/Cargo.toml (1 hunks)
  • BinaryOptionsToolsV2/Cargo.toml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • BinaryOptionsToolsJs/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • BinaryOptionsToolsV2/Cargo.toml
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/CI.yml

[error] 49-49: trailing spaces

(trailing-spaces)


[error] 53-53: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
.github/workflows/CI.yml (2)

24-24: Good call disabling fail-fast on the matrix
Avoids aborting the whole job when a single target flakes.


33-34: Runner downgraded to ubuntu-22.04 only for armv7 – OK
Matches the need for a newer cross-compiler while keeping other targets on the default runner.

Comment on lines +93 to 95
- runner: ubuntu-22.04
target: armv7
steps:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

musllinux job: armv7 lacks cross-compile setup

Unlike the glibc job, the musllinux armv7 leg has no steps to install the Rust target, tool-chain or linker env vars, so it will fail at compile/link time. Mirror the fixes from the Linux job.

🤖 Prompt for AI Agents
In .github/workflows/CI.yml around lines 93 to 95, the musllinux job for armv7
is missing the setup steps for cross-compilation such as installing the Rust
target, toolchain, and setting linker environment variables. To fix this, add
the necessary steps to install the Rust armv7 target, configure the appropriate
cross-compilation toolchain, and set the linker environment variables, mirroring
the setup used in the glibc Linux job for armv7.

Comment on lines 44 to 57
- name: Configure vendored OpenSSL for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf
# Force openssl-sys to build vendored OpenSSL
echo "OPENSSL_NO_VENDOR=0" >> $GITHUB_ENV
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
# Use the cross-compiler as CC and tell Cargo to use it
echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Vendored-OpenSSL block still has three ​blocking problems

  1. OPENSSL_NO_VENDOR=0 disables vendoring even when set to 0 – the mere presence of the var turns it off (see past review).
  2. Overwriting global CC forces the host build (build-scripts, proc-macros) to use the ARM cross-compiler and will fail.
    Use CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_CC (or the linker key already set) instead.
  3. The Rust std-lib for the target is still not installed (rustup target add …), so the build will fail before link time.
   sudo apt-get install -y gcc-arm-linux-gnueabihf
+
+  # Install Rust std-lib for the target
+  rustup target add armv7-unknown-linux-gnueabihf
-
-  echo "OPENSSL_NO_VENDOR=0" >> $GITHUB_ENV
-  echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
-  
-  echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
+  # Force openssl-sys to build its vendored copy statically
+  echo "OPENSSL_VENDOR=1" >> $GITHUB_ENV
+  echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
+
+  # Tell Cargo which compiler to use *only* for the armv7 target
+  echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV

Also, YAML-lint flags trailing whitespace on lines 49 & 53 – remove to keep the file lint-clean.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Configure vendored OpenSSL for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf
# Force openssl-sys to build vendored OpenSSL
echo "OPENSSL_NO_VENDOR=0" >> $GITHUB_ENV
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
# Use the cross-compiler as CC and tell Cargo to use it
echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
- name: Configure vendored OpenSSL for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf
# Install Rust std-lib for the target
rustup target add armv7-unknown-linux-gnueabihf
# Force openssl-sys to build its vendored copy statically
echo "OPENSSL_VENDOR=1" >> $GITHUB_ENV
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
# Tell Cargo which compiler to use *only* for the armv7 target
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 49-49: trailing spaces

(trailing-spaces)


[error] 53-53: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In .github/workflows/CI.yml around lines 44 to 57, fix the vendored OpenSSL
configuration by removing the OPENSSL_NO_VENDOR variable entirely since its
presence disables vendoring regardless of value. Replace the global CC
environment variable with CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_CC to avoid
forcing the host build to use the ARM cross-compiler. Add a step to install the
Rust standard library for the armv7 target using rustup target add before the
build step. Also, remove trailing whitespace on lines 49 and 53 to pass YAML
lint checks.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (5)
.github/workflows/CI.yml (5)

44-53: armv7 step still misses rustup target add and wrongly overrides global CC

Previous reviews already pointed this out.
Without installing the armv7-unknown-linux-gnueabihf target, the build will fail long before link time, and exporting a global CC forces the host build to use the cross-compiler. Use only CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER (already present) and add the rustup target install.


54-60: OPENSSL_NO_VENDOR=0 still disables vendored OpenSSL

Setting this var — regardless of value — tells the openssl crate not to vendor.
Drop it entirely or switch to OPENSSL_VENDOR=1.
Same feedback as the earlier review.


151-156: if: env.PYPI_API_TOKEN never evaluates as intended

The env: block is applied after the condition is parsed, so this step is always skipped.
Gate on the secret directly: if: secrets.PYPI_API_TOKEN != ''.


188-193: Same misplaced if: condition as in Windows job

Use if: secrets.PYPI_API_TOKEN != '' here as well.


231-235: Release job: if: check suffers from the same problem

Replace with if: secrets.PYPI_API_TOKEN != '' to ensure the upload actually runs when the secret is present.

🧹 Nitpick comments (1)
.github/workflows/CI.yml (1)

49-60: YAML-lint: trailing whitespace on lines 49 / 56 / 60

Remove the stray spaces to keep the workflow lint-clean.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f5f9c1 and 344351c.

📒 Files selected for processing (1)
  • .github/workflows/CI.yml (7 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/CI.yml

[error] 49-49: trailing spaces

(trailing-spaces)


[error] 56-56: trailing spaces

(trailing-spaces)


[error] 60-60: trailing spaces

(trailing-spaces)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
.github/workflows/CI.yml (3)

204-208: Same token-guard issue in the macOS job
Apply the identical secrets.PYPI_API_TOKEN fix here as well.


167-172: Publish step will never run – wrong if: expression

env.PYPI_API_TOKEN isn’t defined when the condition is evaluated. Gate on the secret instead:

-        if: env.PYPI_API_TOKEN != ''
+        if: secrets.PYPI_API_TOKEN != ''

247-251: Undefined PYPI_API_TOKEN in release job

The env block never assigns PYPI_API_TOKEN, yet you reference it twice.

-        if: env.PYPI_API_TOKEN != ''
+        if: secrets.PYPI_API_TOKEN != ''
@@
-          TWINE_PASSWORD: ${{ env.PYPI_API_TOKEN }}
+          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
🧹 Nitpick comments (1)
.github/workflows/CI.yml (1)

45-59: YAML-lint failures: trailing whitespace on 54 & 59
These two spaces are the only things blocking the linter.

-            perl␠
+            perl
@@
-          echo "OPENSSL_STATIC=1" >> $GITHUB_ENV␠
+          echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 344351c and e0dc909.

📒 Files selected for processing (1)
  • .github/workflows/CI.yml (8 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/CI.yml

[error] 54-54: trailing spaces

(trailing-spaces)


[error] 59-59: trailing spaces

(trailing-spaces)


[error] 65-65: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
.github/workflows/CI.yml (2)

24-24: Good call disabling matrix fail-fast
Turning off fail-fast improves diagnostics across the whole matrix.


236-236: Release job may miss Linux wheels

Removing linux & musllinux from needs allows the release job to start before those artifacts exist:

-    needs: [ macos, windows ] # [macos, windows, linux, musllinux]
+    needs: [ macos, windows, linux, musllinux ]

Comment on lines 60 to 68
- name: Configure vendored OpenSSL for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf
# Use the cross-compiler as CC and tell Cargo to use it
echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

armv7 leg still incomplete & over-scoped CC

  1. Add the target std-lib or the build aborts before linking:
    rustup target add armv7-unknown-linux-gnueabihf
  2. Don’t overwrite global CC; restrict the cross-compiler to the target:
+          rustup target add armv7-unknown-linux-gnueabihf
-          echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV

The target-specific var you already set is sufficient.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Configure vendored OpenSSL for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf
# Use the cross-compiler as CC and tell Cargo to use it
echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
- name: Configure vendored OpenSSL for armv7
if: matrix.platform.target == 'armv7'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf
# Install the Rust standard library for the armv7 target
rustup target add armv7-unknown-linux-gnueabihf
# Use the target-specific linker only (no global CC override)
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 65-65: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In .github/workflows/CI.yml around lines 60 to 68, the workflow is missing the
addition of the Rust target armv7-unknown-linux-gnueabihf, which causes build
failures before linking. Add a step to run `rustup target add
armv7-unknown-linux-gnueabihf` before building. Also, remove the line that sets
the global CC environment variable to the cross-compiler and only keep the
target-specific linker environment variable to avoid over-scoping the compiler
setting.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
.github/workflows/CI.yml (2)

60-69: armv7 cross-compile block still misses Rust target and over-scopes CC

Exactly the same issues were pointed out in previous review rounds:

  1. rustup target add armv7-unknown-linux-gnueabihf is still missing – the build will stop before linking.
  2. Overwriting global CC forces host-build crates (proc-macros, build-scripts) to use the ARM cross-compiler and will break.
    Keep only the target-specific variable that Cargo actually consults (CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER), or use the more explicit CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_CC.
+          # Install the Rust std-lib for the target
+          rustup target add armv7-unknown-linux-gnueabihf
-          echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV

167-172: if: env.PYPI_API_TOKEN still never matches – step is always skipped

env.PYPI_API_TOKEN is populated after the if: is evaluated, so the publish steps never run.
Gate directly on the secret, as previously suggested:

-        if: env.PYPI_API_TOKEN != ''
+        if: secrets.PYPI_API_TOKEN != ''

Also applies to: 204-208, 247-252

🧹 Nitpick comments (1)
.github/workflows/CI.yml (1)

45-56: Trailing whitespace trips YAML-lint

Lines 54 and 65 still contain trailing spaces which will fail yamllint. Strip them to keep the workflow lint-clean.

-            perl␠
+            perl-          
+          

Also applies to: 63-66

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0dc909 and 29de217.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/CI.yml (8 hunks)
  • BinaryOptionsToolsJs/Cargo.toml (1 hunks)
  • BinaryOptionsToolsV2/Cargo.toml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • BinaryOptionsToolsJs/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • BinaryOptionsToolsV2/Cargo.toml
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/CI.yml

[error] 54-54: trailing spaces

(trailing-spaces)


[error] 65-65: trailing spaces

(trailing-spaces)

@Rick-29
Copy link
Contributor

Rick-29 commented Jul 10, 2025

it looks good but currently i am working on a 100% rework on the core of the crate and the data handling methods. if you want you can take a look at the new core that will replace the old one and tell me what you think: https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/tree/master/crates/core-pre (hopefully today i will make a new commit with progess on supporting more features of pocket option).

@Rick-29 Make sure to include the new loadHistoryPeriodFast, which is triggered after 7 loadHistoryPeriod events.

I’ll add it to this PR.

Screenshot 2025-07-08 at 3 18 35

i will check, @davidantoon what is your discord username so we can talk there as i want to ask you some questions, and also are you sure the loadHistoyPeriodFaset is triggered after 7 loadHistoryPeriod? since when i tested on my account (testing account), it never displayed it
image

@frontegg-david
Copy link

it looks good but currently i am working on a 100% rework on the core of the crate and the data handling methods. if you want you can take a look at the new core that will replace the old one and tell me what you think: https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/tree/master/crates/core-pre (hopefully today i will make a new commit with progess on supporting more features of pocket option).

@Rick-29 Make sure to include the new loadHistoryPeriodFast, which is triggered after 7 loadHistoryPeriod events.

I’ll add it to this PR.

Screenshot 2025-07-08 at 3 18 35

i will check, @davidantoon what is your discord username so we can talk there as i want to ask you some questions, and also are you sure the loadHistoyPeriodFaset is triggered after 7 loadHistoryPeriod? since when i tested on my account (testing account), it never displayed it

image

Yes it's me davidantoon on discord, let's move this conversation to discord channel.

@theshadow76
Copy link
Contributor

Awesome, I will keep this PR open. If needed let me know if it needs to be closed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3f1a7c and b0f69c9.

📒 Files selected for processing (2)
  • .github/workflows/JsPublish.yml (8 hunks)
  • crates/binary_options_tools/src/pocketoption/types/update.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/JsPublish.yml
🔇 Additional comments (7)
crates/binary_options_tools/src/pocketoption/types/update.rs (7)

2-2: LGTM - Appropriate imports for new functionality.

The new imports for fmt and BTreeMap are correctly added to support the Display trait implementation and candle aggregation logic respectively.

Also applies to: 4-4


24-24: LGTM - New field for snapshot candles.

The candles field addition to UpdateHistoryNewFast appropriately supports the new fast history loading feature with snapshot data.


40-43: LGTM - New enum variants for enhanced candle types.

The new ProcessedNew and UpdateNew variants appropriately extend the Candle enum to support the enhanced candle data structures.


45-53: Good design choice for timestamp handling.

Using i64 for the timestamp in ProcessedCandleNew avoids potential precision issues that could occur with floating-point timestamps. The field naming and structure are appropriate for the new candle format.


91-99: LGTM - Consistent structure with proper timestamp type.

The UpdateCandleNew struct appropriately uses DateTime<Utc> for the timestamp field, maintaining consistency with the existing codebase patterns.


185-197: Excellent error handling for timestamp conversion.

The implementation properly addresses the previous review comment by using unwrap_or_else with a fallback to current time and logging the error. This prevents panics while maintaining functionality.


199-208: LGTM - Direct timestamp usage for UpdateNew variant.

The implementation correctly uses the DateTime<Utc> timestamp directly from the UpdateCandleNew struct, avoiding unnecessary conversions.

Comment on lines +234 to 291
// 1) snapshot candles (descending)
let existing: Vec<DataCandle> = self.candles.iter().map(DataCandle::from).collect();
let mut history_dc: Vec<DataCandle> = self.history.iter().map(DataCandle::from).collect();

history_dc.sort_unstable_by_key(|c| c.time.timestamp());

// 3) cutoff: up through the last snapshot candle
let last_cutoff = existing
.first()
.map(|c| c.time.timestamp())
.unwrap_or_else(|| {
let ts = history_dc
.first()
.expect("history cannot be empty")
.time
.timestamp();
(ts / self.period) * self.period - self.period
});

// 4) aggregate into period-buckets via a BTreeMap
let mut buckets: BTreeMap<i64, (f64, f64, f64, f64)> = BTreeMap::new();
for dc in &history_dc {
let ts = dc.time.timestamp();
let bucket = (ts / self.period) * self.period;
if bucket <= last_cutoff {
continue;
}

let price = dc.close; // or whichever price you want
buckets
.entry(bucket)
.and_modify(|e| {
e.1 = e.1.max(price); // high
e.2 = e.2.min(price); // low
e.3 = price; // close
})
.or_insert((price, price, price, price));
}

// 5) build new candles (descending) and prepend snapshot
let mut new_candles: Vec<DataCandle> = buckets
.into_iter()
.rev()
.map(|(bucket_ts, (open, high, low, close))| {
let dt = DateTime::from_timestamp(bucket_ts, 0).unwrap();
DataCandle {
time: dt,
open,
high,
low,
close,
}
})
.collect();

new_candles.extend(existing);
new_candles
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Complex method needs refactoring for maintainability.

The candle_data method implements sophisticated aggregation logic but has several issues that should be addressed:

  1. Panic risk: Line 247 uses expect("history cannot be empty") which will panic if the history is empty
  2. Another panic risk: Line 278 uses unwrap() on DateTime::from_timestamp without error handling
  3. High complexity: The method is quite large and handles multiple responsibilities (sorting, filtering, bucketing, aggregating)

Apply these fixes:

-            .first()
-            .expect("history cannot be empty")
+            .first()
+            .ok_or_else(|| "history cannot be empty")?
-                let dt = DateTime::from_timestamp(bucket_ts, 0).unwrap();
+                let dt = DateTime::from_timestamp(bucket_ts, 0).unwrap_or_else(|| {
+                    eprintln!("Invalid bucket timestamp {}, using current time", bucket_ts);
+                    Utc::now()
+                });

Consider breaking this method into smaller, focused functions:

  • sort_and_filter_history
  • aggregate_into_buckets
  • create_candles_from_buckets
  • merge_snapshot_and_aggregated

This would improve readability, testability, and maintainability.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In crates/binary_options_tools/src/pocketoption/types/update.rs from lines 234
to 291, the candle_data method is too complex and has panic risks due to using
expect on empty history and unwrap on DateTime::from_timestamp. Refactor by
splitting the method into smaller functions: one to sort and filter history
safely without panics, another to aggregate data into buckets, a third to create
candles from these buckets with proper error handling instead of unwrap, and a
final one to merge snapshot and aggregated candles. Replace expect and unwrap
with error handling or safe defaults to avoid panics and improve
maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I was able to fetch data but now i am unable to fetch any data

4 participants