Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
322cedd
Fixed parsing in get_candle with context for Pocket Option API changes
davidantoon Jul 7, 2025
7fce8fe
Update Cargo.toml
davidantoon Jul 7, 2025
97e145b
Add support for LoadHistoryPeriodFast
frontegg-david Jul 8, 2025
f60a053
Expose get_candles_advanced for retrieve historical by time and offset
frontegg-david Jul 8, 2025
7b14993
Add code suggestion from code review
frontegg-david Jul 8, 2025
cd40441
Add full examples to comments to prevent RustRover IntelliJ syntax er…
frontegg-david Jul 8, 2025
e0ab615
add node_modules and error.log to gitignore
frontegg-david Jul 8, 2025
20d7f4d
Fix jsPublish workflow macos run-on versions to support intel and arm…
frontegg-david Jul 8, 2025
52c7e08
Fix jsPublish workflow macos run-on versions to support intel and arm…
frontegg-david Jul 9, 2025
2958cdd
Merge branch 'ChipaDevTeam:master' into patch-1
davidantoon Jul 9, 2025
2629312
fix branch name
frontegg-david Jul 9, 2025
b8588d9
fix cargo toml
frontegg-david Jul 9, 2025
486070d
Fix cargo toml file
frontegg-david Jul 9, 2025
aae20bf
rename readme file to README.md to fix CI build
frontegg-david Jul 9, 2025
878d054
Add support to trigger js publish workflow
frontegg-david Jul 9, 2025
9078fe1
Update openssl version when targeting armv7
frontegg-david Jul 9, 2025
06d2de3
Fix all readme files name
frontegg-david Jul 9, 2025
2fcf452
Fix ci build
frontegg-david Jul 9, 2025
61a8608
Skip publish if no PyPi api token
frontegg-david Jul 9, 2025
5938c9e
Skip publish if no PyPi api token
frontegg-david Jul 9, 2025
38f284c
Fix openssl for armv7
frontegg-david Jul 9, 2025
33c3bfd
Fix openssl for armv7
frontegg-david Jul 9, 2025
7a50075
Fix openssl for armv7
frontegg-david Jul 9, 2025
05e9fbb
Fix openssl for armv7
frontegg-david Jul 9, 2025
18dee2b
Fix openssl for armv7
frontegg-david Jul 9, 2025
ffa4a70
Fix openssl for armv7
frontegg-david Jul 9, 2025
b4a7680
disable fail fast for testing ci workflow
frontegg-david Jul 9, 2025
4f5f9c1
disable fail fast for testing ci workflow
frontegg-david Jul 9, 2025
21c6269
Ensure all required Perl modules are available for OpenSSL builds
frontegg-david Jul 9, 2025
e7667ce
Ensure all required Perl modules are available for OpenSSL builds
frontegg-david Jul 9, 2025
344351c
Fix CI yaml build
frontegg-david Jul 9, 2025
e0dc909
Fix CI yaml build
frontegg-david Jul 9, 2025
29de217
Fix CI yaml build
frontegg-david Jul 9, 2025
3dc3912
Fix CI yaml build
frontegg-david Jul 9, 2025
cbd4e70
Fix CI yaml build
frontegg-david Jul 9, 2025
75a88fb
Fix CI yaml build
frontegg-david Jul 9, 2025
9988b58
Fix CI yaml build
frontegg-david Jul 9, 2025
e752b58
Merge remote-tracking branch 'origin/master' into patch-1
frontegg-david Jul 9, 2025
fa7f491
Fix CI yaml build
frontegg-david Jul 9, 2025
f4ad01d
Fix CI yaml build
frontegg-david Jul 9, 2025
c3f1a7c
Fix CI yaml build
frontegg-david Jul 9, 2025
eec2d70
Fix CI yaml build
frontegg-david Jul 9, 2025
b0f69c9
Fix v1 history pull
frontegg-david Jul 11, 2025
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
22 changes: 22 additions & 0 deletions BinaryOptionsToolsJs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,26 @@ export declare class PocketOption {
* ```
*/
getCandles(asset: string, period: number, offset: number): Promise<any>
/**
* Retrieves historical candle data for an asset with time
*
* # Arguments
* * `asset` - The trading asset/symbol (e.g., "EUR/USD")
* * `time` - The UNIX timestamp for the start of the candle data
* * `period` - The candle period in seconds
* * `offset` - Time offset for historical data
*
* # Returns
* A JSON string containing the candle data
*
* # Examples
* ```javascript
* const candles = await client.getCandlesAdvanced("EUR/USD", 1751925016, 60, 6000);
* const data = JSON.parse(candles);
* console.log(`Retrieved ${data.length} candles`);
* ```
*/
getCandlesAdvanced(asset: string, time: number, period: number, offset: number): Promise<any>
/**
* Retrieves the current account balance.
*
Expand Down Expand Up @@ -558,6 +578,8 @@ export declare class PocketOption {
* ```
*/
createRawIterator(message: string, validator: Validator, timeout?: number | undefined | null): Promise<RawStreamIterator>
/** Returns the current server time as a UNIX timestamp */
getServerTime(): Promise<number>
}
/**
* A validator for WebSocket messages that provides various matching strategies.
Expand Down
27 changes: 27 additions & 0 deletions BinaryOptionsToolsJs/src/pocketoption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,33 @@ impl PocketOption {
serde_json::to_value(&res).map_err(|e| Error::from_reason(e.to_string()))
}

/// Retrieves historical candle data for an asset with time
///
/// # Arguments
/// * `asset` - The trading asset/symbol (e.g., "EUR/USD")
/// * `time` - The UNIX timestamp for the start of the candle data
/// * `period` - The candle period in seconds
/// * `offset` - Time offset for historical data
///
/// # Returns
/// A JSON string containing the candle data
///
/// # Examples
/// ```javascript
/// const candles = await client.getCandlesAdvanced("EUR/USD", 1751925016, 60, 6000);
/// const data = JSON.parse(candles);
/// console.log(`Retrieved ${data.length} candles`);
/// ```
#[napi]
pub async fn get_candles_advanced(&self, asset: String, time: i64, period: i64, offset: i64) -> Result<Value> {
let res = self
.client
.get_candles_advanced(asset, time, period, offset)
.await
.map_err(|e| Error::from_reason(e.to_string()))?;
serde_json::to_value(&res).map_err(|e| Error::from_reason(e.to_string()))
}

/// Retrieves the current account balance.
///
/// # Returns
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[workspace]
resolver = "2"

exclude = [
"BinaryOptionsToolsJs",
"BinaryOptionsToolsV2"
]

members = [
"crates/binary_options_tools",
"crates/core", "crates/core-pre",
Expand Down
21 changes: 21 additions & 0 deletions crates/binary_options_tools/src/pocketoption/parser/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub enum WebSocketMessage {
GetCandles(LoadHistoryPeriod),

LoadHistoryPeriod(LoadHistoryPeriodResult),
LoadHistoryPeriodFast(LoadHistoryPeriodResult),

UpdateStream(UpdateStream),
UpdateHistoryNew(UpdateHistoryNewFast),

Expand Down Expand Up @@ -101,6 +103,9 @@ impl WebSocketMessage {
if let Ok(stream) = from_str::<UpdateStream>(&data) {
return Self::UpdateStream(stream);
}
if let Ok(stream) = from_str::<LoadHistoryPeriodResult>(&data) {
return Self::LoadHistoryPeriod(stream);
}
}
MessageInfo::UpdateHistoryNew => {
if let Ok(history) = from_str::<UpdateHistoryNewFast>(&data) {
Expand Down Expand Up @@ -177,6 +182,11 @@ impl WebSocketMessage {
return Self::LoadHistoryPeriod(history);
}
}
MessageInfo::LoadHistoryPeriodFast => {
if let Ok(history) = from_str::<LoadHistoryPeriodResult>(&data) {
return Self::LoadHistoryPeriod(history);
}
}
// MessageInfo::UpdateCharts => {
// return Err(PocketOptionError::GeneralParsingError(
// "This is expected, there is no parser for the 'updateCharts' message"
Expand Down Expand Up @@ -240,6 +250,7 @@ impl WebSocketMessage {
Self::UpdateOpenedDeals(_) => MessageInfo::UpdateOpenedDeals,
Self::SubscribeSymbol(_) => MessageInfo::SubscribeSymbol,
Self::LoadHistoryPeriod(_) => MessageInfo::LoadHistoryPeriod,
Self::LoadHistoryPeriodFast(_) => MessageInfo::LoadHistoryPeriodFast,
Self::GetCandles(_) => MessageInfo::GetCandles,
Self::FailOpenOrder(_) => MessageInfo::FailopenOrder,
Self::SuccessupdatePending(_) => MessageInfo::SuccessupdatePending,
Expand Down Expand Up @@ -334,6 +345,16 @@ impl fmt::Display for WebSocketMessage {
serde_json::to_string(&period).map_err(|_| fmt::Error)?
)
}
// 451-["loadHistoryPeriodFast",{"_placeholder":true,"num":0}]
WebSocketMessage::LoadHistoryPeriodFast(period) => {
write!(
f,
"451-[{}, {}]",
serde_json::to_string(&MessageInfo::LoadHistoryPeriod)
.map_err(|_| fmt::Error)?,
serde_json::to_string(&period).map_err(|_| fmt::Error)?
)
}
WebSocketMessage::FailOpenOrder(order) => order.fmt(f),
WebSocketMessage::SuccessupdatePending(pending) => pending.fmt(f),
WebSocketMessage::Subfor(sub) => write!(f, "42[\"subfor\",{}]", sub),
Expand Down
1 change: 1 addition & 0 deletions crates/binary_options_tools/src/pocketoption/types/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum MessageInfo {
// UpdateCharts,
SubscribeSymbol,
LoadHistoryPeriod,
LoadHistoryPeriodFast,
FailopenOrder,
GetCandles,
OpenPendingOrder,
Expand Down
18 changes: 18 additions & 0 deletions crates/binary_options_tools/src/pocketoption/types/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,20 @@ pub struct LoadHistoryPeriodResult {
pub enum Candle {
Raw(RawCandle),
Processed(ProcessedCandle),
ProcessedNew(ProcessedCandleNew),
Update(UpdateCandle),
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ProcessedCandleNew {
symbol_id: i32,
time: i64, // use i64 for timestamp to avoid precision issues
open: f64,
close: f64,
high: f64,
low: f64,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct RawCandle {
asset: String,
Expand Down Expand Up @@ -159,6 +170,13 @@ impl From<&Candle> for DataCandle {
candle.high,
candle.low,
),
Candle::ProcessedNew(candle) => Self::new(
DateTime::from_timestamp(candle.time, 0).expect("REASON"),
candle.open,
candle.close,
candle.high,
candle.low,
),
Candle::Update(candle) => Self::new_price(candle.time, candle.price),
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/core/data/client_enhanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,14 @@ where
))
.await?;
}
"loadHistoryPeriodFast" => {
event_manager
.emit(Event::new(
EventType::Custom("candles_received".to_string()),
event_data.clone(),
))
.await?;
}
_ => {
event_manager
.emit(Event::new(
Expand Down