bitpin-sdk 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 (60) hide show
  1. bitpin_sdk-0.1.0/.gitignore +19 -0
  2. bitpin_sdk-0.1.0/CHANGELOG.md +39 -0
  3. bitpin_sdk-0.1.0/LICENSE +21 -0
  4. bitpin_sdk-0.1.0/PKG-INFO +61 -0
  5. bitpin_sdk-0.1.0/README.md +28 -0
  6. bitpin_sdk-0.1.0/pyproject.toml +103 -0
  7. bitpin_sdk-0.1.0/src/bitpin_sdk/__init__.py +26 -0
  8. bitpin_sdk-0.1.0/src/bitpin_sdk/_async/__init__.py +1 -0
  9. bitpin_sdk-0.1.0/src/bitpin_sdk/_async/_compat.py +16 -0
  10. bitpin_sdk-0.1.0/src/bitpin_sdk/_async/client.py +922 -0
  11. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/__init__.py +1 -0
  12. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/auth.py +109 -0
  13. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/errors.py +91 -0
  14. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/numbers.py +37 -0
  15. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/parse.py +435 -0
  16. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/ratelimit.py +78 -0
  17. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/request.py +75 -0
  18. bitpin_sdk-0.1.0/src/bitpin_sdk/_core/symbols.py +35 -0
  19. bitpin_sdk-0.1.0/src/bitpin_sdk/_generated/__init__.py +1 -0
  20. bitpin_sdk-0.1.0/src/bitpin_sdk/_generated/spec.py +436 -0
  21. bitpin_sdk-0.1.0/src/bitpin_sdk/_sync/__init__.py +2 -0
  22. bitpin_sdk-0.1.0/src/bitpin_sdk/_sync/_compat.py +21 -0
  23. bitpin_sdk-0.1.0/src/bitpin_sdk/_sync/client.py +922 -0
  24. bitpin_sdk-0.1.0/src/bitpin_sdk/config.py +170 -0
  25. bitpin_sdk-0.1.0/src/bitpin_sdk/errors.py +127 -0
  26. bitpin_sdk-0.1.0/src/bitpin_sdk/py.typed +0 -0
  27. bitpin_sdk-0.1.0/src/bitpin_sdk/token_store.py +102 -0
  28. bitpin_sdk-0.1.0/src/bitpin_sdk/types.py +209 -0
  29. bitpin_sdk-0.1.0/src/bitpin_sdk/ws/__init__.py +10 -0
  30. bitpin_sdk-0.1.0/src/bitpin_sdk/ws/client.py +167 -0
  31. bitpin_sdk-0.1.0/src/bitpin_sdk/ws/parse.py +66 -0
  32. bitpin_sdk-0.1.0/src/bitpin_sdk/ws/transport.py +48 -0
  33. bitpin_sdk-0.1.0/tests/__init__.py +0 -0
  34. bitpin_sdk-0.1.0/tests/conftest.py +118 -0
  35. bitpin_sdk-0.1.0/tests/core/__init__.py +0 -0
  36. bitpin_sdk-0.1.0/tests/core/test_auth.py +151 -0
  37. bitpin_sdk-0.1.0/tests/core/test_config.py +129 -0
  38. bitpin_sdk-0.1.0/tests/core/test_errors.py +177 -0
  39. bitpin_sdk-0.1.0/tests/core/test_numbers.py +64 -0
  40. bitpin_sdk-0.1.0/tests/core/test_parse.py +329 -0
  41. bitpin_sdk-0.1.0/tests/core/test_ratelimit.py +71 -0
  42. bitpin_sdk-0.1.0/tests/core/test_request.py +95 -0
  43. bitpin_sdk-0.1.0/tests/core/test_symbols.py +30 -0
  44. bitpin_sdk-0.1.0/tests/fixtures.py +17 -0
  45. bitpin_sdk-0.1.0/tests/test_ai_files.py +102 -0
  46. bitpin_sdk-0.1.0/tests/test_docs.py +27 -0
  47. bitpin_sdk-0.1.0/tests/test_examples.py +264 -0
  48. bitpin_sdk-0.1.0/tests/test_fixtures.py +23 -0
  49. bitpin_sdk-0.1.0/tests/test_generated.py +54 -0
  50. bitpin_sdk-0.1.0/tests/test_has.py +30 -0
  51. bitpin_sdk-0.1.0/tests/test_public.py +158 -0
  52. bitpin_sdk-0.1.0/tests/test_spec.py +76 -0
  53. bitpin_sdk-0.1.0/tests/test_sync_fresh.py +38 -0
  54. bitpin_sdk-0.1.0/tests/test_token_store.py +87 -0
  55. bitpin_sdk-0.1.0/tests/test_trading.py +414 -0
  56. bitpin_sdk-0.1.0/tests/test_transport.py +410 -0
  57. bitpin_sdk-0.1.0/tests/test_wallet.py +202 -0
  58. bitpin_sdk-0.1.0/tests/ws/__init__.py +0 -0
  59. bitpin_sdk-0.1.0/tests/ws/test_ws.py +455 -0
  60. bitpin_sdk-0.1.0/uv.lock +1846 -0
@@ -0,0 +1,19 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .coverage
8
+ coverage.xml
9
+ htmlcov/
10
+ .pytest_cache/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+ site/
14
+ .superpowers/
15
+ .env
16
+ .env.*
17
+ !.env.example
18
+ .DS_Store
19
+ .hypothesis/
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Python SDK, written by release-please from Conventional Commits.
4
+
5
+
6
+ ## 0.1.0 (2026-10-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * **python:** async client with public market data ([e23997b](https://github.com/bitpin-dev/bitpin-sdk/commit/e23997b3e3135e0d2d1352d86ac62fb301141c41))
12
+ * **python:** config, rate limiter, symbol and decimal helpers ([4bf3f14](https://github.com/bitpin-dev/bitpin-sdk/commit/4bf3f142848c800c6e2dd8e40ada0053683d3d12))
13
+ * **python:** error hierarchy and mapping ([5795634](https://github.com/bitpin-dev/bitpin-sdk/commit/57956343ad9f8ad9219269ce2047f89e5aed3350))
14
+ * **python:** generate endpoint table from spec ([7377da1](https://github.com/bitpin-dev/bitpin-sdk/commit/7377da15cd4a326ff9a49ad61951e05d6660e9b8))
15
+ * **python:** generate sync client with unasync ([2e1c41c](https://github.com/bitpin-dev/bitpin-sdk/commit/2e1c41c7c304ce83a6508f30850554519ca56cf7))
16
+ * **python:** request builder, parsers and shared fixtures ([daaa339](https://github.com/bitpin-dev/bitpin-sdk/commit/daaa339f942065ee7a06f00513c4928af80766b4))
17
+ * **python:** token lifecycle and token stores ([300ddf6](https://github.com/bitpin-dev/bitpin-sdk/commit/300ddf6040bb5bd2964ae3fda843cddbe146cdf5))
18
+ * **python:** trading, wallet and not-supported methods ([5007c21](https://github.com/bitpin-dev/bitpin-sdk/commit/5007c211cdf9b0ec4041a8d1f52e8556709fd5be))
19
+ * **python:** websocket watch methods ([03b6624](https://github.com/bitpin-dev/bitpin-sdk/commit/03b66249e637f7abad484cfc2b75ad1a685fbbeb))
20
+
21
+
22
+ ### Bug fixes
23
+
24
+ * **ci:** dependabot PR titles pass the conventional-title check ([d9edc02](https://github.com/bitpin-dev/bitpin-sdk/commit/d9edc02c6cc66dc2c922799c7245747eb79396d7))
25
+ * **examples:** market maker always cancels its quotes on exit ([6c1b066](https://github.com/bitpin-dev/bitpin-sdk/commit/6c1b0665d22b0b64bac7b742a51c37ee105d61ad))
26
+ * **python:** give each websocket watch its own queue ([41cee57](https://github.com/bitpin-dev/bitpin-sdk/commit/41cee574bd748341b5ca4e71df5e4df956c479ba))
27
+ * **python:** ignore a late 401 for a token that was already replaced ([5f7092a](https://github.com/bitpin-dev/bitpin-sdk/commit/5f7092a732ee738b5f2fbd7ff6867100df1cae46))
28
+ * **python:** paginate reads every page and can't loop forever ([f25b7b3](https://github.com/bitpin-dev/bitpin-sdk/commit/f25b7b316254534f99ac900c0e515a97abe491ba))
29
+ * **python:** parse one-digit fractions on Python 3.10; derive the token-file id with PBKDF2 ([d896f26](https://github.com/bitpin-dev/bitpin-sdk/commit/d896f26e5cfe066b06b8ee99dcae829cb2484f15))
30
+ * **python:** reserve rate-limit slots so concurrent calls don't burst ([d934e3d](https://github.com/bitpin-dev/bitpin-sdk/commit/d934e3dda3a02bb754e3555e4b23faac15d337f5))
31
+ * **python:** safe concurrent token-file saves; keep credentials out of exception chains ([1835e09](https://github.com/bitpin-dev/bitpin-sdk/commit/1835e09d9fbd5023d2c99e064609a2eb00d7c61a))
32
+ * **python:** ticker change is a ratio, report it as ccxt percentage ([d81d56e](https://github.com/bitpin-dev/bitpin-sdk/commit/d81d56ec33e32ffe3c0e92325b7f72c6d1f7c4b7))
33
+
34
+
35
+ ### Documentation
36
+
37
+ * **ai:** agent instructions, rules, skills and permissions ([0b5989a](https://github.com/bitpin-dev/bitpin-sdk/commit/0b5989ad4a41323487d3d7efe0d711031796189a))
38
+ * bilingual documentation and llms.txt ([69e7f6a](https://github.com/bitpin-dev/bitpin-sdk/commit/69e7f6a5e0c4cb276796c1c0c7c411a5626d0f45))
39
+ * **examples:** add dry-run examples ([58620ac](https://github.com/bitpin-dev/bitpin-sdk/commit/58620ac1999ef10f2a503b43df6eae32a71d8cae))
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bitpin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.5
2
+ Name: bitpin-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the Bitpin exchange API (REST + WebSocket, sync + async)
5
+ Project-URL: Homepage, https://github.com/bitpin-dev/bitpin-sdk
6
+ Project-URL: Documentation, https://bitpin-dev.github.io/bitpin-sdk/
7
+ Project-URL: Source, https://github.com/bitpin-dev/bitpin-sdk/tree/main/python
8
+ Project-URL: Changelog, https://github.com/bitpin-dev/bitpin-sdk/blob/main/python/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/bitpin-dev/bitpin-sdk/issues
10
+ Author: Bitpin
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: bitpin,ccxt,crypto,exchange,market-making,sdk,trading
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Office/Business :: Financial :: Investment
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Requires-Dist: httpx<1,>=0.27
29
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
30
+ Provides-Extra: ws
31
+ Requires-Dist: centrifuge-python<1,>=0.4; extra == 'ws'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # bitpin-sdk
35
+
36
+ The official Python SDK for the [Bitpin](https://bitpin.ir) exchange API: sync `Bitpin` and async `AsyncBitpin`, ccxt method names and result structures, `Decimal` numbers, automatic token refresh, client-side rate limiting with overridable VIP limits, and WebSocket streams.
37
+
38
+ SDK رسمی پایتون برای API صرافی بیت‌پین. [مستندات فارسی](https://bitpin-dev.github.io/bitpin-sdk/fa/)
39
+
40
+ ```bash
41
+ pip install bitpin-sdk # REST
42
+ pip install "bitpin-sdk[ws]" # + WebSocket
43
+ ```
44
+
45
+ ```python
46
+ from bitpin_sdk import Bitpin, Config
47
+
48
+ with Bitpin(Config.from_env()) as client: # BITPIN_API_KEY, BITPIN_SECRET_KEY
49
+ print(client.fetch_ticker("BTC/IRT")["last"])
50
+ order = client.create_order("USDT/IRT", "limit", "buy", "10", "90000",
51
+ {"clientOrderId": "bot-1"})
52
+ client.cancel_order_by_identifier("bot-1")
53
+ ```
54
+
55
+ Bitpin has no sandbox: every call is real.
56
+
57
+ - [Documentation](https://bitpin-dev.github.io/bitpin-sdk/) (English and Persian)
58
+ - [Examples](https://github.com/bitpin-dev/bitpin-sdk/tree/main/examples/python)
59
+ - [llms.txt](https://github.com/bitpin-dev/bitpin-sdk/blob/main/llms.txt) for AI agents
60
+ - [Changelog](https://github.com/bitpin-dev/bitpin-sdk/blob/main/python/CHANGELOG.md)
61
+ - [Security](https://github.com/bitpin-dev/bitpin-sdk/blob/main/SECURITY.md)
@@ -0,0 +1,28 @@
1
+ # bitpin-sdk
2
+
3
+ The official Python SDK for the [Bitpin](https://bitpin.ir) exchange API: sync `Bitpin` and async `AsyncBitpin`, ccxt method names and result structures, `Decimal` numbers, automatic token refresh, client-side rate limiting with overridable VIP limits, and WebSocket streams.
4
+
5
+ SDK رسمی پایتون برای API صرافی بیت‌پین. [مستندات فارسی](https://bitpin-dev.github.io/bitpin-sdk/fa/)
6
+
7
+ ```bash
8
+ pip install bitpin-sdk # REST
9
+ pip install "bitpin-sdk[ws]" # + WebSocket
10
+ ```
11
+
12
+ ```python
13
+ from bitpin_sdk import Bitpin, Config
14
+
15
+ with Bitpin(Config.from_env()) as client: # BITPIN_API_KEY, BITPIN_SECRET_KEY
16
+ print(client.fetch_ticker("BTC/IRT")["last"])
17
+ order = client.create_order("USDT/IRT", "limit", "buy", "10", "90000",
18
+ {"clientOrderId": "bot-1"})
19
+ client.cancel_order_by_identifier("bot-1")
20
+ ```
21
+
22
+ Bitpin has no sandbox: every call is real.
23
+
24
+ - [Documentation](https://bitpin-dev.github.io/bitpin-sdk/) (English and Persian)
25
+ - [Examples](https://github.com/bitpin-dev/bitpin-sdk/tree/main/examples/python)
26
+ - [llms.txt](https://github.com/bitpin-dev/bitpin-sdk/blob/main/llms.txt) for AI agents
27
+ - [Changelog](https://github.com/bitpin-dev/bitpin-sdk/blob/main/python/CHANGELOG.md)
28
+ - [Security](https://github.com/bitpin-dev/bitpin-sdk/blob/main/SECURITY.md)
@@ -0,0 +1,103 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "bitpin-sdk"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for the Bitpin exchange API (REST + WebSocket, sync + async)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Bitpin" }]
14
+ keywords = ["bitpin", "crypto", "exchange", "trading", "sdk", "ccxt", "market-making"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Financial and Insurance Industry",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Topic :: Office/Business :: Financial :: Investment",
28
+ "Typing :: Typed",
29
+ ]
30
+ dependencies = [
31
+ "httpx>=0.27,<1",
32
+ "tomli>=2.0; python_version < '3.11'",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ ws = ["centrifuge-python>=0.4,<1"]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/bitpin-dev/bitpin-sdk"
40
+ Documentation = "https://bitpin-dev.github.io/bitpin-sdk/"
41
+ Source = "https://github.com/bitpin-dev/bitpin-sdk/tree/main/python"
42
+ Changelog = "https://github.com/bitpin-dev/bitpin-sdk/blob/main/python/CHANGELOG.md"
43
+ Issues = "https://github.com/bitpin-dev/bitpin-sdk/issues"
44
+
45
+ [dependency-groups]
46
+ dev = [
47
+ "pytest>=8",
48
+ "pytest-asyncio>=0.24",
49
+ "pytest-cov>=5",
50
+ "respx>=0.21",
51
+ "hypothesis>=6.100",
52
+ "jsonschema>=4.22",
53
+ "pyyaml>=6",
54
+ "ruff>=0.6",
55
+ "mypy>=1.11",
56
+ "types-pyyaml",
57
+ "unasync>=0.6",
58
+ "centrifuge-python>=0.4,<1",
59
+ ]
60
+
61
+ [tool.hatch.build.targets.wheel]
62
+ packages = ["src/bitpin_sdk"]
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
66
+ asyncio_mode = "auto"
67
+ asyncio_default_fixture_loop_scope = "function"
68
+ filterwarnings = ["error"]
69
+ markers = ["live: calls the real Bitpin API (read-only); never run in CI"]
70
+ addopts = "-m 'not live'"
71
+
72
+ [tool.coverage.run]
73
+ branch = true
74
+ source = ["bitpin_sdk"]
75
+
76
+ [tool.coverage.report]
77
+ fail_under = 95
78
+ show_missing = true
79
+ exclude_also = ["if TYPE_CHECKING:", "@overload", "raise NotImplementedError", "\\.\\.\\."]
80
+
81
+ [tool.ruff]
82
+ line-length = 100
83
+ target-version = "py310"
84
+ extend-exclude = ["src/bitpin_sdk/_generated", "src/bitpin_sdk/_sync"]
85
+
86
+ [tool.ruff.lint]
87
+ select = ["E", "F", "W", "I", "UP", "B", "S", "SIM", "RUF", "PT", "C4", "ASYNC"]
88
+ ignore = ["S101"]
89
+
90
+ [tool.ruff.lint.per-file-ignores]
91
+ "tests/**" = ["S105", "S106", "S108"]
92
+
93
+ [tool.mypy]
94
+ strict = true
95
+ python_version = "3.10"
96
+ files = ["src"]
97
+
98
+ [[tool.mypy.overrides]]
99
+ module = ["tomli", "centrifuge", "centrifuge.*", "respx"]
100
+ ignore_missing_imports = true
101
+
102
+ [tool.hatch.build.targets.sdist]
103
+ exclude = [".hypothesis", ".venv", "dist"]
@@ -0,0 +1,26 @@
1
+ """Official Python SDK for the Bitpin exchange.
2
+
3
+ from bitpin_sdk import Bitpin, AsyncBitpin, Config
4
+
5
+ See https://bitpin-dev.github.io/bitpin-sdk/ for the full documentation.
6
+ """
7
+
8
+ __version__ = "0.1.0" # x-release-please-version
9
+
10
+ from bitpin_sdk import errors
11
+ from bitpin_sdk._async.client import AsyncBitpin
12
+ from bitpin_sdk._sync.client import Bitpin
13
+ from bitpin_sdk.config import Config, RateLimit
14
+ from bitpin_sdk.token_store import FileTokenStore, MemoryTokenStore, TokenStore
15
+
16
+ __all__ = [
17
+ "AsyncBitpin",
18
+ "Bitpin",
19
+ "Config",
20
+ "FileTokenStore",
21
+ "MemoryTokenStore",
22
+ "RateLimit",
23
+ "TokenStore",
24
+ "__version__",
25
+ "errors",
26
+ ]
@@ -0,0 +1 @@
1
+ """The async client. The hand-written source of truth; ``_sync`` is generated from it."""
@@ -0,0 +1,16 @@
1
+ """Async primitives. ``_sync/_compat.py`` is the hand-written sync counterpart."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ from typing import Any
7
+
8
+ Lock = asyncio.Lock
9
+ default_sleep = asyncio.sleep
10
+
11
+
12
+ def websocket(client: Any, transport_factory: Any) -> Any:
13
+ """The WebSocket client behind ``AsyncBitpin.watch_*``."""
14
+ from bitpin_sdk.ws.client import BitpinWS
15
+
16
+ return BitpinWS(client, transport_factory=transport_factory)