binaryoptionstoolsv2 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2/BinaryOptionsToolsV2}/BinaryOptionsToolsV2/asyncronous.py +3 -3
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2/BinaryOptionsToolsV2}/BinaryOptionsToolsV2/syncronous.py +4 -5
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/Cargo.lock +7 -7
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/Cargo.toml +4 -4
- {BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/asyncronous.py +3 -3
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/src/pocketoption.rs +2 -2
- {BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/syncronous.py +4 -5
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/PKG-INFO +1 -1
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/api.rs +24 -20
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/basic.rs +9 -13
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/connect.rs +1 -1
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/ssid.rs +15 -14
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/.github/workflows/CI.yml +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/.gitignore +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/BinaryOptionsToolsV2/__init__.py +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/Readme.md +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/__init__.py +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/candles_eurusd_otc.csv +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/src/error.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/src/lib.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/tests/test.py +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/tests/test_sync.py +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/uv.lock +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/Cargo.toml +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/README.md +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/readme.md +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/error.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/general/client.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/general/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/general/traits.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/general/types.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/lib.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/error.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/parser/basic.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/parser/message.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/parser/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/pocket_client.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/base.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/data.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/data_v2.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/info.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/order.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/success.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/update.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/user.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/basic.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/connect.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/location.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/validators.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/listener.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/regions.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/utils/mod.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/utils/tracing.rs +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/assets.txt +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/data.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/load_history_period.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/load_history_period2.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/success_open_order.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/success_update_pending.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/test.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/test_close_order.txt +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/test_demo.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_close_order.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_closed_deals.txt +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_history_new.json +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_opened_deals.txt +0 -0
- {BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/pyproject.toml +0 -0
|
@@ -9,7 +9,7 @@ class PocketOptionAsync:
|
|
|
9
9
|
async def buy(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
10
10
|
"""
|
|
11
11
|
Takes the asset, and amount to place a buy trade that will expire in time (in seconds).
|
|
12
|
-
If check_win is True then the function will return a tuple
|
|
12
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
13
13
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
14
14
|
"""
|
|
15
15
|
(trade_id, trade) = await self.client.buy(asset, amount, time)
|
|
@@ -22,12 +22,12 @@ class PocketOptionAsync:
|
|
|
22
22
|
async def sell(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
23
23
|
"""
|
|
24
24
|
Takes the asset, and amount to place a sell trade that will expire in time (in seconds).
|
|
25
|
-
If check_win is True then the function will return a tuple
|
|
25
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
26
26
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
27
27
|
"""
|
|
28
28
|
(trade_id, trade) = await self.client.sell(asset, amount, time)
|
|
29
29
|
if check_win:
|
|
30
|
-
return await self.check_win(trade_id)
|
|
30
|
+
return trade_id, await self.check_win(trade_id)
|
|
31
31
|
else:
|
|
32
32
|
trade = json.loads(trade)
|
|
33
33
|
return trade_id, trade
|
|
@@ -2,11 +2,11 @@ from BinaryOptionsToolsV2.asyncronous import PocketOptionAsync, async_connect
|
|
|
2
2
|
import asyncio
|
|
3
3
|
|
|
4
4
|
class PocketOption:
|
|
5
|
-
def __init__(self, ssid: str
|
|
5
|
+
def __init__(self, ssid: str):
|
|
6
6
|
"Creates a new instance of the PocketOption class"
|
|
7
7
|
self.loop = asyncio.new_event_loop()
|
|
8
8
|
self._client: PocketOptionAsync = self.loop.run_until_complete(
|
|
9
|
-
async_connect(ssid
|
|
9
|
+
async_connect(ssid)
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
def __del__(self):
|
|
@@ -15,16 +15,15 @@ class PocketOption:
|
|
|
15
15
|
def buy(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
16
16
|
"""
|
|
17
17
|
Takes the asset, and amount to place a buy trade that will expire in time (in seconds).
|
|
18
|
-
If check_win is True then the function will return a tuple
|
|
18
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
19
19
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
20
|
-
future = self.loop.run_in_executor(None, self._client.buy, asset, amount, time, check_win)
|
|
21
20
|
"""
|
|
22
21
|
return self.loop.run_until_complete(self._client.buy(asset, amount, time, check_win))
|
|
23
22
|
|
|
24
23
|
def sell(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
25
24
|
"""
|
|
26
25
|
Takes the asset, and amount to place a sell trade that will expire in time (in seconds).
|
|
27
|
-
If check_win is True then the function will return a tuple
|
|
26
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
28
27
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
29
28
|
"""
|
|
30
29
|
return self.loop.run_until_complete(self._client.sell(asset, amount, time, check_win))
|
|
@@ -4,7 +4,7 @@ version = 3
|
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
6
6
|
name = "BinaryOptionsToolsV2"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
dependencies = [
|
|
9
9
|
"binary-option-tools-core",
|
|
10
10
|
"pyo3",
|
|
@@ -1333,9 +1333,9 @@ dependencies = [
|
|
|
1333
1333
|
|
|
1334
1334
|
[[package]]
|
|
1335
1335
|
name = "serde_json"
|
|
1336
|
-
version = "1.0.
|
|
1336
|
+
version = "1.0.134"
|
|
1337
1337
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1338
|
-
checksum = "
|
|
1338
|
+
checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
|
|
1339
1339
|
dependencies = [
|
|
1340
1340
|
"itoa",
|
|
1341
1341
|
"memchr",
|
|
@@ -1497,18 +1497,18 @@ dependencies = [
|
|
|
1497
1497
|
|
|
1498
1498
|
[[package]]
|
|
1499
1499
|
name = "thiserror"
|
|
1500
|
-
version = "2.0.
|
|
1500
|
+
version = "2.0.9"
|
|
1501
1501
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1502
|
-
checksum = "
|
|
1502
|
+
checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc"
|
|
1503
1503
|
dependencies = [
|
|
1504
1504
|
"thiserror-impl",
|
|
1505
1505
|
]
|
|
1506
1506
|
|
|
1507
1507
|
[[package]]
|
|
1508
1508
|
name = "thiserror-impl"
|
|
1509
|
-
version = "2.0.
|
|
1509
|
+
version = "2.0.9"
|
|
1510
1510
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1511
|
-
checksum = "
|
|
1511
|
+
checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4"
|
|
1512
1512
|
dependencies = [
|
|
1513
1513
|
"proc-macro2",
|
|
1514
1514
|
"quote",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "BinaryOptionsToolsV2"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
description = "A library to connect to PocketOption using python with async and sync support."
|
|
6
6
|
license = "BSD License (BSD)"
|
|
@@ -15,9 +15,9 @@ crate-type = ["cdylib"]
|
|
|
15
15
|
[dependencies]
|
|
16
16
|
pyo3 = "0.21.0"
|
|
17
17
|
|
|
18
|
-
binary-option-tools-core ={ path = "../core" }
|
|
19
|
-
thiserror = "2.0.
|
|
18
|
+
binary-option-tools-core = { path = "../core" }
|
|
19
|
+
thiserror = "2.0.9"
|
|
20
20
|
pyo3-asyncio-0-21 = { version = "0.21.0", features = ["tokio-runtime"] }
|
|
21
21
|
serde = { version = "1.0.216", features = ["derive"] }
|
|
22
|
-
serde_json = "1.0.
|
|
22
|
+
serde_json = "1.0.134"
|
|
23
23
|
uuid = "1.11.0"
|
|
@@ -9,7 +9,7 @@ class PocketOptionAsync:
|
|
|
9
9
|
async def buy(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
10
10
|
"""
|
|
11
11
|
Takes the asset, and amount to place a buy trade that will expire in time (in seconds).
|
|
12
|
-
If check_win is True then the function will return a tuple
|
|
12
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
13
13
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
14
14
|
"""
|
|
15
15
|
(trade_id, trade) = await self.client.buy(asset, amount, time)
|
|
@@ -22,12 +22,12 @@ class PocketOptionAsync:
|
|
|
22
22
|
async def sell(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
23
23
|
"""
|
|
24
24
|
Takes the asset, and amount to place a sell trade that will expire in time (in seconds).
|
|
25
|
-
If check_win is True then the function will return a tuple
|
|
25
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
26
26
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
27
27
|
"""
|
|
28
28
|
(trade_id, trade) = await self.client.sell(asset, amount, time)
|
|
29
29
|
if check_win:
|
|
30
|
-
return await self.check_win(trade_id)
|
|
30
|
+
return trade_id, await self.check_win(trade_id)
|
|
31
31
|
else:
|
|
32
32
|
trade = json.loads(trade)
|
|
33
33
|
return trade_id, trade
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/src/pocketoption.rs
RENAMED
|
@@ -16,9 +16,9 @@ pub struct RawPocketOption {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
#[pyfunction]
|
|
19
|
-
pub fn connect(py: Python, ssid: String
|
|
19
|
+
pub fn connect(py: Python, ssid: String) -> PyResult<Bound<PyAny>> {
|
|
20
20
|
future_into_py(py, async move {
|
|
21
|
-
let client = WebSocketClient::<Handler>::new(ssid
|
|
21
|
+
let client = WebSocketClient::<Handler>::new(ssid).await.map_err(BinaryErrorPy::from)?;
|
|
22
22
|
let pocket_option = RawPocketOption { client: Arc::new(client )};
|
|
23
23
|
Python::with_gil(|py: Python<'_>| Ok(pocket_option.into_py(py)))
|
|
24
24
|
})
|
|
@@ -2,11 +2,11 @@ from BinaryOptionsToolsV2.asyncronous import PocketOptionAsync, async_connect
|
|
|
2
2
|
import asyncio
|
|
3
3
|
|
|
4
4
|
class PocketOption:
|
|
5
|
-
def __init__(self, ssid: str
|
|
5
|
+
def __init__(self, ssid: str):
|
|
6
6
|
"Creates a new instance of the PocketOption class"
|
|
7
7
|
self.loop = asyncio.new_event_loop()
|
|
8
8
|
self._client: PocketOptionAsync = self.loop.run_until_complete(
|
|
9
|
-
async_connect(ssid
|
|
9
|
+
async_connect(ssid)
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
def __del__(self):
|
|
@@ -15,16 +15,15 @@ class PocketOption:
|
|
|
15
15
|
def buy(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
16
16
|
"""
|
|
17
17
|
Takes the asset, and amount to place a buy trade that will expire in time (in seconds).
|
|
18
|
-
If check_win is True then the function will return a tuple
|
|
18
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
19
19
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
20
|
-
future = self.loop.run_in_executor(None, self._client.buy, asset, amount, time, check_win)
|
|
21
20
|
"""
|
|
22
21
|
return self.loop.run_until_complete(self._client.buy(asset, amount, time, check_win))
|
|
23
22
|
|
|
24
23
|
def sell(self, asset: str, amount: float, time: int, check_win: bool = False):
|
|
25
24
|
"""
|
|
26
25
|
Takes the asset, and amount to place a sell trade that will expire in time (in seconds).
|
|
27
|
-
If check_win is True then the function will return a tuple
|
|
26
|
+
If check_win is True then the function will return a tuple containing the trade id and a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)
|
|
28
27
|
If check_win is False then the function will return a tuple with the id of the trade and the trade as a dict
|
|
29
28
|
"""
|
|
30
29
|
return self.loop.run_until_complete(self._client.sell(asset, amount, time, check_win))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: BinaryOptionsToolsV2
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -46,7 +46,7 @@ impl<T: EventListener> WebSocketClient<T> {
|
|
|
46
46
|
amount: f64,
|
|
47
47
|
time: u32,
|
|
48
48
|
) -> PocketResult<(Uuid, Deal)> {
|
|
49
|
-
let order = OpenOrder::call(amount, asset.to_string(), time, self.demo as u32)?;
|
|
49
|
+
let order = OpenOrder::call(amount, asset.to_string(), time, self.ssid.demo() as u32)?;
|
|
50
50
|
let request_id = order.request_id;
|
|
51
51
|
let res = self
|
|
52
52
|
.send_message(
|
|
@@ -70,7 +70,7 @@ impl<T: EventListener> WebSocketClient<T> {
|
|
|
70
70
|
amount: f64,
|
|
71
71
|
time: u32,
|
|
72
72
|
) -> PocketResult<(Uuid, Deal)> {
|
|
73
|
-
let order = OpenOrder::put(amount, asset.to_string(), time, self.demo as u32)?;
|
|
73
|
+
let order = OpenOrder::put(amount, asset.to_string(), time, self.ssid.demo() as u32)?;
|
|
74
74
|
let request_id = order.request_id;
|
|
75
75
|
let res = self
|
|
76
76
|
.send_message(
|
|
@@ -214,8 +214,7 @@ mod tests {
|
|
|
214
214
|
async fn test_websocket_client() -> anyhow::Result<()> {
|
|
215
215
|
tracing_subscriber::fmt::init();
|
|
216
216
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
217
|
-
let
|
|
218
|
-
let client = WebSocketClient::<Handler>::new(ssid, demo).await?;
|
|
217
|
+
let client = WebSocketClient::<Handler>::new(ssid).await?;
|
|
219
218
|
let mut test = 0;
|
|
220
219
|
// let mut threads = Vec::new();
|
|
221
220
|
while test < 1000 {
|
|
@@ -235,8 +234,7 @@ mod tests {
|
|
|
235
234
|
async fn test_all_trades() -> anyhow::Result<()> {
|
|
236
235
|
start_tracing()?;
|
|
237
236
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
238
|
-
let
|
|
239
|
-
let client = Arc::new(WebSocketClient::<Handler>::new(ssid, demo).await?);
|
|
237
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await?);
|
|
240
238
|
// let mut threads = Vec::new();
|
|
241
239
|
let symbols = include_str!("../../../tests/assets.txt")
|
|
242
240
|
.lines()
|
|
@@ -269,8 +267,7 @@ mod tests {
|
|
|
269
267
|
async fn test_force_error() {
|
|
270
268
|
start_tracing().unwrap();
|
|
271
269
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
272
|
-
let
|
|
273
|
-
let client = WebSocketClient::<Handler>::new(ssid, demo).await.unwrap();
|
|
270
|
+
let client = WebSocketClient::<Handler>::new(ssid).await.unwrap();
|
|
274
271
|
let mut loops = 0;
|
|
275
272
|
while loops < 1000 {
|
|
276
273
|
loops += 1;
|
|
@@ -283,8 +280,7 @@ mod tests {
|
|
|
283
280
|
async fn test_incorrect_asset_name() {
|
|
284
281
|
start_tracing().unwrap();
|
|
285
282
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
286
|
-
let
|
|
287
|
-
let client = WebSocketClient::<Handler>::new(ssid, demo).await.unwrap();
|
|
283
|
+
let client = WebSocketClient::<Handler>::new(ssid).await.unwrap();
|
|
288
284
|
|
|
289
285
|
client.sell("EUReUSD_otc", 1.0, 60).await.unwrap();
|
|
290
286
|
}
|
|
@@ -293,8 +289,7 @@ mod tests {
|
|
|
293
289
|
async fn test_check_win() -> anyhow::Result<()> {
|
|
294
290
|
start_tracing()?;
|
|
295
291
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
296
|
-
let
|
|
297
|
-
let client = Arc::new(WebSocketClient::<Handler>::new(ssid, demo).await.unwrap());
|
|
292
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await.unwrap());
|
|
298
293
|
let mut test = 0;
|
|
299
294
|
let mut checks = Vec::new();
|
|
300
295
|
while test < 1000 {
|
|
@@ -324,9 +319,8 @@ mod tests {
|
|
|
324
319
|
async fn test_get_candles() -> anyhow::Result<()> {
|
|
325
320
|
start_tracing()?;
|
|
326
321
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
327
|
-
let demo = true;
|
|
328
322
|
// time: 1733040000, offset: 540000, period: 3600
|
|
329
|
-
let client = Arc::new(WebSocketClient::<Handler>::new(ssid
|
|
323
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await.unwrap());
|
|
330
324
|
sleep(Duration::from_secs(5)).await;
|
|
331
325
|
let candles = client.get_candles("EURUSD", 60, 6000).await?;
|
|
332
326
|
dbg!(candles);
|
|
@@ -337,8 +331,7 @@ mod tests {
|
|
|
337
331
|
async fn test_get_closed_orders() -> anyhow::Result<()> {
|
|
338
332
|
start_tracing()?;
|
|
339
333
|
let ssid = r#"42["auth",{"session":"t0mc6nefcv7ncr21g4fmtioidb","isDemo":1,"uid":90000798,"platform":2}] "#;
|
|
340
|
-
let
|
|
341
|
-
let client = Arc::new(WebSocketClient::<Handler>::new(ssid, demo).await?);
|
|
334
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await?);
|
|
342
335
|
// let file = File::options().append(true).open("tes")
|
|
343
336
|
let mut ids = Vec::new();
|
|
344
337
|
let mut tasks: Vec<JoinHandle<PocketResult<()>>> = Vec::new();
|
|
@@ -374,8 +367,7 @@ mod tests {
|
|
|
374
367
|
async fn test_get_open_orders() -> anyhow::Result<()> {
|
|
375
368
|
start_tracing()?;
|
|
376
369
|
let ssid = r#"42["auth",{"session":"looc69ct294h546o368s0lct7d","isDemo":1,"uid":87742848,"platform":2}] "#;
|
|
377
|
-
let
|
|
378
|
-
let client = Arc::new(WebSocketClient::<Handler>::new(ssid, demo).await?);
|
|
370
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await?);
|
|
379
371
|
let original_orders = client.get_opened_deals().await;
|
|
380
372
|
// let file = File::options().append(true).open("tes")
|
|
381
373
|
let mut ids = Vec::new();
|
|
@@ -408,8 +400,20 @@ mod tests {
|
|
|
408
400
|
async fn test_real_account() -> anyhow::Result<()> {
|
|
409
401
|
start_tracing()?;
|
|
410
402
|
let ssid = r#"42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"b718d584d524ee1bac02ef2ad56bbcc1\";s:10:\"ip_address\";s:14:\"191.113.153.59\";s:10:\"user_agent\";s:120:\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.\";s:13:\"last_activity\";i:1734375340;}a7ae2d152460e813f196b3a01636c13a","isDemo":0,"uid":87742848,"platform":2}] "#;
|
|
411
|
-
let
|
|
412
|
-
|
|
403
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await?);
|
|
404
|
+
sleep(Duration::from_secs(10)).await;
|
|
405
|
+
dbg!(client.get_balande().await);
|
|
406
|
+
let candles = client.get_candles("EURUSD_otc", 60, 3600).await?;
|
|
407
|
+
dbg!(&candles);
|
|
408
|
+
dbg!("Candles length: {}", candles.len()); // 4172
|
|
409
|
+
Ok(())
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
#[tokio::test]
|
|
413
|
+
async fn test_real_ssid_on_demo() -> anyhow::Result<()> {
|
|
414
|
+
start_tracing()?;
|
|
415
|
+
let ssid = r#"42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"b718d584d524ee1bac02ef2ad56bbcc1\";s:10:\"ip_address\";s:14:\"191.113.153.59\";s:10:\"user_agent\";s:120:\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.\";s:13:\"last_activity\";i:1734375340;}a7ae2d152460e813f196b3a01636c13a","isDemo":0,"uid":87742848,"platform":2}] "#;
|
|
416
|
+
let client = Arc::new(WebSocketClient::<Handler>::new(ssid).await?);
|
|
413
417
|
sleep(Duration::from_secs(10)).await;
|
|
414
418
|
dbg!(client.get_balande().await);
|
|
415
419
|
let candles = client.get_candles("EURUSD_otc", 60, 3600).await?;
|
|
@@ -31,7 +31,6 @@ const SLEEP_INTERVAL: u32 = 2;
|
|
|
31
31
|
|
|
32
32
|
pub struct WebSocketClient<T: EventListener> {
|
|
33
33
|
pub ssid: Ssid,
|
|
34
|
-
pub demo: bool,
|
|
35
34
|
pub handler: T,
|
|
36
35
|
// pub balance: UpdateBalance
|
|
37
36
|
pub data: Data,
|
|
@@ -40,22 +39,21 @@ pub struct WebSocketClient<T: EventListener> {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
impl<T: EventListener> WebSocketClient<T> {
|
|
43
|
-
pub async fn new(ssid: impl ToString
|
|
42
|
+
pub async fn new(ssid: impl ToString) -> PocketResult<WebSocketClient<Handler>> {
|
|
44
43
|
let handler = Handler::new(Ssid::parse(ssid.to_string().clone())?);
|
|
45
|
-
WebSocketClient::init(ssid,
|
|
44
|
+
WebSocketClient::init(ssid, handler).await
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
pub async fn init(ssid: impl ToString,
|
|
47
|
+
pub async fn init(ssid: impl ToString, handler: T) -> PocketResult<Self> {
|
|
49
48
|
let ssid = Ssid::parse(ssid)?;
|
|
50
|
-
let _connection = Self::connect(ssid.clone()
|
|
49
|
+
let _connection = Self::connect(ssid.clone()).await?;
|
|
51
50
|
let data = Data::default();
|
|
52
51
|
let (_event_loop, sender) =
|
|
53
|
-
Self::start_loops(handler.clone(), ssid.clone(),
|
|
52
|
+
Self::start_loops(handler.clone(), ssid.clone(), data.clone()).await?;
|
|
54
53
|
println!("Initialized");
|
|
55
54
|
sleep(Duration::from_millis(500)).await;
|
|
56
55
|
Ok(Self {
|
|
57
56
|
ssid,
|
|
58
|
-
demo,
|
|
59
57
|
handler,
|
|
60
58
|
data,
|
|
61
59
|
sender,
|
|
@@ -65,9 +63,8 @@ impl<T: EventListener> WebSocketClient<T> {
|
|
|
65
63
|
|
|
66
64
|
pub async fn connect(
|
|
67
65
|
ssid: Ssid,
|
|
68
|
-
demo: bool,
|
|
69
66
|
) -> PocketResult<WebSocketStream<MaybeTlsStream<TcpStream>>> {
|
|
70
|
-
let urls = ssid.servers(
|
|
67
|
+
let urls = ssid.servers().await?;
|
|
71
68
|
let mut error = None;
|
|
72
69
|
for url in urls.clone() {
|
|
73
70
|
match try_connect(ssid.clone(), url).await {
|
|
@@ -90,10 +87,9 @@ impl<T: EventListener> WebSocketClient<T> {
|
|
|
90
87
|
async fn start_loops(
|
|
91
88
|
handler: T,
|
|
92
89
|
ssid: Ssid,
|
|
93
|
-
demo: bool,
|
|
94
90
|
data: Data,
|
|
95
91
|
) -> PocketResult<(JoinHandle<()>, Sender<WebSocketMessage>)> {
|
|
96
|
-
let (mut write, mut read) = WebSocketClient::<T>::connect(ssid.clone()
|
|
92
|
+
let (mut write, mut read) = WebSocketClient::<T>::connect(ssid.clone())
|
|
97
93
|
.await?
|
|
98
94
|
.split();
|
|
99
95
|
let (sender, mut reciever) = tokio::sync::mpsc::channel(128);
|
|
@@ -118,7 +114,7 @@ impl<T: EventListener> WebSocketClient<T> {
|
|
|
118
114
|
match try_join3(listener_future, sender_future, update_loop).await {
|
|
119
115
|
Ok(_) => {
|
|
120
116
|
if let Ok(websocket) =
|
|
121
|
-
WebSocketClient::<T>::connect(ssid.clone()
|
|
117
|
+
WebSocketClient::<T>::connect(ssid.clone()).await
|
|
122
118
|
{
|
|
123
119
|
(write, read) = websocket.split();
|
|
124
120
|
info!("Reconnected successfully!");
|
|
@@ -134,7 +130,7 @@ impl<T: EventListener> WebSocketClient<T> {
|
|
|
134
130
|
Err(e) => {
|
|
135
131
|
warn!("Error in event loop, {e}, reconnecting...");
|
|
136
132
|
if let Ok(websocket) =
|
|
137
|
-
WebSocketClient::<T>::connect(ssid.clone()
|
|
133
|
+
WebSocketClient::<T>::connect(ssid.clone()).await
|
|
138
134
|
{
|
|
139
135
|
(write, read) = websocket.split();
|
|
140
136
|
info!("Reconnected successfully!");
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/connect.rs
RENAMED
|
@@ -29,7 +29,7 @@ impl Connect for PocketConnect {
|
|
|
29
29
|
|
|
30
30
|
let connector = Connector::NativeTls(tls_connector);
|
|
31
31
|
|
|
32
|
-
let url = creds.server(
|
|
32
|
+
let url = creds.server().await?;
|
|
33
33
|
let user_agent = creds.user_agent();
|
|
34
34
|
let t_url = Url::parse(&url).map_err(|e| {
|
|
35
35
|
BinaryOptionsToolsError::GeneralParsingError(format!("Error getting host, {e}"))
|
|
@@ -82,23 +82,17 @@ impl Ssid {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
pub async fn server(&self
|
|
86
|
-
match
|
|
87
|
-
(_
|
|
88
|
-
|
|
89
|
-
"Could not connect to real server while using a demo SSID".into(),
|
|
90
|
-
)),
|
|
91
|
-
_ => Regions.get_server().await.map(|s| s.to_string()),
|
|
85
|
+
pub async fn server(&self) -> PocketResult<String> {
|
|
86
|
+
match self {
|
|
87
|
+
Self::Demo(_) => Ok(Regions::DEMO.to_string()),
|
|
88
|
+
Self::Real(_) => Regions.get_server().await.map(|s| s.to_string()),
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
pub async fn servers(&self
|
|
96
|
-
match
|
|
97
|
-
(_
|
|
98
|
-
|
|
99
|
-
"Could not connect to real server while using a demo SSID".into(),
|
|
100
|
-
)),
|
|
101
|
-
_ => Ok(Regions
|
|
92
|
+
pub async fn servers(&self) -> PocketResult<Vec<String>> {
|
|
93
|
+
match self {
|
|
94
|
+
Self::Demo(_) => Ok(vec![Regions::DEMO.to_string()]),
|
|
95
|
+
Self::Real(_) => Ok(Regions
|
|
102
96
|
.get_servers()
|
|
103
97
|
.await?
|
|
104
98
|
.iter()
|
|
@@ -113,6 +107,13 @@ impl Ssid {
|
|
|
113
107
|
Self::Real(real) => real.session.user_agent.clone()
|
|
114
108
|
}
|
|
115
109
|
}
|
|
110
|
+
|
|
111
|
+
pub fn demo(&self) -> bool {
|
|
112
|
+
match self {
|
|
113
|
+
Self::Demo(_) => true,
|
|
114
|
+
Self::Real(_) => false,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
116
117
|
}
|
|
117
118
|
impl fmt::Display for Demo {
|
|
118
119
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/tests/test.py
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/BinaryOptionsToolsV2/tests/test_sync.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/parser/basic.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/parser/message.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/parser/mod.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/pocket_client.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/base.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/data.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/data_v2.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/info.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/mod.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/order.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/success.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/update.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/types/user.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/basic.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/connect.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/location.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/utils/mod.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/validators.rs
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/listener.rs
RENAMED
|
File without changes
|
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/src/pocketoption/ws/regions.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/load_history_period.json
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/load_history_period2.json
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/success_open_order.json
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/success_update_pending.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_close_order.json
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_closed_deals.txt
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_history_new.json
RENAMED
|
File without changes
|
{BinaryOptionsToolsV2-0.1.0 → BinaryOptionsToolsV2-0.1.2}/core/tests/update_opened_deals.txt
RENAMED
|
File without changes
|
|
File without changes
|