typed-extended 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 (137) hide show
  1. typed_extended-0.1.0/LICENSE +21 -0
  2. typed_extended-0.1.0/PKG-INFO +104 -0
  3. typed_extended-0.1.0/README.md +82 -0
  4. typed_extended-0.1.0/pyproject.toml +35 -0
  5. typed_extended-0.1.0/setup.cfg +4 -0
  6. typed_extended-0.1.0/src/typed_extended/__init__.py +14 -0
  7. typed_extended-0.1.0/src/typed_extended/__init__.pyi +29 -0
  8. typed_extended-0.1.0/src/typed_extended/account/__init__.py +44 -0
  9. typed_extended-0.1.0/src/typed_extended/account/asset_operations.py +206 -0
  10. typed_extended-0.1.0/src/typed_extended/account/balance.py +67 -0
  11. typed_extended-0.1.0/src/typed_extended/account/fees.py +65 -0
  12. typed_extended-0.1.0/src/typed_extended/account/funding_history.py +146 -0
  13. typed_extended-0.1.0/src/typed_extended/account/info.py +47 -0
  14. typed_extended-0.1.0/src/typed_extended/account/leverage.py +46 -0
  15. typed_extended-0.1.0/src/typed_extended/account/open_orders.py +58 -0
  16. typed_extended-0.1.0/src/typed_extended/account/order.py +35 -0
  17. typed_extended-0.1.0/src/typed_extended/account/orders_by_external_id.py +43 -0
  18. typed_extended-0.1.0/src/typed_extended/account/orders_history.py +146 -0
  19. typed_extended-0.1.0/src/typed_extended/account/positions.py +52 -0
  20. typed_extended-0.1.0/src/typed_extended/account/positions_history.py +153 -0
  21. typed_extended-0.1.0/src/typed_extended/account/rebates.py +50 -0
  22. typed_extended-0.1.0/src/typed_extended/account/schemas.py +251 -0
  23. typed_extended-0.1.0/src/typed_extended/account/spot_balances.py +76 -0
  24. typed_extended-0.1.0/src/typed_extended/account/sub_accounts.py +54 -0
  25. typed_extended-0.1.0/src/typed_extended/account/trades.py +153 -0
  26. typed_extended-0.1.0/src/typed_extended/account/update_leverage.py +52 -0
  27. typed_extended-0.1.0/src/typed_extended/builder/__init__.py +11 -0
  28. typed_extended-0.1.0/src/typed_extended/builder/dashboard.py +63 -0
  29. typed_extended-0.1.0/src/typed_extended/builder/schemas.py +18 -0
  30. typed_extended-0.1.0/src/typed_extended/builder/trades.py +118 -0
  31. typed_extended-0.1.0/src/typed_extended/core/__init__.py +5 -0
  32. typed_extended-0.1.0/src/typed_extended/core/__init__.pyi +47 -0
  33. typed_extended-0.1.0/src/typed_extended/core/auth.py +122 -0
  34. typed_extended-0.1.0/src/typed_extended/core/client.py +140 -0
  35. typed_extended-0.1.0/src/typed_extended/core/endpoint/__init__.py +1 -0
  36. typed_extended-0.1.0/src/typed_extended/core/endpoint/rpc.py +136 -0
  37. typed_extended-0.1.0/src/typed_extended/core/endpoint/stream.py +98 -0
  38. typed_extended-0.1.0/src/typed_extended/core/endpoint/wire.py +88 -0
  39. typed_extended-0.1.0/src/typed_extended/core/envelope.py +163 -0
  40. typed_extended-0.1.0/src/typed_extended/core/exc.py +27 -0
  41. typed_extended-0.1.0/src/typed_extended/core/networks.py +48 -0
  42. typed_extended-0.1.0/src/typed_extended/core/signing.py +309 -0
  43. typed_extended-0.1.0/src/typed_extended/core/stark/__init__.py +2 -0
  44. typed_extended-0.1.0/src/typed_extended/core/stark/backend.py +177 -0
  45. typed_extended-0.1.0/src/typed_extended/core/stark/curve.py +225 -0
  46. typed_extended-0.1.0/src/typed_extended/core/stark/messages.py +229 -0
  47. typed_extended-0.1.0/src/typed_extended/core/stark/poseidon.py +56 -0
  48. typed_extended-0.1.0/src/typed_extended/core/stark/settlement.py +343 -0
  49. typed_extended-0.1.0/src/typed_extended/core/transport/__init__.py +1 -0
  50. typed_extended-0.1.0/src/typed_extended/core/transport/http.py +333 -0
  51. typed_extended-0.1.0/src/typed_extended/core/transport/ws.py +184 -0
  52. typed_extended-0.1.0/src/typed_extended/core/types.py +50 -0
  53. typed_extended-0.1.0/src/typed_extended/funds/__init__.py +14 -0
  54. typed_extended-0.1.0/src/typed_extended/funds/bridge_config.py +46 -0
  55. typed_extended-0.1.0/src/typed_extended/funds/bridge_quote.py +64 -0
  56. typed_extended-0.1.0/src/typed_extended/funds/commit_quote.py +46 -0
  57. typed_extended-0.1.0/src/typed_extended/funds/transfer.py +66 -0
  58. typed_extended-0.1.0/src/typed_extended/funds/withdraw.py +75 -0
  59. typed_extended-0.1.0/src/typed_extended/info/__init__.py +34 -0
  60. typed_extended-0.1.0/src/typed_extended/info/asset_price.py +38 -0
  61. typed_extended-0.1.0/src/typed_extended/info/assets.py +120 -0
  62. typed_extended-0.1.0/src/typed_extended/info/candles.py +110 -0
  63. typed_extended-0.1.0/src/typed_extended/info/funding_rates.py +63 -0
  64. typed_extended-0.1.0/src/typed_extended/info/market_stats.py +37 -0
  65. typed_extended-0.1.0/src/typed_extended/info/markets.py +156 -0
  66. typed_extended-0.1.0/src/typed_extended/info/open_interests.py +76 -0
  67. typed_extended-0.1.0/src/typed_extended/info/orderbook.py +46 -0
  68. typed_extended-0.1.0/src/typed_extended/info/schemas.py +69 -0
  69. typed_extended-0.1.0/src/typed_extended/info/settings.py +37 -0
  70. typed_extended-0.1.0/src/typed_extended/info/starknet.py +43 -0
  71. typed_extended-0.1.0/src/typed_extended/info/status.py +37 -0
  72. typed_extended-0.1.0/src/typed_extended/info/trades.py +58 -0
  73. typed_extended-0.1.0/src/typed_extended/interest/__init__.py +17 -0
  74. typed_extended-0.1.0/src/typed_extended/interest/daily_metrics.py +63 -0
  75. typed_extended-0.1.0/src/typed_extended/interest/key_metrics.py +51 -0
  76. typed_extended-0.1.0/src/typed_extended/interest/latest_rate_curves.py +42 -0
  77. typed_extended-0.1.0/src/typed_extended/interest/payment_chart.py +87 -0
  78. typed_extended-0.1.0/src/typed_extended/interest/payments.py +67 -0
  79. typed_extended-0.1.0/src/typed_extended/interest/rate_curves.py +47 -0
  80. typed_extended-0.1.0/src/typed_extended/interest/schemas.py +49 -0
  81. typed_extended-0.1.0/src/typed_extended/main.py +121 -0
  82. typed_extended-0.1.0/src/typed_extended/orders/__init__.py +15 -0
  83. typed_extended-0.1.0/src/typed_extended/orders/cancel.py +37 -0
  84. typed_extended-0.1.0/src/typed_extended/orders/cancel_by_external_id.py +42 -0
  85. typed_extended-0.1.0/src/typed_extended/orders/create.py +226 -0
  86. typed_extended-0.1.0/src/typed_extended/orders/create_rfq.py +223 -0
  87. typed_extended-0.1.0/src/typed_extended/orders/dead_man_switch.py +39 -0
  88. typed_extended-0.1.0/src/typed_extended/orders/mass_cancel.py +63 -0
  89. typed_extended-0.1.0/src/typed_extended/orders/schemas.py +40 -0
  90. typed_extended-0.1.0/src/typed_extended/points/__init__.py +11 -0
  91. typed_extended-0.1.0/src/typed_extended/points/earned.py +57 -0
  92. typed_extended-0.1.0/src/typed_extended/points/leaderboard_stats.py +48 -0
  93. typed_extended-0.1.0/src/typed_extended/portfolio/__init__.py +36 -0
  94. typed_extended-0.1.0/src/typed_extended/portfolio/cumulative_pnl.py +65 -0
  95. typed_extended-0.1.0/src/typed_extended/portfolio/cumulative_pnl_percentage.py +68 -0
  96. typed_extended-0.1.0/src/typed_extended/portfolio/equities.py +47 -0
  97. typed_extended-0.1.0/src/typed_extended/portfolio/funding_chart.py +54 -0
  98. typed_extended-0.1.0/src/typed_extended/portfolio/funding_history.py +149 -0
  99. typed_extended-0.1.0/src/typed_extended/portfolio/funding_stats.py +74 -0
  100. typed_extended-0.1.0/src/typed_extended/portfolio/health.py +69 -0
  101. typed_extended-0.1.0/src/typed_extended/portfolio/max_drawdown.py +56 -0
  102. typed_extended-0.1.0/src/typed_extended/portfolio/performance.py +82 -0
  103. typed_extended-0.1.0/src/typed_extended/portfolio/pnl.py +65 -0
  104. typed_extended-0.1.0/src/typed_extended/portfolio/pnl_percentage.py +68 -0
  105. typed_extended-0.1.0/src/typed_extended/portfolio/schemas.py +33 -0
  106. typed_extended-0.1.0/src/typed_extended/portfolio/summary.py +87 -0
  107. typed_extended-0.1.0/src/typed_extended/portfolio/vault_equities.py +47 -0
  108. typed_extended-0.1.0/src/typed_extended/py.typed +0 -0
  109. typed_extended-0.1.0/src/typed_extended/referrals/__init__.py +16 -0
  110. typed_extended-0.1.0/src/typed_extended/referrals/affiliate.py +31 -0
  111. typed_extended-0.1.0/src/typed_extended/referrals/create.py +55 -0
  112. typed_extended-0.1.0/src/typed_extended/referrals/dashboard.py +109 -0
  113. typed_extended-0.1.0/src/typed_extended/referrals/links.py +54 -0
  114. typed_extended-0.1.0/src/typed_extended/referrals/schemas.py +115 -0
  115. typed_extended-0.1.0/src/typed_extended/referrals/status.py +42 -0
  116. typed_extended-0.1.0/src/typed_extended/referrals/update.py +55 -0
  117. typed_extended-0.1.0/src/typed_extended/referrals/use.py +37 -0
  118. typed_extended-0.1.0/src/typed_extended/schemas.py +13 -0
  119. typed_extended-0.1.0/src/typed_extended/streams/__init__.py +19 -0
  120. typed_extended-0.1.0/src/typed_extended/streams/account.py +316 -0
  121. typed_extended-0.1.0/src/typed_extended/streams/candles.py +103 -0
  122. typed_extended-0.1.0/src/typed_extended/streams/funding.py +65 -0
  123. typed_extended-0.1.0/src/typed_extended/streams/index_prices.py +69 -0
  124. typed_extended-0.1.0/src/typed_extended/streams/mark_prices.py +69 -0
  125. typed_extended-0.1.0/src/typed_extended/streams/orderbooks.py +49 -0
  126. typed_extended-0.1.0/src/typed_extended/streams/rfq_orderbooks.py +47 -0
  127. typed_extended-0.1.0/src/typed_extended/streams/schemas.py +69 -0
  128. typed_extended-0.1.0/src/typed_extended/streams/trades.py +74 -0
  129. typed_extended-0.1.0/src/typed_extended/vault/__init__.py +11 -0
  130. typed_extended-0.1.0/src/typed_extended/vault/performance.py +62 -0
  131. typed_extended-0.1.0/src/typed_extended/vault/schemas.py +14 -0
  132. typed_extended-0.1.0/src/typed_extended/vault/summary.py +55 -0
  133. typed_extended-0.1.0/src/typed_extended.egg-info/PKG-INFO +104 -0
  134. typed_extended-0.1.0/src/typed_extended.egg-info/SOURCES.txt +135 -0
  135. typed_extended-0.1.0/src/typed_extended.egg-info/dependency_links.txt +1 -0
  136. typed_extended-0.1.0/src/typed_extended.egg-info/requires.txt +5 -0
  137. typed_extended-0.1.0/src/typed_extended.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tribulnation Labs
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,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: typed-extended
3
+ Version: 0.1.0
4
+ Summary: A fully typed, validated async client for the Extended API.
5
+ Author-email: Marcel Claramunt <marcel@tribulnation.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/tribulnation/typed
8
+ Project-URL: Documentation, https://tribulnation.com/typed/extended
9
+ Project-URL: Website, https://tribulnation.com/typed
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: typed-core>=0.13.0
18
+ Requires-Dist: lazy-loader
19
+ Provides-Extra: fast
20
+ Requires-Dist: fast-stark-crypto<0.6,>=0.5; extra == "fast"
21
+ Dynamic: license-file
22
+
23
+ # Typed Extended
24
+
25
+ <p align="center">
26
+ <em>A fully typed, validated async client for the Extended API.</em>
27
+ </p>
28
+
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/typed-extended/">
31
+ <img src="https://img.shields.io/pypi/v/typed-extended.svg" alt="PyPI version">
32
+ </a>
33
+ <a href="https://pypi.org/project/typed-extended/">
34
+ <img src="https://img.shields.io/pypi/pyversions/typed-extended.svg" alt="Python versions">
35
+ </a>
36
+ <a href="https://tribulnation.com/typed/extended">
37
+ <img src="https://img.shields.io/badge/docs-live-black" alt="Docs">
38
+ </a>
39
+ <a href="LICENSE">
40
+ <img src="https://img.shields.io/pypi/l/typed-extended.svg" alt="License">
41
+ </a>
42
+ </p>
43
+
44
+ ---
45
+
46
+ - **Documentation**: [https://tribulnation.com/typed/extended](https://tribulnation.com/typed/extended)
47
+ - **Source Code**: [https://github.com/tribulnation/typed/tree/main/packages/extended](https://github.com/tribulnation/typed/tree/main/packages/extended)
48
+
49
+ ---
50
+
51
+ ```python
52
+ from typed_extended import Extended
53
+
54
+ async with Extended.new(public=True) as client:
55
+ stats = await client.info.market_stats('BTC-USD')
56
+ print(stats['lastPrice'], stats['markPrice'], stats['fundingRate'])
57
+ ```
58
+
59
+ ## Why Typed Extended?
60
+
61
+ - **🎯 Precise Types**: Typed inputs and responses for every REST call and WebSocket stream, including the order request union (limit, market, conditional, TP/SL).
62
+ - **✅ Runtime Validation**: Responses and stream messages validated by default, with prices and sizes as exact `Decimal` and timestamps as `datetime`.
63
+ - **⚡ Async First**: Async HTTP and WebSocket streams, with Stark order, transfer and withdrawal signing done for you.
64
+ - **📚 Full Surface**: Market data, account, orders, transfers and withdrawals, portfolio analytics, vault, interest, points, referrals and builder endpoints.
65
+
66
+ ## Installation
67
+
68
+ ```bash
69
+ pip install typed-extended
70
+ ```
71
+
72
+ Signing runs in pure Python out of the box. For roughly 10x faster signatures, install the
73
+ optional native backend:
74
+
75
+ ```bash
76
+ pip install "typed-extended[fast]"
77
+ ```
78
+
79
+ ## How To
80
+
81
+ - [Fetch Market Data](https://tribulnation.com/typed/extended/how-to/fetch-market-data)
82
+ - [Listen To Live Streams](https://tribulnation.com/typed/extended/how-to/listen-to-live-streams)
83
+ - [Place & Manage Orders](https://tribulnation.com/typed/extended/how-to/place-and-manage-orders)
84
+ - [Fetch Account Data](https://tribulnation.com/typed/extended/how-to/fetch-account-data)
85
+ - [Paginate Through Results](https://tribulnation.com/typed/extended/how-to/paginate-through-results)
86
+ - [Transfer & Withdraw](https://tribulnation.com/typed/extended/how-to/transfer-and-withdraw)
87
+
88
+ ## Reference
89
+
90
+ - [Authenticated Setup](https://tribulnation.com/typed/extended/authenticated-setup)
91
+ - [Async Usage](https://tribulnation.com/typed/extended/reference/async-usage)
92
+ - [Error Handling](https://tribulnation.com/typed/extended/reference/error-handling)
93
+ - [Environment Variables](https://tribulnation.com/typed/extended/reference/env-vars)
94
+ - [Timestamps](https://tribulnation.com/typed/extended/reference/timestamps)
95
+
96
+ ## Design Philosophy
97
+
98
+ Typed Extended follows the principles outlined in [this blog post](https://tribulnation.com/blog/clients).
99
+
100
+ *Details matter. Developer experience matters.*
101
+
102
+ ## License
103
+
104
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,82 @@
1
+ # Typed Extended
2
+
3
+ <p align="center">
4
+ <em>A fully typed, validated async client for the Extended API.</em>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://pypi.org/project/typed-extended/">
9
+ <img src="https://img.shields.io/pypi/v/typed-extended.svg" alt="PyPI version">
10
+ </a>
11
+ <a href="https://pypi.org/project/typed-extended/">
12
+ <img src="https://img.shields.io/pypi/pyversions/typed-extended.svg" alt="Python versions">
13
+ </a>
14
+ <a href="https://tribulnation.com/typed/extended">
15
+ <img src="https://img.shields.io/badge/docs-live-black" alt="Docs">
16
+ </a>
17
+ <a href="LICENSE">
18
+ <img src="https://img.shields.io/pypi/l/typed-extended.svg" alt="License">
19
+ </a>
20
+ </p>
21
+
22
+ ---
23
+
24
+ - **Documentation**: [https://tribulnation.com/typed/extended](https://tribulnation.com/typed/extended)
25
+ - **Source Code**: [https://github.com/tribulnation/typed/tree/main/packages/extended](https://github.com/tribulnation/typed/tree/main/packages/extended)
26
+
27
+ ---
28
+
29
+ ```python
30
+ from typed_extended import Extended
31
+
32
+ async with Extended.new(public=True) as client:
33
+ stats = await client.info.market_stats('BTC-USD')
34
+ print(stats['lastPrice'], stats['markPrice'], stats['fundingRate'])
35
+ ```
36
+
37
+ ## Why Typed Extended?
38
+
39
+ - **🎯 Precise Types**: Typed inputs and responses for every REST call and WebSocket stream, including the order request union (limit, market, conditional, TP/SL).
40
+ - **✅ Runtime Validation**: Responses and stream messages validated by default, with prices and sizes as exact `Decimal` and timestamps as `datetime`.
41
+ - **⚡ Async First**: Async HTTP and WebSocket streams, with Stark order, transfer and withdrawal signing done for you.
42
+ - **📚 Full Surface**: Market data, account, orders, transfers and withdrawals, portfolio analytics, vault, interest, points, referrals and builder endpoints.
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install typed-extended
48
+ ```
49
+
50
+ Signing runs in pure Python out of the box. For roughly 10x faster signatures, install the
51
+ optional native backend:
52
+
53
+ ```bash
54
+ pip install "typed-extended[fast]"
55
+ ```
56
+
57
+ ## How To
58
+
59
+ - [Fetch Market Data](https://tribulnation.com/typed/extended/how-to/fetch-market-data)
60
+ - [Listen To Live Streams](https://tribulnation.com/typed/extended/how-to/listen-to-live-streams)
61
+ - [Place & Manage Orders](https://tribulnation.com/typed/extended/how-to/place-and-manage-orders)
62
+ - [Fetch Account Data](https://tribulnation.com/typed/extended/how-to/fetch-account-data)
63
+ - [Paginate Through Results](https://tribulnation.com/typed/extended/how-to/paginate-through-results)
64
+ - [Transfer & Withdraw](https://tribulnation.com/typed/extended/how-to/transfer-and-withdraw)
65
+
66
+ ## Reference
67
+
68
+ - [Authenticated Setup](https://tribulnation.com/typed/extended/authenticated-setup)
69
+ - [Async Usage](https://tribulnation.com/typed/extended/reference/async-usage)
70
+ - [Error Handling](https://tribulnation.com/typed/extended/reference/error-handling)
71
+ - [Environment Variables](https://tribulnation.com/typed/extended/reference/env-vars)
72
+ - [Timestamps](https://tribulnation.com/typed/extended/reference/timestamps)
73
+
74
+ ## Design Philosophy
75
+
76
+ Typed Extended follows the principles outlined in [this blog post](https://tribulnation.com/blog/clients).
77
+
78
+ *Details matter. Developer experience matters.*
79
+
80
+ ## License
81
+
82
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "typed-extended"
7
+ version = "0.1.0"
8
+ authors = [
9
+ {name="Marcel Claramunt", email="marcel@tribulnation.com"}
10
+ ]
11
+ description = "A fully typed, validated async client for the Extended API."
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Typing :: Typed",
19
+ ]
20
+ dependencies = [
21
+ "typed-core>=0.13.0", "lazy-loader",
22
+ ]
23
+ requires-python = ">=3.10"
24
+ readme = {file="README.md", content-type="text/markdown"}
25
+
26
+ [project.optional-dependencies]
27
+ fast = ["fast-stark-crypto>=0.5,<0.6"]
28
+
29
+ [tool.setuptools.package-data]
30
+ "typed_extended" = ["py.typed", "*.pyi", "**/*.pyi"]
31
+
32
+ [project.urls]
33
+ Repository = "https://github.com/tribulnation/typed"
34
+ Documentation = "https://tribulnation.com/typed/extended"
35
+ Website = "https://tribulnation.com/typed"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ """A fully typed, validated async client for the Extended API.
2
+
3
+ Examples:
4
+ ```python
5
+ from typed_extended import Extended
6
+
7
+ async with Extended.new(public=True) as client:
8
+ markets = await client.info.markets(['BTC-USD'])
9
+ ```
10
+ """
11
+
12
+ import lazy_loader as lazy
13
+
14
+ __getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
@@ -0,0 +1,29 @@
1
+ from .main import Extended
2
+ from .core import (
3
+ Error,
4
+ NetworkError,
5
+ ValidationError,
6
+ ApiError,
7
+ BadRequest,
8
+ AuthError,
9
+ RateLimited,
10
+ LogicError,
11
+ Network,
12
+ StarkAccount,
13
+ StarknetDomain,
14
+ )
15
+
16
+ __all__ = [
17
+ 'Extended',
18
+ 'Error',
19
+ 'NetworkError',
20
+ 'ValidationError',
21
+ 'ApiError',
22
+ 'BadRequest',
23
+ 'AuthError',
24
+ 'RateLimited',
25
+ 'LogicError',
26
+ 'Network',
27
+ 'StarkAccount',
28
+ 'StarknetDomain',
29
+ ]
@@ -0,0 +1,44 @@
1
+ # Generated by typed-dev — see CONTRIBUTING.md.
2
+ from .asset_operations import AssetOperations
3
+ from .balance import BalanceEndpoint
4
+ from .fees import Fees
5
+ from .funding_history import FundingHistory
6
+ from .info import Info
7
+ from .leverage import Leverage
8
+ from .open_orders import OpenOrders
9
+ from .order import OrderEndpoint
10
+ from .orders_by_external_id import OrdersByExternalId
11
+ from .orders_history import OrdersHistory
12
+ from .positions import Positions
13
+ from .positions_history import PositionsHistory
14
+ from .rebates import Rebates
15
+ from .spot_balances import SpotBalances
16
+ from .sub_accounts import SubAccounts
17
+ from .trades import Trades
18
+ from .update_leverage import UpdateLeverage
19
+
20
+
21
+ class Account(
22
+ AssetOperations,
23
+ BalanceEndpoint,
24
+ Fees,
25
+ FundingHistory,
26
+ Info,
27
+ Leverage,
28
+ OpenOrders,
29
+ OrderEndpoint,
30
+ OrdersByExternalId,
31
+ OrdersHistory,
32
+ Positions,
33
+ PositionsHistory,
34
+ Rebates,
35
+ SpotBalances,
36
+ SubAccounts,
37
+ Trades,
38
+ UpdateLeverage,
39
+ ):
40
+ """The API key's sub-account: details, balances, positions, orders, trades, funding payments, rebates, leverage and fees.
41
+
42
+ References:
43
+ - [Upstream docs](https://api.docs.extended.exchange/#account)
44
+ """
@@ -0,0 +1,206 @@
1
+ # Generated by typed-dev — see CONTRIBUTING.md.
2
+ from decimal import Decimal
3
+ from typed_core import PaginatedResponse
4
+ from typing_extensions import Literal, NotRequired, Sequence, TypedDict
5
+ from typed_extended.core import TimestampMillis
6
+ from typed_extended.core.endpoint.rpc import RpcEndpoint
7
+ from typed_extended.schemas import Pagination
8
+
9
+
10
+ class AssetOperation(TypedDict):
11
+ """One deposit, withdrawal, transfer or testnet claim."""
12
+
13
+ id: str
14
+ """Operation id: a decimal number for transfers and withdrawals, an on-chain id (hex) for deposits."""
15
+ type: Literal[
16
+ 'DEPOSIT', 'CLAIM', 'TRANSFER', 'WITHDRAWAL', 'FAST_WITHDRAWAL', 'SLOW_WITHDRAWAL'
17
+ ]
18
+ """Operation type (`CLAIM`: testnet funds claim)."""
19
+ status: Literal['CREATED', 'IN_PROGRESS', 'COMPLETED', 'REJECTED', 'READY_FOR_CLAIM']
20
+ """Operation status."""
21
+ amount: Decimal
22
+ """Amount, in the collateral asset (negative for outflows in the docs example)."""
23
+ fee: Decimal
24
+ """Fee paid."""
25
+ asset: int
26
+ """Asset id of the collateral asset."""
27
+ time: TimestampMillis
28
+ """When the operation was last updated."""
29
+ accountId: int
30
+ """Source account for transfers and withdrawals; destination account for deposits."""
31
+ counterpartyAccountId: NotRequired[int]
32
+ """Destination account of a transfer."""
33
+ transactionHash: NotRequired[str]
34
+ """On-chain transaction hash; absent for transfers."""
35
+ chain: NotRequired[str]
36
+ """Source chain of a deposit, target chain of a withdrawal."""
37
+
38
+
39
+ class Request(TypedDict):
40
+ """Filters and page."""
41
+
42
+ id: NotRequired[int]
43
+ """Only this operation (SDK only)."""
44
+ type: NotRequired[
45
+ list[
46
+ Literal[
47
+ 'DEPOSIT',
48
+ 'CLAIM',
49
+ 'TRANSFER',
50
+ 'WITHDRAWAL',
51
+ 'FAST_WITHDRAWAL',
52
+ 'SLOW_WITHDRAWAL',
53
+ ]
54
+ ]
55
+ ]
56
+ """Only these operation types (repeated `type` query key)."""
57
+ status: NotRequired[
58
+ list[Literal['CREATED', 'IN_PROGRESS', 'COMPLETED', 'REJECTED', 'READY_FOR_CLAIM']]
59
+ ]
60
+ """Only these statuses (repeated `status` query key)."""
61
+ startTime: NotRequired[TimestampMillis]
62
+ """Only operations from this time (SDK only)."""
63
+ endTime: NotRequired[TimestampMillis]
64
+ """Only operations up to this time (SDK only)."""
65
+ cursor: NotRequired[int]
66
+ """Continue after this item id: the `pagination.cursor` of the previous page."""
67
+ limit: NotRequired[int]
68
+ """Most operations per page; the docs say 50 per page."""
69
+
70
+
71
+ class AssetOperationsPage(TypedDict):
72
+ """One page of operations, newest first."""
73
+
74
+ data: list[AssetOperation]
75
+ """The operations."""
76
+ pagination: NotRequired[Pagination]
77
+ """Where the page ends; absent when the venue sends none."""
78
+
79
+
80
+ class AssetOperations(RpcEndpoint):
81
+ """Get the history of deposits, withdrawals, transfers between sub-accounts and testnet claims, newest first, 50 per page."""
82
+
83
+ def asset_operations_paged(
84
+ self,
85
+ *,
86
+ id: int | None = None,
87
+ type: list[
88
+ Literal[
89
+ 'DEPOSIT',
90
+ 'CLAIM',
91
+ 'TRANSFER',
92
+ 'WITHDRAWAL',
93
+ 'FAST_WITHDRAWAL',
94
+ 'SLOW_WITHDRAWAL',
95
+ ]
96
+ ]
97
+ | None = None,
98
+ status: list[
99
+ Literal['CREATED', 'IN_PROGRESS', 'COMPLETED', 'REJECTED', 'READY_FOR_CLAIM']
100
+ ]
101
+ | None = None,
102
+ start_time: TimestampMillis | None = None,
103
+ end_time: TimestampMillis | None = None,
104
+ limit: int | None = None,
105
+ validate: bool | None = None,
106
+ ) -> PaginatedResponse[AssetOperation, int]:
107
+ """Get the history of deposits, withdrawals, transfers between sub-accounts and testnet claims, newest first, 50 per page.
108
+
109
+ Paged variant of `asset_operations`: Passes each page's token back as `cursor` and stops on the first empty page. Awaitable (flattens every page) or async-iterable (one page at a time).
110
+
111
+ Args:
112
+ id: Only this operation (SDK only).
113
+ type: Only these operation types (repeated `type` query key).
114
+ status: Only these statuses (repeated `status` query key).
115
+ start_time: Only operations from this time (SDK only).
116
+ end_time: Only operations up to this time (SDK only).
117
+ limit: Most operations per page; the docs say 50 per page.
118
+ validate: Override this call's response validation; falls back to the client-level default when omitted.
119
+
120
+ References:
121
+ - [Official docs](https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history)
122
+ """
123
+
124
+ async def next(cursor: int) -> tuple[Sequence[AssetOperation], int | None]:
125
+ response = await self.asset_operations(
126
+ id=id,
127
+ type=type,
128
+ status=status,
129
+ start_time=start_time,
130
+ end_time=end_time,
131
+ limit=limit,
132
+ cursor=(cursor or None),
133
+ validate=validate,
134
+ )
135
+ rows = response.get('data')
136
+ rows = rows if rows is not None else []
137
+ state_0 = response.get('pagination')
138
+ state = state_0.get('cursor') if state_0 is not None else None
139
+ return rows, (state or None) if rows else None
140
+
141
+ return PaginatedResponse(0, next)
142
+
143
+ async def asset_operations(
144
+ self,
145
+ *,
146
+ id: int | None = None,
147
+ type: list[
148
+ Literal[
149
+ 'DEPOSIT',
150
+ 'CLAIM',
151
+ 'TRANSFER',
152
+ 'WITHDRAWAL',
153
+ 'FAST_WITHDRAWAL',
154
+ 'SLOW_WITHDRAWAL',
155
+ ]
156
+ ]
157
+ | None = None,
158
+ status: list[
159
+ Literal['CREATED', 'IN_PROGRESS', 'COMPLETED', 'REJECTED', 'READY_FOR_CLAIM']
160
+ ]
161
+ | None = None,
162
+ start_time: TimestampMillis | None = None,
163
+ end_time: TimestampMillis | None = None,
164
+ cursor: int | None = None,
165
+ limit: int | None = None,
166
+ validate: bool | None = None,
167
+ ) -> AssetOperationsPage:
168
+ """Get the history of deposits, withdrawals, transfers between sub-accounts and testnet claims, newest first, 50 per page.
169
+
170
+ Args:
171
+ id: Only this operation (SDK only).
172
+ type: Only these operation types (repeated `type` query key).
173
+ status: Only these statuses (repeated `status` query key).
174
+ start_time: Only operations from this time (SDK only).
175
+ end_time: Only operations up to this time (SDK only).
176
+ cursor: Continue after this item id: the `pagination.cursor` of the previous page.
177
+ limit: Most operations per page; the docs say 50 per page.
178
+ validate: Override this call's response validation; falls back to the client-level default when omitted.
179
+
180
+ References:
181
+ - [Official docs](https://api.docs.extended.exchange/#get-deposits-withdrawals-transfers-history)
182
+ """
183
+ request: Request = Request()
184
+ if id is not None:
185
+ request['id'] = id
186
+ if type is not None:
187
+ request['type'] = type
188
+ if status is not None:
189
+ request['status'] = status
190
+ if start_time is not None:
191
+ request['startTime'] = start_time
192
+ if end_time is not None:
193
+ request['endTime'] = end_time
194
+ if cursor is not None:
195
+ request['cursor'] = cursor
196
+ if limit is not None:
197
+ request['limit'] = limit
198
+ return await self.request(
199
+ request,
200
+ method='GET',
201
+ path='/user/assetOperations',
202
+ meta={'auth': 'api_key', 'envelope': 'page'},
203
+ validate=validate,
204
+ request_type=Request,
205
+ response_type=AssetOperationsPage,
206
+ )
@@ -0,0 +1,67 @@
1
+ # Generated by typed-dev — see CONTRIBUTING.md.
2
+ from decimal import Decimal
3
+ from typing_extensions import NotRequired, TypedDict
4
+ from typed_extended.core import TimestampMillis
5
+ from typed_extended.core.endpoint.rpc import RpcEndpoint
6
+
7
+
8
+ class Balance(TypedDict):
9
+ """Collateral balance, equity, margin and exposure of the sub-account."""
10
+
11
+ collateralName: str
12
+ """Collateral asset name."""
13
+ balance: Decimal
14
+ """Wallet balance: deposits - withdrawals + realised PnL, in the collateral asset."""
15
+ equity: Decimal
16
+ """Equity: balance + unrealised PnL, plus the equity contribution of spot holdings."""
17
+ availableForTrade: Decimal
18
+ """Available balance for trading: equity - initial margin requirement."""
19
+ availableForWithdrawal: Decimal
20
+ """Available balance for withdrawal of the collateral asset; includes unrealised profit only from markets with `tradingConfig.uPnlWithdrawable`."""
21
+ unrealisedPnl: Decimal
22
+ """Unrealised PnL of the account."""
23
+ withdrawableUnrealisedPnl: Decimal
24
+ """Portion of `unrealisedPnl` held on markets with `tradingConfig.uPnlWithdrawable` (signed)."""
25
+ initialMargin: Decimal
26
+ """Collateral used by open positions and orders."""
27
+ marginRatio: Decimal
28
+ """Maintenance margin requirement / equity; liquidation above 100%."""
29
+ exposure: Decimal
30
+ """Sum of all position values."""
31
+ leverage: Decimal
32
+ """Account leverage: exposure / equity."""
33
+ spotEquity: NotRequired[Decimal]
34
+ """Sum of `equityContribution` over spot balances (`0` without spot holdings)."""
35
+ spotEquityForAvailableForTrade: NotRequired[Decimal]
36
+ """Portion of `spotEquity` counted towards `availableForTrade`."""
37
+ collateralReservedForSpotOrders: NotRequired[Decimal]
38
+ """Collateral reserved by open spot buy orders."""
39
+ updatedTime: TimestampMillis
40
+ """When the server generated the balance."""
41
+
42
+
43
+ class Request(TypedDict):
44
+ """No parameters."""
45
+
46
+
47
+ class BalanceEndpoint(RpcEndpoint):
48
+ """Get the sub-account's collateral balance, equity, available-for-trade/withdrawal, margin, exposure and spot equity. The venue answers `404` (raised as `BadRequest`) when the balance is 0."""
49
+
50
+ async def balance(self, *, validate: bool | None = None) -> Balance:
51
+ """Get the sub-account's collateral balance, equity, available-for-trade/withdrawal, margin, exposure and spot equity. The venue answers `404` (raised as `BadRequest`) when the balance is 0.
52
+
53
+ Args:
54
+ validate: Override this call's response validation; falls back to the client-level default when omitted.
55
+
56
+ References:
57
+ - [Official docs](https://api.docs.extended.exchange/#get-balance)
58
+ """
59
+ return await self.request(
60
+ Request(),
61
+ method='GET',
62
+ path='/user/balance',
63
+ meta={'auth': 'api_key'},
64
+ validate=validate,
65
+ request_type=Request,
66
+ response_type=Balance,
67
+ )
@@ -0,0 +1,65 @@
1
+ # Generated by typed-dev — see CONTRIBUTING.md.
2
+ from decimal import Decimal
3
+ from typing_extensions import NotRequired, TypedDict
4
+ from typed_extended.core.endpoint.rpc import RpcEndpoint
5
+
6
+
7
+ class Request(TypedDict):
8
+ """Markets and builder."""
9
+
10
+ market: NotRequired[list[str]]
11
+ """Only these markets (repeated `market` query key); every market when omitted."""
12
+ builderId: NotRequired[int]
13
+ """Builder client id whose fee rate to include."""
14
+
15
+
16
+ class TradingFee(TypedDict):
17
+ """Fee rates on one market."""
18
+
19
+ market: str
20
+ """Market name."""
21
+ makerFeeRate: Decimal
22
+ """Maker fee rate."""
23
+ takerFeeRate: Decimal
24
+ """Taker fee rate."""
25
+ builderFeeRate: Decimal
26
+ """Fee rate of the given builder (`0` without one)."""
27
+
28
+
29
+ Response = list[TradingFee]
30
+
31
+
32
+ class Fees(RpcEndpoint):
33
+ """Get the sub-account's maker and taker fee rates per market (and a builder's fee rate). An order's `fee` is capped by these."""
34
+
35
+ async def fees(
36
+ self,
37
+ market: list[str] | None = None,
38
+ *,
39
+ builder_id: int | None = None,
40
+ validate: bool | None = None,
41
+ ) -> Response:
42
+ """Get the sub-account's maker and taker fee rates per market (and a builder's fee rate). An order's `fee` is capped by these.
43
+
44
+ Args:
45
+ market: Only these markets (repeated `market` query key); every market when omitted.
46
+ builder_id: Builder client id whose fee rate to include.
47
+ validate: Override this call's response validation; falls back to the client-level default when omitted.
48
+
49
+ References:
50
+ - [Official docs](https://api.docs.extended.exchange/#get-fees)
51
+ """
52
+ request: Request = Request()
53
+ if market is not None:
54
+ request['market'] = market
55
+ if builder_id is not None:
56
+ request['builderId'] = builder_id
57
+ return await self.request(
58
+ request,
59
+ method='GET',
60
+ path='/user/fees',
61
+ meta={'auth': 'api_key'},
62
+ validate=validate,
63
+ request_type=Request,
64
+ response_type=Response,
65
+ )