binaryoptionstoolsv2 0.1.0__cp310-none-win_amd64.whl

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.
@@ -0,0 +1,8 @@
1
+ from .BinaryOptionsToolsV2 import * # noqa: F403
2
+ from .BinaryOptionsToolsV2 import __all__
3
+
4
+ # optional: include the documentation from the Rust module
5
+ from .BinaryOptionsToolsV2 import __doc__ # noqa: F401
6
+ from . import asyncronous
7
+ from . import syncronous
8
+ __all__ = __all__ + ["asyncronous", "syncronous"]
@@ -0,0 +1,85 @@
1
+ from BinaryOptionsToolsV2 import connect, RawPocketOption
2
+ import json
3
+
4
+ # This file contains all the async code for the PocketOption Module
5
+ class PocketOptionAsync:
6
+ def __init__(self, client: RawPocketOption):
7
+ self.client = client
8
+
9
+ async def buy(self, asset: str, amount: float, time: int, check_win: bool = False):
10
+ """
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 with the result of the trade ("win", "loss", "draw") and the trade as a dict
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
+ """
15
+ (trade_id, trade) = await self.client.buy(asset, amount, time)
16
+ if check_win:
17
+ return await self.check_win(trade_id)
18
+ else:
19
+ trade = json.loads(trade)
20
+ return trade_id, trade
21
+
22
+ async def sell(self, asset: str, amount: float, time: int, check_win: bool = False):
23
+ """
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 with the result of the trade ("win", "loss", "draw") and the trade as a dict
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
+ """
28
+ (trade_id, trade) = await self.client.sell(asset, amount, time)
29
+ if check_win:
30
+ return await self.check_win(trade_id)
31
+ else:
32
+ trade = json.loads(trade)
33
+ return trade_id, trade
34
+
35
+ async def check_win(self, id: str):
36
+ """Returns a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)"""
37
+ trade = await self.client.check_win(id)
38
+ trade = json.loads(trade)
39
+ win = trade["profit"]
40
+ if win > 0:
41
+ trade["result"] = "win"
42
+ elif win == 0:
43
+ trade["result"] = "draw"
44
+ else:
45
+ trade["result"] = "loss"
46
+ return trade
47
+
48
+ async def get_candles(self, asset: str, period: int, offset: int):
49
+ """
50
+ Takes the asset you want to get the candles and return a list of raw candles in dictionary format
51
+ Each candle contains:
52
+ * time: using the iso format
53
+ * open: open price
54
+ * close: close price
55
+ * high: highest price
56
+ * low: lowest price
57
+ """
58
+ candles = await self.client.get_candles(asset, period, offset)
59
+ return json.loads(candles)
60
+
61
+ async def balance(self):
62
+ "Returns the balance of the account"
63
+ return json.loads(await self.client.balance())["balance"]
64
+
65
+ async def opened_deals(self):
66
+ "Returns a list of all the opened deals as dictionaries"
67
+ return json.loads(await self.client.opened_deals())
68
+
69
+ async def closed_deals(self):
70
+ "Returns a list of all the closed deals as dictionaries"
71
+ return json.loads(await self.client.closed_deals())
72
+
73
+ async def payout(self, asset: None | str | list[str] = None):
74
+ "Returns a dict of asset : payout for each asset, if 'asset' is not None then it will return the payout of the asset or a list of the payouts for each asset it was passed"
75
+ payout = json.loads(await self.client.payout())
76
+ if isinstance(asset, str):
77
+ return payout.get(asset)
78
+ elif isinstance(asset, list):
79
+ return [payout.get(ast) for ast in asset]
80
+ return payout
81
+
82
+ async def async_connect(ssid: str, demo: bool) -> PocketOptionAsync:
83
+ "Use this function to connect to the server, this works as the initialization for the `PocketOptionAsync` class"
84
+ client = await connect(ssid, demo)
85
+ return PocketOptionAsync(client)
@@ -0,0 +1,62 @@
1
+ from BinaryOptionsToolsV2.asyncronous import PocketOptionAsync, async_connect
2
+ import asyncio
3
+
4
+ class PocketOption:
5
+ def __init__(self, ssid: str, demo: bool):
6
+ "Creates a new instance of the PocketOption class"
7
+ self.loop = asyncio.new_event_loop()
8
+ self._client: PocketOptionAsync = self.loop.run_until_complete(
9
+ async_connect(ssid, demo)
10
+ )
11
+
12
+ def __del__(self):
13
+ self.loop.close()
14
+
15
+ def buy(self, asset: str, amount: float, time: int, check_win: bool = False):
16
+ """
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 with the result of the trade ("win", "loss", "draw") and the trade as a dict
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
+ """
22
+ return self.loop.run_until_complete(self._client.buy(asset, amount, time, check_win))
23
+
24
+ def sell(self, asset: str, amount: float, time: int, check_win: bool = False):
25
+ """
26
+ 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 with the result of the trade ("win", "loss", "draw") and the trade as a dict
28
+ 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
+ """
30
+ return self.loop.run_until_complete(self._client.sell(asset, amount, time, check_win))
31
+
32
+ def check_win(self, id: str):
33
+ """Returns a dictionary containing the trade data and the result of the trade ("win", "draw", "loss)"""
34
+ return self.loop.run_in_executor(self._client.check_win(id))
35
+
36
+ def get_candles(self, asset: str, period: int, offset: int):
37
+ """
38
+ Takes the asset you want to get the candles and return a list of raw candles in dictionary format
39
+ Each candle contains:
40
+ * time: using the iso format
41
+ * open: open price
42
+ * close: close price
43
+ * high: highest price
44
+ * low: lowest price
45
+ """
46
+ return self.loop.run_until_complete(self._client.get_candles(asset, period, offset))
47
+
48
+ def balance(self):
49
+ "Returns the balance of the account"
50
+ return self.loop.run_until_complete(self._client.balance())
51
+
52
+ def opened_deals(self):
53
+ "Returns a list of all the opened deals as dictionaries"
54
+ return self.loop.run_until_complete(self._client.opened_deals())
55
+
56
+ def closed_deals(self):
57
+ "Returns a list of all the closed deals as dictionaries"
58
+ return self.loop.run_until_complete(self._client.closed_deals())
59
+
60
+ def payout(self, asset: None | str | list[str] = None):
61
+ "Returns a dict of asset | payout for each asset, if 'asset' is not None then it will return the payout of the asset or a list of the payouts for each asset it was passed"
62
+ return self.loop.run_until_complete(self._client.payout(asset))
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.3
2
+ Name: BinaryOptionsToolsV2
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Summary: A library to connect to PocketOption using python with async and sync support.
8
+ Home-Page: https://github.com/ChipaDevTeam/BinaryOptionsTools-v2
9
+ License: BSD License (BSD)
10
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
11
+
12
+ 👉 [Join us on Discord](https://discord.gg/T3FGXcmd)
13
+ # BinaryOptionsTools
14
+
15
+ **BinaryOptionsTools** is a powerful suite of tools designed to enhance your binary options trading experience. Whether you're looking for analysis, strategy optimization, or execution tools, this project provides a variety of solutions to help you make informed trading decisions.
16
+
@@ -0,0 +1,7 @@
1
+ BinaryOptionsToolsV2-0.1.0.dist-info/METADATA,sha256=-oXIaiXgeWRe_5JpjUYU7DFkLtoVt_7Gebd0IyALHq0,859
2
+ BinaryOptionsToolsV2-0.1.0.dist-info/WHEEL,sha256=WdQznVppN7z1Vmr3uommICdFQ8BTH-_snRK0jTnZY7g,95
3
+ BinaryOptionsToolsV2/asyncronous.py,sha256=kC3-i1Hz8lSYhCVKt70r8_0Iq-5jlKZHlRBxIuYkjuY,3955
4
+ BinaryOptionsToolsV2/syncronous.py,sha256=TZgPqcDixdxIQCjQVS2o1EFm-vS8_4hb9mjvRa0k2BA,3236
5
+ BinaryOptionsToolsV2/__init__.py,sha256=QZyZtpaxGwlQBFjmrCCE0TxB2oFCKDEBcyShTh7BiGI,317
6
+ BinaryOptionsToolsV2/BinaryOptionsToolsV2.cp310-win_amd64.pyd,sha256=bg7_iIiPwLKA5oSx9Xssc4lyTh1bym94eqGmYjBGjZw,4929024
7
+ BinaryOptionsToolsV2-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.7.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-none-win_amd64