Skip to content

Commit d31cfba

Browse files
authored
Merge pull request #112 from sixtysixx/master
various fixes
2 parents 4bfa35d + 20da1d8 commit d31cfba

35 files changed

Lines changed: 1087 additions & 734 deletions

.github/workflows/CI.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,38 @@ jobs:
8585
strategy:
8686
fail-fast: false
8787
matrix:
88-
target: [x64, x86]
88+
include:
89+
- target: x86_64-pc-windows-msvc
90+
arch: x64
91+
- target: i686-pc-windows-msvc
92+
arch: x86
93+
env:
94+
RUSTC_WRAPPER: "" # Disable sccache for Windows
95+
SCCACHE_GHA_ENABLED: "false"
8996
steps:
9097
- uses: actions/checkout@v4
91-
- name: Run sccache-cache
92-
uses: mozilla/sccache-action@v0.0.6
98+
with:
99+
persist-credentials: false
100+
# Disable sccache for windows due to potential cross-compilation issues
101+
# - name: Run sccache-cache
102+
# uses: mozilla/sccache-action@v0.0.6
93103
- uses: actions/setup-python@v5
104+
id: setup-python
94105
with:
95106
python-version: "3.13.12"
96-
architecture: ${{ matrix.target }}
107+
architecture: ${{ matrix.arch }}
97108
- name: Build wheels
98109
uses: PyO3/maturin-action@v1
110+
env:
111+
PYO3_PYTHON: ${{ steps.setup-python.outputs.python-path }}
99112
with:
100113
target: ${{ matrix.target }}
101-
args: --release --strip --out dist -i python3.13
114+
args: --release --strip --out dist -i "${{ steps.setup-python.outputs.python-path }}"
102115
working-directory: python
103116
- name: Upload wheels
104117
uses: actions/upload-artifact@v4
105118
with:
106-
name: wheels-windows-${{ matrix.target }}
119+
name: wheels-windows-${{ matrix.arch }}
107120
path: python/dist
108121

109122
# --- 3. MACOS BUILD ---

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ Install directly from our GitHub releases. Supports **Python 3.9 - 3.12**.
121121
**Windows**
122122

123123
```bash
124-
pip install "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/releases/download/v0.2.9/binaryoptionstoolsv2-0.2.9-cp39-abi3-win_amd64.whl"
124+
pip install "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/releases/download/v0.2.11/binaryoptionstoolsv2-0.2.11-cp39-abi3-win_amd64.whl"
125125
```
126126

127127
**Linux**
128128

129129
```bash
130-
pip install "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/releases/download/v0.2.9/binaryoptionstoolsv2-0.2.9-cp39-abi3-manylinux_2_28_x86_64.whl"
130+
pip install "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/releases/download/v0.2.11/binaryoptionstoolsv2-0.2.11-cp39-abi3-manylinux_2_28_x86_64.whl"
131131
```
132132

133133
**macOS (Apple Silicon)**
134134

135135
```bash
136-
pip install "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/releases/download/v0.2.9/binaryoptionstoolsv2-0.2.9-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl"
136+
pip install "https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/releases/download/v0.2.11/binaryoptionstoolsv2-0.2.11-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl"
137137
```
138138

139139
#### Option B: Build from Source

codemap.md

Lines changed: 65 additions & 65 deletions
Large diffs are not rendered by default.

crates/binary_options_tools/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ chrono = { workspace = true }
2020
# binary-options-tools-core = { path = "../core", version = "0.2.0" }
2121
# trading-macros = { path = "../macros" }
2222
futures-util = { workspace = true }
23-
reqwest = { version = "0.13.4", default-features = false, features = ["rustls-tls", "json"] }
23+
reqwest = { version = "0.13.4", default-features = false, features = ["rustls-no-provider", "json"] }
2424
serde = { workspace = true }
2525
serde_json = { workspace = true }
2626
tokio = { workspace = true }

crates/binary_options_tools/examples/pending_trades_example.rs

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use binary_options_tools::pocketoption::{
2828
error::PocketResult,
2929
ssid::{Demo, Ssid},
3030
state::{State, StateBuilder},
31-
types::PendingOrder,
31+
types::{PendingOrder, OpenPendingOrder},
3232
};
3333
use binary_options_tools_core::reimports::Message;
3434
use binary_options_tools_core::traits::{ApiModule, RunnerCommand};
@@ -154,16 +154,16 @@ async fn example_basic_pending_order() -> PocketResult<()> {
154154
});
155155

156156
let result = client_handle
157-
.open_pending_order(
158-
1, // open_type: 1 = typical for binary options
159-
Decimal::from_f64_retain(100.0).unwrap(), // amount
160-
"EURUSD_otc".to_string(), // asset (OTC EUR/USD)
161-
"2026-04-07 22:50:00".to_string(), // open_time: specific trigger time (for openType 0) or expiration (for openType 1)
162-
Decimal::from_f64_retain(1.1950).unwrap(), // open_price: current market price
163-
60, // timeframe: 60 seconds
164-
85, // min_payout: 85% minimum payout
165-
0, // command: 0 (typically for buy/call)
166-
)
157+
.open_pending_order(OpenPendingOrder {
158+
open_type: 1, // open_type: 1 = typical for binary options
159+
amount: Decimal::from_f64_retain(100.0).unwrap(), // amount
160+
asset: "EURUSD_otc".to_string(), // asset (OTC EUR/USD)
161+
open_time: "2026-04-07 22:50:00".to_string(), // open_time: specific trigger time (for openType 0) or expiration (for openType 1)
162+
open_price: Decimal::from_f64_retain(1.1950).unwrap(), // open_price: current market price
163+
timeframe: 60, // timeframe: 60 seconds
164+
min_payout: 85, // min_payout: 85% minimum payout
165+
command: 0, // command: 0 (typically for buy/call)
166+
})
167167
.await;
168168

169169
// 7. Handle the result
@@ -262,16 +262,16 @@ async fn example_concurrent_pending_orders() -> PocketResult<()> {
262262

263263
let order_fut = tokio::spawn(async move {
264264
handle_clone2
265-
.open_pending_order(
266-
1,
267-
amount2,
268-
asset2,
269-
"2026-04-07 22:50:00".to_string(),
270-
Decimal::from_f64_retain(1.0).unwrap(),
271-
60,
272-
85,
273-
0,
274-
)
265+
.open_pending_order(OpenPendingOrder {
266+
open_type: 1,
267+
amount: amount2,
268+
asset: asset2,
269+
open_time: "2026-04-07 22:50:00".to_string(),
270+
open_price: Decimal::from_f64_retain(1.0).unwrap(),
271+
timeframe: 60,
272+
min_payout: 85,
273+
command: 0,
274+
})
275275
.await
276276
});
277277

@@ -456,16 +456,16 @@ async fn example_integration_with_pocketclient() -> PocketResult<()> {
456456

457457
let order_result = timeout(
458458
Duration::from_secs(30),
459-
pending_trades_handle.open_pending_order(
460-
1,
461-
Decimal::from_f64_retain(250.0).unwrap(),
462-
"EURUSD_otc".to_string(),
463-
"2026-04-07 22:50:00".to_string(),
464-
Decimal::from_f64_retain(1.1850).unwrap(),
465-
60,
466-
90,
467-
0,
468-
),
459+
pending_trades_handle.open_pending_order(OpenPendingOrder {
460+
open_type: 1,
461+
amount: Decimal::from_f64_retain(250.0).unwrap(),
462+
asset: "EURUSD_otc".to_string(),
463+
open_time: "2026-04-07 22:50:00".to_string(),
464+
open_price: Decimal::from_f64_retain(1.1850).unwrap(),
465+
timeframe: 60,
466+
min_payout: 90,
467+
command: 0,
468+
}),
469469
)
470470
.await;
471471

@@ -537,8 +537,16 @@ async fn scenario1_mismatched_responses() -> PocketResult<()> {
537537
});
538538

539539
println!("Waiting for order (should handle mismatches)...");
540-
// This might still fail if the module's matching logic is strict, but it demonstrates the retry loop
541-
let _ = client_handle.open_pending_order(1, dec!(100), "EURUSD_otc".into(), "2026-04-07 22:50:00".into(), dec!(1.1950), 60, 85, 0).await;
540+
let _ = client_handle.open_pending_order(OpenPendingOrder {
541+
open_type: 1,
542+
amount: dec!(100),
543+
asset: "EURUSD_otc".into(),
544+
open_time: "2026-04-07 22:50:00".into(),
545+
open_price: dec!(1.1950),
546+
timeframe: 60,
547+
min_payout: 85,
548+
command: 0,
549+
}).await;
542550

543551
module_task.abort();
544552
Ok(())
@@ -567,7 +575,16 @@ async fn scenario3_timeout() -> PocketResult<()> {
567575
let module_task = tokio::spawn(async move { module.run().await.ok() });
568576

569577
println!("Requesting order with no server response (expect timeout)...");
570-
let result = timeout(Duration::from_secs(2), client_handle.open_pending_order(1, dec!(100), "EURUSD_otc".into(), "2026-04-07 22:50:00".into(), dec!(1.1950), 60, 85, 0)).await;
578+
let result = timeout(Duration::from_secs(2), client_handle.open_pending_order(OpenPendingOrder {
579+
open_type: 1,
580+
amount: dec!(100),
581+
asset: "EURUSD_otc".into(),
582+
open_time: "2026-04-07 22:50:00".into(),
583+
open_price: dec!(1.1950),
584+
timeframe: 60,
585+
min_payout: 85,
586+
command: 0,
587+
})).await;
571588

572589
match result {
573590
Err(_) => println!("✓ Correctly timed out!"),

crates/binary_options_tools/examples/test_demo.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
112112
}
113113

114114
println!("\n=== Test 4: Custom max_subscriptions ===");
115-
let mut config = Config::default();
116-
config.max_subscriptions = 8;
115+
let config = Config {
116+
max_subscriptions: 8,
117+
..Default::default()
118+
};
117119
let client2 = PocketOption::new_with_config(&ssid, config).await?;
118120
tokio::time::sleep(Duration::from_secs(3)).await;
119121

crates/binary_options_tools/src/expertoptions/modules/profile.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ impl ApiModule<State> for ProfileModule {
304304
) -> CoreResult<()> {
305305
// On reconnect, re-send multipleAction and ensure context if demo
306306
let token = state.token.clone();
307-
let timezone = state.timezone.read().await;
308-
let multi = multiple_action_action(token.clone(), *timezone)?.to_message()?;
307+
let timezone = *state.timezone.read().await;
308+
let multi = multiple_action_action(token.clone(), timezone)?.to_message()?;
309309
ws_sender.send(multi).await?;
310310
if state.is_demo().await {
311311
let demo = Demo::new(true);
@@ -325,10 +325,12 @@ impl ApiModule<State> for ProfileModule {
325325
impl ProfileModule {
326326
async fn send_startup_messages(&self) -> CoreResult<()> {
327327
let token = self.state.token.clone();
328-
let timezone = self.state.timezone.read().await;
328+
let timezone = *self.state.timezone.read().await;
329329
// Ensure demo context if currently demo
330-
if dbg!(self.state.is_demo().await) {
331-
dbg!("Sent demo message");
330+
let is_demo = self.state.is_demo().await;
331+
debug!("Current demo state: {}", is_demo);
332+
if is_demo {
333+
debug!("Sending demo context startup message");
332334
let demo = Demo::new(true);
333335
let msg = demo
334336
.action(token.clone())
@@ -337,7 +339,7 @@ impl ProfileModule {
337339
self.ws_sender.send(msg).await?;
338340
}
339341
// Send multipleAction with basic actions placeholder (can be extended)
340-
let multi = multiple_action_action(token, *timezone)?.to_message()?;
342+
let multi = multiple_action_action(token, timezone)?.to_message()?;
341343
self.ws_sender.send(multi).await?;
342344
Ok(())
343345
}

crates/binary_options_tools/src/expertoptions/state.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use binary_options_tools_core::traits::AppState;
22
use chrono::Local;
33
use rust_decimal::{dec, Decimal};
44
use tokio::sync::RwLock;
5+
use tracing::info;
56

67
use crate::expertoptions::{modules::profile::Demo, types::Assets};
78

@@ -57,7 +58,7 @@ impl AppState for State {
5758
impl State {
5859
pub fn new(token: String, demo: bool) -> Self {
5960
let timezone = Local::now().offset().local_minus_utc().div_euclid(60);
60-
dbg!(timezone);
61+
info!("Timezone offset: {}", timezone);
6162
State {
6263
token,
6364
balance: RwLock::new(None),

crates/binary_options_tools/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub mod error;
3131
pub mod expertoptions;
3232
pub mod framework;
3333
pub mod pocketoption;
34-
pub mod reimports;
3534
pub mod traits;
3635
pub mod utils;
3736
pub mod validator;
@@ -49,7 +48,7 @@ mod tests {
4948
use tokio::time::sleep;
5049
use tracing::debug;
5150

52-
use binary_options_tools_macros::{deserialize, serialize, timeout};
51+
use binary_options_tools_macros::timeout;
5352
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
5453
struct Test {
5554
name: String,
@@ -60,8 +59,8 @@ mod tests {
6059
let test = Test {
6160
name: "Test".to_string(),
6261
};
63-
let test_str = serialize!(&test).unwrap();
64-
let test2 = deserialize!(Test, &test_str).unwrap();
62+
let test_str = serde_json::to_string(&test).unwrap();
63+
let test2 = serde_json::from_str::<Test>(&test_str).unwrap();
6564
assert_eq!(test, test2)
6665
}
6766

crates/binary_options_tools/src/pocketoption/modules/pending_trades.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,7 @@ impl PendingTradesHandle {
121121
/// Creates a new pending order on the PocketOption platform.
122122
pub async fn open_pending_order(
123123
&self,
124-
open_type: u32,
125-
amount: Decimal,
126-
asset: String,
127-
open_time: String,
128-
open_price: Decimal,
129-
timeframe: u32,
130-
min_payout: u32,
131-
command: u32,
124+
order: OpenPendingOrder,
132125
) -> PocketResult<PendingOrder> {
133126
let _lock = self.call_lock.lock().await;
134127

@@ -138,11 +131,22 @@ impl PendingTradesHandle {
138131
}
139132

140133
let id = Uuid::new_v4();
134+
let OpenPendingOrder {
135+
open_type,
136+
amount,
137+
asset: order_asset,
138+
open_time,
139+
open_price,
140+
timeframe,
141+
min_payout,
142+
command,
143+
} = order;
144+
let asset = order_asset.clone();
141145
self.sender
142146
.send(Command::OpenPendingOrder {
143147
open_type,
144148
amount,
145-
asset: asset.clone(),
149+
asset: order_asset,
146150
open_time,
147151
open_price,
148152
timeframe,

0 commit comments

Comments
 (0)