binaryoptionstoolsv2 0.1.0__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.
Files changed (71) hide show
  1. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/.github/workflows/CI.yml +169 -0
  2. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/.gitignore +72 -0
  3. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/BinaryOptionsToolsV2/__init__.py +8 -0
  4. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/BinaryOptionsToolsV2/asyncronous.py +85 -0
  5. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/BinaryOptionsToolsV2/syncronous.py +62 -0
  6. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/Cargo.lock +2119 -0
  7. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/Cargo.toml +23 -0
  8. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/Readme.md +4 -0
  9. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/__init__.py +8 -0
  10. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/asyncronous.py +85 -0
  11. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/candles_eurusd_otc.csv +149 -0
  12. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/src/error.rs +23 -0
  13. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/src/lib.rs +16 -0
  14. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/src/pocketoption.rs +105 -0
  15. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/syncronous.py +62 -0
  16. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/tests/test.py +42 -0
  17. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/tests/test_sync.py +11 -0
  18. BinaryOptionsToolsV2-0.1.0/BinaryOptionsToolsV2/uv.lock +7 -0
  19. BinaryOptionsToolsV2-0.1.0/PKG-INFO +16 -0
  20. BinaryOptionsToolsV2-0.1.0/core/Cargo.toml +23 -0
  21. BinaryOptionsToolsV2-0.1.0/core/README.md +28 -0
  22. BinaryOptionsToolsV2-0.1.0/core/readme.md +28 -0
  23. BinaryOptionsToolsV2-0.1.0/core/src/error.rs +48 -0
  24. BinaryOptionsToolsV2-0.1.0/core/src/general/client.rs +306 -0
  25. BinaryOptionsToolsV2-0.1.0/core/src/general/mod.rs +3 -0
  26. BinaryOptionsToolsV2-0.1.0/core/src/general/traits.rs +73 -0
  27. BinaryOptionsToolsV2-0.1.0/core/src/general/types.rs +326 -0
  28. BinaryOptionsToolsV2-0.1.0/core/src/lib.rs +4 -0
  29. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/error.rs +58 -0
  30. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/mod.rs +9 -0
  31. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/parser/basic.rs +46 -0
  32. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/parser/message.rs +429 -0
  33. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/parser/mod.rs +2 -0
  34. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/pocket_client.rs +102 -0
  35. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/base.rs +11 -0
  36. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/data.rs +163 -0
  37. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/data_v2.rs +180 -0
  38. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/info.rs +57 -0
  39. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/mod.rs +8 -0
  40. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/order.rs +228 -0
  41. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/success.rs +21 -0
  42. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/update.rs +312 -0
  43. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/types/user.rs +15 -0
  44. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/utils/basic.rs +22 -0
  45. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/utils/connect.rs +44 -0
  46. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/utils/location.rs +35 -0
  47. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/utils/mod.rs +3 -0
  48. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/validators.rs +41 -0
  49. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/api.rs +420 -0
  50. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/basic.rs +389 -0
  51. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/connect.rs +64 -0
  52. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/listener.rs +190 -0
  53. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/mod.rs +6 -0
  54. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/regions.rs +99 -0
  55. BinaryOptionsToolsV2-0.1.0/core/src/pocketoption/ws/ssid.rs +187 -0
  56. BinaryOptionsToolsV2-0.1.0/core/src/utils/mod.rs +1 -0
  57. BinaryOptionsToolsV2-0.1.0/core/src/utils/tracing.rs +28 -0
  58. BinaryOptionsToolsV2-0.1.0/core/tests/assets.txt +176 -0
  59. BinaryOptionsToolsV2-0.1.0/core/tests/data.json +5674 -0
  60. BinaryOptionsToolsV2-0.1.0/core/tests/load_history_period.json +1357 -0
  61. BinaryOptionsToolsV2-0.1.0/core/tests/load_history_period2.json +4161 -0
  62. BinaryOptionsToolsV2-0.1.0/core/tests/success_open_order.json +23 -0
  63. BinaryOptionsToolsV2-0.1.0/core/tests/success_update_pending.json +62 -0
  64. BinaryOptionsToolsV2-0.1.0/core/tests/test.json +6 -0
  65. BinaryOptionsToolsV2-0.1.0/core/tests/test_close_order.txt +54 -0
  66. BinaryOptionsToolsV2-0.1.0/core/tests/test_demo.json +6 -0
  67. BinaryOptionsToolsV2-0.1.0/core/tests/update_close_order.json +120 -0
  68. BinaryOptionsToolsV2-0.1.0/core/tests/update_closed_deals.txt +582 -0
  69. BinaryOptionsToolsV2-0.1.0/core/tests/update_history_new.json +1265 -0
  70. BinaryOptionsToolsV2-0.1.0/core/tests/update_opened_deals.txt +98 -0
  71. BinaryOptionsToolsV2-0.1.0/pyproject.toml +19 -0
@@ -0,0 +1,169 @@
1
+ # This file is autogenerated by maturin v1.7.0
2
+ # To update, run
3
+ #
4
+ # maturin generate-ci github
5
+ #
6
+ name: CI
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - main
12
+ - master
13
+ tags:
14
+ - '*'
15
+ pull_request:
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ linux:
23
+ runs-on: ${{ matrix.platform.runner }}
24
+ strategy:
25
+ matrix:
26
+ platform:
27
+ - runner: ubuntu-latest
28
+ target: x86_64
29
+ - runner: ubuntu-latest
30
+ target: x86
31
+ - runner: ubuntu-latest
32
+ target: aarch64
33
+ - runner: ubuntu-latest
34
+ target: armv7
35
+ - runner: ubuntu-latest
36
+ target: s390x
37
+ - runner: ubuntu-latest
38
+ target: ppc64le
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: actions/setup-python@v5
42
+ with:
43
+ python-version: 3.x
44
+ - name: Build wheels
45
+ uses: PyO3/maturin-action@v1
46
+ with:
47
+ target: ${{ matrix.platform.target }}
48
+ args: --release --out dist --find-interpreter
49
+ sccache: 'true'
50
+ manylinux: auto
51
+ - name: Upload wheels
52
+ uses: actions/upload-artifact@v4
53
+ with:
54
+ name: wheels-linux-${{ matrix.platform.target }}
55
+ path: dist
56
+
57
+ musllinux:
58
+ runs-on: ${{ matrix.platform.runner }}
59
+ strategy:
60
+ matrix:
61
+ platform:
62
+ - runner: ubuntu-latest
63
+ target: x86_64
64
+ - runner: ubuntu-latest
65
+ target: x86
66
+ - runner: ubuntu-latest
67
+ target: aarch64
68
+ - runner: ubuntu-latest
69
+ target: armv7
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+ - uses: actions/setup-python@v5
73
+ with:
74
+ python-version: 3.x
75
+ - name: Build wheels
76
+ uses: PyO3/maturin-action@v1
77
+ with:
78
+ target: ${{ matrix.platform.target }}
79
+ args: --release --out dist --find-interpreter
80
+ sccache: 'true'
81
+ manylinux: musllinux_1_2
82
+ - name: Upload wheels
83
+ uses: actions/upload-artifact@v4
84
+ with:
85
+ name: wheels-musllinux-${{ matrix.platform.target }}
86
+ path: dist
87
+
88
+ windows:
89
+ runs-on: ${{ matrix.platform.runner }}
90
+ strategy:
91
+ matrix:
92
+ platform:
93
+ - runner: windows-latest
94
+ target: x64
95
+ - runner: windows-latest
96
+ target: x86
97
+ steps:
98
+ - uses: actions/checkout@v4
99
+ - uses: actions/setup-python@v5
100
+ with:
101
+ python-version: 3.x
102
+ architecture: ${{ matrix.platform.target }}
103
+ - name: Build wheels
104
+ uses: PyO3/maturin-action@v1
105
+ with:
106
+ target: ${{ matrix.platform.target }}
107
+ args: --release --out dist --find-interpreter
108
+ sccache: 'true'
109
+ - name: Upload wheels
110
+ uses: actions/upload-artifact@v4
111
+ with:
112
+ name: wheels-windows-${{ matrix.platform.target }}
113
+ path: dist
114
+
115
+ macos:
116
+ runs-on: ${{ matrix.platform.runner }}
117
+ strategy:
118
+ matrix:
119
+ platform:
120
+ - runner: macos-12
121
+ target: x86_64
122
+ - runner: macos-14
123
+ target: aarch64
124
+ steps:
125
+ - uses: actions/checkout@v4
126
+ - uses: actions/setup-python@v5
127
+ with:
128
+ python-version: 3.x
129
+ - name: Build wheels
130
+ uses: PyO3/maturin-action@v1
131
+ with:
132
+ target: ${{ matrix.platform.target }}
133
+ args: --release --out dist --find-interpreter
134
+ sccache: 'true'
135
+ - name: Upload wheels
136
+ uses: actions/upload-artifact@v4
137
+ with:
138
+ name: wheels-macos-${{ matrix.platform.target }}
139
+ path: dist
140
+
141
+ sdist:
142
+ runs-on: ubuntu-latest
143
+ steps:
144
+ - uses: actions/checkout@v4
145
+ - name: Build sdist
146
+ uses: PyO3/maturin-action@v1
147
+ with:
148
+ command: sdist
149
+ args: --out dist
150
+ - name: Upload sdist
151
+ uses: actions/upload-artifact@v4
152
+ with:
153
+ name: wheels-sdist
154
+ path: dist
155
+
156
+ release:
157
+ name: Release
158
+ runs-on: ubuntu-latest
159
+ if: "startsWith(github.ref, 'refs/tags/')"
160
+ needs: [linux, musllinux, windows, macos, sdist]
161
+ steps:
162
+ - uses: actions/download-artifact@v4
163
+ - name: Publish to PyPI
164
+ uses: PyO3/maturin-action@v1
165
+ env:
166
+ MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
167
+ with:
168
+ command: upload
169
+ args: --non-interactive --skip-existing wheels-*/*
@@ -0,0 +1,72 @@
1
+ /target
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ .pytest_cache/
6
+ *.py[cod]
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ .venv/
14
+ env/
15
+ bin/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ include/
26
+ man/
27
+ venv/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+ pip-selfcheck.json
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+
45
+ # Translations
46
+ *.mo
47
+
48
+ # Mr Developer
49
+ .mr.developer.cfg
50
+ .project
51
+ .pydevproject
52
+
53
+ # Rope
54
+ .ropeproject
55
+
56
+ # Django stuff:
57
+ *.log
58
+ *.pot
59
+
60
+ .DS_Store
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyCharm
66
+ .idea/
67
+
68
+ # VSCode
69
+ .vscode/
70
+
71
+ # Pyenv
72
+ .python-version
@@ -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))