typed-risex 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.
- typed_risex-0.1.0/LICENSE +21 -0
- typed_risex-0.1.0/PKG-INFO +101 -0
- typed_risex-0.1.0/README.md +80 -0
- typed_risex-0.1.0/pyproject.toml +32 -0
- typed_risex-0.1.0/setup.cfg +4 -0
- typed_risex-0.1.0/src/typed_risex/__init__.py +14 -0
- typed_risex-0.1.0/src/typed_risex/__init__.pyi +25 -0
- typed_risex-0.1.0/src/typed_risex/account/__init__.py +36 -0
- typed_risex-0.1.0/src/typed_risex/account/balance.py +47 -0
- typed_risex-0.1.0/src/typed_risex/account/cross_margin_balance.py +47 -0
- typed_risex-0.1.0/src/typed_risex/account/deposit.py +60 -0
- typed_risex-0.1.0/src/typed_risex/account/fees.py +81 -0
- typed_risex-0.1.0/src/typed_risex/account/funding_payments.py +169 -0
- typed_risex-0.1.0/src/typed_risex/account/position.py +51 -0
- typed_risex-0.1.0/src/typed_risex/account/position_funding.py +59 -0
- typed_risex-0.1.0/src/typed_risex/account/positions.py +154 -0
- typed_risex-0.1.0/src/typed_risex/account/trade_history.py +195 -0
- typed_risex-0.1.0/src/typed_risex/account/transfer_history.py +169 -0
- typed_risex-0.1.0/src/typed_risex/account/update_isolated_margin.py +55 -0
- typed_risex-0.1.0/src/typed_risex/account/update_leverage.py +55 -0
- typed_risex-0.1.0/src/typed_risex/account/update_margin_mode.py +55 -0
- typed_risex-0.1.0/src/typed_risex/affiliate/__init__.py +12 -0
- typed_risex-0.1.0/src/typed_risex/affiliate/dashboard.py +110 -0
- typed_risex-0.1.0/src/typed_risex/affiliate/payouts.py +103 -0
- typed_risex-0.1.0/src/typed_risex/affiliate/referrals.py +102 -0
- typed_risex-0.1.0/src/typed_risex/auth/__init__.py +38 -0
- typed_risex-0.1.0/src/typed_risex/auth/allowance.py +37 -0
- typed_risex-0.1.0/src/typed_risex/auth/allowance_status.py +49 -0
- typed_risex-0.1.0/src/typed_risex/auth/approve_single.py +68 -0
- typed_risex-0.1.0/src/typed_risex/auth/eip712_domain.py +38 -0
- typed_risex-0.1.0/src/typed_risex/auth/login.py +25 -0
- typed_risex-0.1.0/src/typed_risex/auth/login_nonce.py +32 -0
- typed_risex-0.1.0/src/typed_risex/auth/logout.py +43 -0
- typed_risex-0.1.0/src/typed_risex/auth/nonce_state.py +47 -0
- typed_risex-0.1.0/src/typed_risex/auth/refresh.py +37 -0
- typed_risex-0.1.0/src/typed_risex/auth/register_signer.py +68 -0
- typed_risex-0.1.0/src/typed_risex/auth/revoke_session.py +46 -0
- typed_risex-0.1.0/src/typed_risex/auth/revoke_signer.py +55 -0
- typed_risex-0.1.0/src/typed_risex/auth/session_key_status.py +52 -0
- typed_risex-0.1.0/src/typed_risex/auth/sessions.py +53 -0
- typed_risex-0.1.0/src/typed_risex/competitions/__init__.py +18 -0
- typed_risex-0.1.0/src/typed_risex/competitions/all.py +135 -0
- typed_risex-0.1.0/src/typed_risex/competitions/get.py +58 -0
- typed_risex-0.1.0/src/typed_risex/competitions/leaderboard.py +186 -0
- typed_risex-0.1.0/src/typed_risex/competitions/leaderboard_entry.py +99 -0
- typed_risex-0.1.0/src/typed_risex/competitions/my_entry.py +105 -0
- typed_risex-0.1.0/src/typed_risex/competitions/registration_status.py +62 -0
- typed_risex-0.1.0/src/typed_risex/competitions/trader.py +81 -0
- typed_risex-0.1.0/src/typed_risex/core/__init__.py +5 -0
- typed_risex-0.1.0/src/typed_risex/core/__init__.pyi +41 -0
- typed_risex-0.1.0/src/typed_risex/core/auth.py +203 -0
- typed_risex-0.1.0/src/typed_risex/core/client.py +102 -0
- typed_risex-0.1.0/src/typed_risex/core/eip712.py +256 -0
- typed_risex-0.1.0/src/typed_risex/core/endpoint/__init__.py +1 -0
- typed_risex-0.1.0/src/typed_risex/core/endpoint/rpc.py +126 -0
- typed_risex-0.1.0/src/typed_risex/core/endpoint/stream.py +104 -0
- typed_risex-0.1.0/src/typed_risex/core/endpoint/wire.py +92 -0
- typed_risex-0.1.0/src/typed_risex/core/envelope.py +128 -0
- typed_risex-0.1.0/src/typed_risex/core/exc.py +23 -0
- typed_risex-0.1.0/src/typed_risex/core/networks.py +41 -0
- typed_risex-0.1.0/src/typed_risex/core/nonces.py +50 -0
- typed_risex-0.1.0/src/typed_risex/core/signing.py +514 -0
- typed_risex-0.1.0/src/typed_risex/core/transport/__init__.py +1 -0
- typed_risex-0.1.0/src/typed_risex/core/transport/http.py +138 -0
- typed_risex-0.1.0/src/typed_risex/core/transport/ws.py +262 -0
- typed_risex-0.1.0/src/typed_risex/core/types.py +42 -0
- typed_risex-0.1.0/src/typed_risex/main.py +121 -0
- typed_risex-0.1.0/src/typed_risex/markets/__init__.py +16 -0
- typed_risex-0.1.0/src/typed_risex/markets/all.py +161 -0
- typed_risex-0.1.0/src/typed_risex/markets/candles.py +92 -0
- typed_risex-0.1.0/src/typed_risex/markets/funding_rate_history.py +142 -0
- typed_risex-0.1.0/src/typed_risex/markets/orderbook.py +62 -0
- typed_risex-0.1.0/src/typed_risex/markets/trade_history.py +137 -0
- typed_risex-0.1.0/src/typed_risex/orders/__init__.py +36 -0
- typed_risex-0.1.0/src/typed_risex/orders/builders/__init__.py +12 -0
- typed_risex-0.1.0/src/typed_risex/orders/builders/active.py +33 -0
- typed_risex-0.1.0/src/typed_risex/orders/builders/approve_fee.py +52 -0
- typed_risex-0.1.0/src/typed_risex/orders/builders/get.py +62 -0
- typed_risex-0.1.0/src/typed_risex/orders/cancel.py +54 -0
- typed_risex-0.1.0/src/typed_risex/orders/cancel_all.py +50 -0
- typed_risex-0.1.0/src/typed_risex/orders/get.py +58 -0
- typed_risex-0.1.0/src/typed_risex/orders/history.py +195 -0
- typed_risex-0.1.0/src/typed_risex/orders/open.py +108 -0
- typed_risex-0.1.0/src/typed_risex/orders/place.py +60 -0
- typed_risex-0.1.0/src/typed_risex/orders/tpsl/__init__.py +13 -0
- typed_risex-0.1.0/src/typed_risex/orders/tpsl/cancel.py +55 -0
- typed_risex-0.1.0/src/typed_risex/orders/tpsl/cancel_all.py +52 -0
- typed_risex-0.1.0/src/typed_risex/orders/tpsl/place.py +100 -0
- typed_risex-0.1.0/src/typed_risex/orders/tpsl/query.py +193 -0
- typed_risex-0.1.0/src/typed_risex/points/__init__.py +13 -0
- typed_risex-0.1.0/src/typed_risex/points/current_epoch.py +35 -0
- typed_risex-0.1.0/src/typed_risex/points/history.py +82 -0
- typed_risex-0.1.0/src/typed_risex/points/tiers.py +33 -0
- typed_risex-0.1.0/src/typed_risex/points/wallet.py +54 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/__init__.py +28 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/chart.py +65 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/detail_preview.py +56 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/details.py +48 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/equity_chart.py +63 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/header.py +52 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/pnl_calendar.py +93 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/realized_pnl.py +163 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/stats.py +86 -0
- typed_risex-0.1.0/src/typed_risex/portfolio/volume_chart.py +63 -0
- typed_risex-0.1.0/src/typed_risex/py.typed +0 -0
- typed_risex-0.1.0/src/typed_risex/schemas.py +707 -0
- typed_risex-0.1.0/src/typed_risex/stats/__init__.py +24 -0
- typed_risex-0.1.0/src/typed_risex/stats/leaderboard.py +73 -0
- typed_risex-0.1.0/src/typed_risex/stats/trade_count.py +72 -0
- typed_risex-0.1.0/src/typed_risex/stats/user_trading.py +73 -0
- typed_risex-0.1.0/src/typed_risex/stats/user_volume.py +95 -0
- typed_risex-0.1.0/src/typed_risex/stats/user_volume_leaderboard.py +115 -0
- typed_risex-0.1.0/src/typed_risex/stats/volume.py +73 -0
- typed_risex-0.1.0/src/typed_risex/stats/wallet_count.py +38 -0
- typed_risex-0.1.0/src/typed_risex/streams/__init__.py +28 -0
- typed_risex-0.1.0/src/typed_risex/streams/account.py +87 -0
- typed_risex-0.1.0/src/typed_risex/streams/expected_funding_rate.py +72 -0
- typed_risex-0.1.0/src/typed_risex/streams/fills.py +119 -0
- typed_risex-0.1.0/src/typed_risex/streams/funding.py +87 -0
- typed_risex-0.1.0/src/typed_risex/streams/oracle.py +83 -0
- typed_risex-0.1.0/src/typed_risex/streams/orderbook.py +94 -0
- typed_risex-0.1.0/src/typed_risex/streams/orders.py +92 -0
- typed_risex-0.1.0/src/typed_risex/streams/positions.py +90 -0
- typed_risex-0.1.0/src/typed_risex/streams/trades.py +93 -0
- typed_risex-0.1.0/src/typed_risex/system/__init__.py +13 -0
- typed_risex-0.1.0/src/typed_risex/system/client_info.py +40 -0
- typed_risex-0.1.0/src/typed_risex/system/config.py +111 -0
- typed_risex-0.1.0/src/typed_risex/system/decode_tx.py +62 -0
- typed_risex-0.1.0/src/typed_risex/system/error_codes.py +110 -0
- typed_risex-0.1.0/src/typed_risex.egg-info/PKG-INFO +101 -0
- typed_risex-0.1.0/src/typed_risex.egg-info/SOURCES.txt +132 -0
- typed_risex-0.1.0/src/typed_risex.egg-info/dependency_links.txt +1 -0
- typed_risex-0.1.0/src/typed_risex.egg-info/requires.txt +3 -0
- typed_risex-0.1.0/src/typed_risex.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,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: typed-risex
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A fully typed, validated async client for the RISEx 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/risex
|
|
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.14.0
|
|
18
|
+
Requires-Dist: lazy-loader
|
|
19
|
+
Requires-Dist: eth-account>=0.13
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Typed RISEx
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<em>A fully typed, validated async client for the RISEx API.</em>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="https://pypi.org/project/typed-risex/">
|
|
30
|
+
<img src="https://img.shields.io/pypi/v/typed-risex.svg" alt="PyPI version">
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://pypi.org/project/typed-risex/">
|
|
33
|
+
<img src="https://img.shields.io/pypi/pyversions/typed-risex.svg" alt="Python versions">
|
|
34
|
+
</a>
|
|
35
|
+
<a href="https://tribulnation.com/typed/risex">
|
|
36
|
+
<img src="https://img.shields.io/badge/docs-live-black" alt="Docs">
|
|
37
|
+
</a>
|
|
38
|
+
<a href="LICENSE">
|
|
39
|
+
<img src="https://img.shields.io/pypi/l/typed-risex.svg" alt="License">
|
|
40
|
+
</a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
- **Documentation**: [https://tribulnation.com/typed/risex](https://tribulnation.com/typed/risex)
|
|
46
|
+
- **Source Code**: [https://github.com/tribulnation/typed/tree/main/packages/risex](https://github.com/tribulnation/typed/tree/main/packages/risex)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from typed_risex import RISEx
|
|
52
|
+
|
|
53
|
+
async with RISEx.new(public=True) as client:
|
|
54
|
+
markets = await client.markets.all()
|
|
55
|
+
book = await client.markets.orderbook(market_id=1, limit=5)
|
|
56
|
+
print(markets['markets'][0]['config']['name'], book['bids'][0]['price'])
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Why Typed RISEx?
|
|
60
|
+
|
|
61
|
+
- **🎯 Precise Types**: Typed requests and responses for every REST endpoint and WebSocket channel, with order bodies typed as limit/market unions, not `dict`/`Any`.
|
|
62
|
+
- **✅ Runtime Validation**: Responses validated by default, with prices and amounts as `Decimal` (or `''` where RISEx sends no value, and raw 10^18-scaled `int`s where it returns on-chain values; a few affiliate, leaderboard and points amounts with no observed value stay `str`), and timestamps as `datetime` with a few exceptions (see [Timestamps](https://tribulnation.com/typed/risex/reference/timestamps)).
|
|
63
|
+
- **⚡ Async First**: Async HTTP and a single multiplexed WebSocket feed, with EIP-712 permits, nonces and JWT sessions signed for you.
|
|
64
|
+
- **📚 Full Surface**: The full trading, account and market-data API: markets, orders, TP/SL, positions and margin, portfolio, signers and sessions, points, competition and leaderboard reads, and stats.
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install typed-risex
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Setup
|
|
73
|
+
|
|
74
|
+
RISEx has no API keys: you trade with an EVM account key plus a registered signer (session) key. See [Authenticated Setup](https://tribulnation.com/typed/risex/authenticated-setup) to create both on testnet, claim test USDC, and register the signer.
|
|
75
|
+
|
|
76
|
+
## How To
|
|
77
|
+
|
|
78
|
+
- [Fetch Market Data](https://tribulnation.com/typed/risex/how-to/fetch-market-data)
|
|
79
|
+
- [Fetch Account Data](https://tribulnation.com/typed/risex/how-to/fetch-account-data)
|
|
80
|
+
- [Place & Manage Orders](https://tribulnation.com/typed/risex/how-to/place-and-manage-orders)
|
|
81
|
+
- [Manage Leverage & Margin](https://tribulnation.com/typed/risex/how-to/manage-leverage-and-margin)
|
|
82
|
+
- [Paginate Through Results](https://tribulnation.com/typed/risex/how-to/paginate-through-results)
|
|
83
|
+
- [Listen To Live Streams](https://tribulnation.com/typed/risex/how-to/listen-to-live-streams)
|
|
84
|
+
|
|
85
|
+
## Reference
|
|
86
|
+
|
|
87
|
+
- [Authenticated Setup](https://tribulnation.com/typed/risex/authenticated-setup)
|
|
88
|
+
- [Async Usage](https://tribulnation.com/typed/risex/reference/async-usage)
|
|
89
|
+
- [Error Handling](https://tribulnation.com/typed/risex/reference/error-handling)
|
|
90
|
+
- [Environment Variables](https://tribulnation.com/typed/risex/reference/env-vars)
|
|
91
|
+
- [Timestamps](https://tribulnation.com/typed/risex/reference/timestamps)
|
|
92
|
+
|
|
93
|
+
## Design Philosophy
|
|
94
|
+
|
|
95
|
+
Typed RISEx follows the principles outlined in [this blog post](https://tribulnation.com/blog/clients).
|
|
96
|
+
|
|
97
|
+
*Details matter. Developer experience matters.*
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Typed RISEx
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<em>A fully typed, validated async client for the RISEx API.</em>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://pypi.org/project/typed-risex/">
|
|
9
|
+
<img src="https://img.shields.io/pypi/v/typed-risex.svg" alt="PyPI version">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://pypi.org/project/typed-risex/">
|
|
12
|
+
<img src="https://img.shields.io/pypi/pyversions/typed-risex.svg" alt="Python versions">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://tribulnation.com/typed/risex">
|
|
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-risex.svg" alt="License">
|
|
19
|
+
</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
- **Documentation**: [https://tribulnation.com/typed/risex](https://tribulnation.com/typed/risex)
|
|
25
|
+
- **Source Code**: [https://github.com/tribulnation/typed/tree/main/packages/risex](https://github.com/tribulnation/typed/tree/main/packages/risex)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from typed_risex import RISEx
|
|
31
|
+
|
|
32
|
+
async with RISEx.new(public=True) as client:
|
|
33
|
+
markets = await client.markets.all()
|
|
34
|
+
book = await client.markets.orderbook(market_id=1, limit=5)
|
|
35
|
+
print(markets['markets'][0]['config']['name'], book['bids'][0]['price'])
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Why Typed RISEx?
|
|
39
|
+
|
|
40
|
+
- **🎯 Precise Types**: Typed requests and responses for every REST endpoint and WebSocket channel, with order bodies typed as limit/market unions, not `dict`/`Any`.
|
|
41
|
+
- **✅ Runtime Validation**: Responses validated by default, with prices and amounts as `Decimal` (or `''` where RISEx sends no value, and raw 10^18-scaled `int`s where it returns on-chain values; a few affiliate, leaderboard and points amounts with no observed value stay `str`), and timestamps as `datetime` with a few exceptions (see [Timestamps](https://tribulnation.com/typed/risex/reference/timestamps)).
|
|
42
|
+
- **⚡ Async First**: Async HTTP and a single multiplexed WebSocket feed, with EIP-712 permits, nonces and JWT sessions signed for you.
|
|
43
|
+
- **📚 Full Surface**: The full trading, account and market-data API: markets, orders, TP/SL, positions and margin, portfolio, signers and sessions, points, competition and leaderboard reads, and stats.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install typed-risex
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Setup
|
|
52
|
+
|
|
53
|
+
RISEx has no API keys: you trade with an EVM account key plus a registered signer (session) key. See [Authenticated Setup](https://tribulnation.com/typed/risex/authenticated-setup) to create both on testnet, claim test USDC, and register the signer.
|
|
54
|
+
|
|
55
|
+
## How To
|
|
56
|
+
|
|
57
|
+
- [Fetch Market Data](https://tribulnation.com/typed/risex/how-to/fetch-market-data)
|
|
58
|
+
- [Fetch Account Data](https://tribulnation.com/typed/risex/how-to/fetch-account-data)
|
|
59
|
+
- [Place & Manage Orders](https://tribulnation.com/typed/risex/how-to/place-and-manage-orders)
|
|
60
|
+
- [Manage Leverage & Margin](https://tribulnation.com/typed/risex/how-to/manage-leverage-and-margin)
|
|
61
|
+
- [Paginate Through Results](https://tribulnation.com/typed/risex/how-to/paginate-through-results)
|
|
62
|
+
- [Listen To Live Streams](https://tribulnation.com/typed/risex/how-to/listen-to-live-streams)
|
|
63
|
+
|
|
64
|
+
## Reference
|
|
65
|
+
|
|
66
|
+
- [Authenticated Setup](https://tribulnation.com/typed/risex/authenticated-setup)
|
|
67
|
+
- [Async Usage](https://tribulnation.com/typed/risex/reference/async-usage)
|
|
68
|
+
- [Error Handling](https://tribulnation.com/typed/risex/reference/error-handling)
|
|
69
|
+
- [Environment Variables](https://tribulnation.com/typed/risex/reference/env-vars)
|
|
70
|
+
- [Timestamps](https://tribulnation.com/typed/risex/reference/timestamps)
|
|
71
|
+
|
|
72
|
+
## Design Philosophy
|
|
73
|
+
|
|
74
|
+
Typed RISEx follows the principles outlined in [this blog post](https://tribulnation.com/blog/clients).
|
|
75
|
+
|
|
76
|
+
*Details matter. Developer experience matters.*
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "typed-risex"
|
|
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 RISEx 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.14.0", "lazy-loader", "eth-account>=0.13",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.10"
|
|
24
|
+
readme = {file="README.md", content-type="text/markdown"}
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.package-data]
|
|
27
|
+
"typed_risex" = ["py.typed", "*.pyi", "**/*.pyi"]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Repository = "https://github.com/tribulnation/typed"
|
|
31
|
+
Documentation = "https://tribulnation.com/typed/risex"
|
|
32
|
+
Website = "https://tribulnation.com/typed"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""A fully typed, validated async client for the RISEx API.
|
|
2
|
+
|
|
3
|
+
Examples:
|
|
4
|
+
```python
|
|
5
|
+
from typed_risex import RISEx
|
|
6
|
+
|
|
7
|
+
async with RISEx.new(public=True) as client:
|
|
8
|
+
book = await client.markets.orderbook(market_id=1, limit=5)
|
|
9
|
+
```
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import lazy_loader as lazy
|
|
13
|
+
|
|
14
|
+
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from .main import RISEx
|
|
2
|
+
from .core import (
|
|
3
|
+
Error,
|
|
4
|
+
NetworkError,
|
|
5
|
+
ValidationError,
|
|
6
|
+
ApiError,
|
|
7
|
+
BadRequest,
|
|
8
|
+
AuthError,
|
|
9
|
+
RateLimited,
|
|
10
|
+
LogicError,
|
|
11
|
+
Network,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
'RISEx',
|
|
16
|
+
'Error',
|
|
17
|
+
'NetworkError',
|
|
18
|
+
'ValidationError',
|
|
19
|
+
'ApiError',
|
|
20
|
+
'BadRequest',
|
|
21
|
+
'AuthError',
|
|
22
|
+
'RateLimited',
|
|
23
|
+
'LogicError',
|
|
24
|
+
'Network',
|
|
25
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Generated by typed-dev — see CONTRIBUTING.md.
|
|
2
|
+
from .balance import BalanceEndpoint
|
|
3
|
+
from .cross_margin_balance import CrossMarginBalanceEndpoint
|
|
4
|
+
from .deposit import Deposit
|
|
5
|
+
from .fees import Fees
|
|
6
|
+
from .funding_payments import FundingPayments
|
|
7
|
+
from .position import PositionEndpoint
|
|
8
|
+
from .position_funding import PositionFundingEndpoint
|
|
9
|
+
from .positions import Positions
|
|
10
|
+
from .trade_history import TradeHistory
|
|
11
|
+
from .transfer_history import TransferHistoryEndpoint
|
|
12
|
+
from .update_isolated_margin import UpdateIsolatedMargin
|
|
13
|
+
from .update_leverage import UpdateLeverage
|
|
14
|
+
from .update_margin_mode import UpdateMarginMode
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Account(
|
|
18
|
+
BalanceEndpoint,
|
|
19
|
+
CrossMarginBalanceEndpoint,
|
|
20
|
+
Deposit,
|
|
21
|
+
Fees,
|
|
22
|
+
FundingPayments,
|
|
23
|
+
PositionEndpoint,
|
|
24
|
+
PositionFundingEndpoint,
|
|
25
|
+
Positions,
|
|
26
|
+
TradeHistory,
|
|
27
|
+
TransferHistoryEndpoint,
|
|
28
|
+
UpdateIsolatedMargin,
|
|
29
|
+
UpdateLeverage,
|
|
30
|
+
UpdateMarginMode,
|
|
31
|
+
):
|
|
32
|
+
"""The account: balances, positions and their funding, trade and transfer history, fees, leverage and margin settings (permit-signed), and the testnet faucet.
|
|
33
|
+
|
|
34
|
+
References:
|
|
35
|
+
- [Upstream docs](https://developer.rise.trade/reference/accountservice_getbalance)
|
|
36
|
+
"""
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Generated by typed-dev — see CONTRIBUTING.md.
|
|
2
|
+
from decimal import Decimal
|
|
3
|
+
from typing_extensions import TypedDict
|
|
4
|
+
from typed_risex.core.endpoint.rpc import RpcEndpoint
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Balance(TypedDict):
|
|
8
|
+
"""The account's token balance."""
|
|
9
|
+
|
|
10
|
+
balance: Decimal
|
|
11
|
+
"""Token balance as string (uint256)"""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Request(TypedDict):
|
|
15
|
+
"""Parameters for reading one token balance of an account."""
|
|
16
|
+
|
|
17
|
+
account: str
|
|
18
|
+
"""Account address to query (hex format)"""
|
|
19
|
+
token: str
|
|
20
|
+
"""Token address to query balance for (hex format)"""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BalanceEndpoint(RpcEndpoint):
|
|
24
|
+
"""Get token balance for an account from the blockchain."""
|
|
25
|
+
|
|
26
|
+
async def balance(
|
|
27
|
+
self, *, account: str, token: str, validate: bool | None = None
|
|
28
|
+
) -> Balance:
|
|
29
|
+
"""Get token balance for an account from the blockchain.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
account: Account address to query (hex format)
|
|
33
|
+
token: Token address to query balance for (hex format)
|
|
34
|
+
validate: Override this call's response validation; falls back to the client-level default when omitted.
|
|
35
|
+
|
|
36
|
+
References:
|
|
37
|
+
- [Official docs](https://developer.rise.trade/reference/accountservice_getbalance)
|
|
38
|
+
"""
|
|
39
|
+
return await self.request(
|
|
40
|
+
Request(account=account, token=token),
|
|
41
|
+
method='GET',
|
|
42
|
+
path='/v1/account/balance',
|
|
43
|
+
meta={},
|
|
44
|
+
validate=validate,
|
|
45
|
+
request_type=Request,
|
|
46
|
+
response_type=Balance,
|
|
47
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Generated by typed-dev — see CONTRIBUTING.md.
|
|
2
|
+
from decimal import Decimal
|
|
3
|
+
from typing_extensions import TypedDict
|
|
4
|
+
from typed_risex.core.endpoint.rpc import RpcEndpoint
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CrossMarginBalance(TypedDict):
|
|
8
|
+
"""The account's cross margin balance, including unrealized PnL."""
|
|
9
|
+
|
|
10
|
+
balance: Decimal
|
|
11
|
+
"""Cross margin balance as string (int256, can be negative if unrealized loss exceeds collateral)"""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Request(TypedDict):
|
|
15
|
+
"""Parameters for reading an account's cross margin balance."""
|
|
16
|
+
|
|
17
|
+
account: str
|
|
18
|
+
"""Account address to query (hex format)"""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CrossMarginBalanceEndpoint(RpcEndpoint):
|
|
22
|
+
"""Get cross margin balance for an account. This includes the collateral balance plus unrealized PnL from all cross margin positions."""
|
|
23
|
+
|
|
24
|
+
async def cross_margin_balance(
|
|
25
|
+
self,
|
|
26
|
+
account: str,
|
|
27
|
+
*,
|
|
28
|
+
validate: bool | None = None,
|
|
29
|
+
) -> CrossMarginBalance:
|
|
30
|
+
"""Get cross margin balance for an account. This includes the collateral balance plus unrealized PnL from all cross margin positions.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
account: Account address to query (hex format)
|
|
34
|
+
validate: Override this call's response validation; falls back to the client-level default when omitted.
|
|
35
|
+
|
|
36
|
+
References:
|
|
37
|
+
- [Official docs](https://developer.rise.trade/reference/accountservice_getcrossmarginbalance)
|
|
38
|
+
"""
|
|
39
|
+
return await self.request(
|
|
40
|
+
Request(account=account),
|
|
41
|
+
method='GET',
|
|
42
|
+
path='/v1/account/cross-margin-balance',
|
|
43
|
+
meta={},
|
|
44
|
+
validate=validate,
|
|
45
|
+
request_type=Request,
|
|
46
|
+
response_type=CrossMarginBalance,
|
|
47
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Generated by typed-dev — see CONTRIBUTING.md.
|
|
2
|
+
from typing_extensions import NotRequired, TypedDict
|
|
3
|
+
from typed_risex.core.endpoint.rpc import RpcEndpoint
|
|
4
|
+
from typed_risex.schemas import TransactionReceipt
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Request(TypedDict):
|
|
8
|
+
"""The account to credit with testnet faucet USDC, and optionally the amount."""
|
|
9
|
+
|
|
10
|
+
account: str
|
|
11
|
+
"""Account address to deposit to (hex format)"""
|
|
12
|
+
amount: NotRequired[str]
|
|
13
|
+
"""Amount to deposit in USDC (decimal format, e.g., "100" = 100 USDC, "100.50" = 100.50 USDC)"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DepositResult(TypedDict):
|
|
17
|
+
"""Transaction details of the deposit."""
|
|
18
|
+
|
|
19
|
+
transaction_hash: str
|
|
20
|
+
"""Hash of the faucet transfer transaction."""
|
|
21
|
+
block_number: int
|
|
22
|
+
"""Block number where deposit was confirmed"""
|
|
23
|
+
receipt: TransactionReceipt | None
|
|
24
|
+
"""Blockchain transaction details."""
|
|
25
|
+
success: bool
|
|
26
|
+
"""Success status"""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Deposit(RpcEndpoint):
|
|
30
|
+
"""Deposit USDC to an account on the blockchain (faucet). The API service pays gas on behalf of the user."""
|
|
31
|
+
|
|
32
|
+
async def deposit(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
account: str,
|
|
36
|
+
amount: str | None = None,
|
|
37
|
+
validate: bool | None = None,
|
|
38
|
+
) -> DepositResult:
|
|
39
|
+
"""Deposit USDC to an account on the blockchain (faucet). The API service pays gas on behalf of the user.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
account: Account address to deposit to (hex format)
|
|
43
|
+
amount: Amount to deposit in USDC (decimal format, e.g., "100" = 100 USDC, "100.50" = 100.50 USDC)
|
|
44
|
+
validate: Override this call's response validation; falls back to the client-level default when omitted.
|
|
45
|
+
|
|
46
|
+
References:
|
|
47
|
+
- [Official docs](https://developer.rise.trade/reference/accountservice_depositusdc)
|
|
48
|
+
"""
|
|
49
|
+
request: Request = Request(account=account)
|
|
50
|
+
if amount is not None:
|
|
51
|
+
request['amount'] = amount
|
|
52
|
+
return await self.request(
|
|
53
|
+
request,
|
|
54
|
+
method='POST',
|
|
55
|
+
path='/v1/account/deposit',
|
|
56
|
+
meta={},
|
|
57
|
+
validate=validate,
|
|
58
|
+
request_type=Request,
|
|
59
|
+
response_type=DepositResult,
|
|
60
|
+
)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Generated by typed-dev — see CONTRIBUTING.md.
|
|
2
|
+
from decimal import Decimal
|
|
3
|
+
from typing_extensions import Literal, NotRequired, TypedDict
|
|
4
|
+
from typed_risex.core import TimestampIso
|
|
5
|
+
from typed_risex.core.endpoint.rpc import RpcEndpoint
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FeeScheduleEntry(TypedDict):
|
|
9
|
+
"""One fee tier: the volume at which it starts and its maker and taker rates."""
|
|
10
|
+
|
|
11
|
+
tier: int
|
|
12
|
+
"""Fee tier number."""
|
|
13
|
+
threshold_usd: Decimal
|
|
14
|
+
"""Weighted 14-day USD volume at which this tier starts (`0.00` for the entry tier)."""
|
|
15
|
+
taker_bps: float
|
|
16
|
+
"""Taker fee, in basis points."""
|
|
17
|
+
maker_bps: float
|
|
18
|
+
"""Maker fee, in basis points (negative is a rebate)."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class NextTierProgress(TypedDict):
|
|
22
|
+
"""The tier above the current one and the volume still needed to reach it."""
|
|
23
|
+
|
|
24
|
+
tier: int
|
|
25
|
+
"""Fee tier number."""
|
|
26
|
+
threshold_usd: Decimal
|
|
27
|
+
"""Weighted 14-day USD volume at which this tier starts."""
|
|
28
|
+
remaining_usd: Decimal
|
|
29
|
+
"""USD volume the caller still needs to reach this tier."""
|
|
30
|
+
progress_pct: float
|
|
31
|
+
"""0-100 scale, e.g. 38.9 = 38.9% of the way to next_tier"""
|
|
32
|
+
taker_bps: float
|
|
33
|
+
"""Taker fee, in basis points."""
|
|
34
|
+
maker_bps: float
|
|
35
|
+
"""Maker fee, in basis points (negative is a rebate)."""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class UserFees(TypedDict):
|
|
39
|
+
"""Get my fees."""
|
|
40
|
+
|
|
41
|
+
tier: int
|
|
42
|
+
"""The caller's current fee tier number (`1` is the entry tier)."""
|
|
43
|
+
taker_bps: float
|
|
44
|
+
"""Taker fee, in basis points."""
|
|
45
|
+
maker_bps: float
|
|
46
|
+
"""Maker fee, in basis points (negative is a rebate)."""
|
|
47
|
+
weighted_14d_volume_usd: Decimal
|
|
48
|
+
"""The caller's weighted 14-day trading volume in USD, as of the last daily cutover."""
|
|
49
|
+
applied_at: TimestampIso | Literal['']
|
|
50
|
+
"""When the current tier took effect on-chain (RFC 3339); empty if never synced."""
|
|
51
|
+
next_tier: NextTierProgress
|
|
52
|
+
schedule: list[FeeScheduleEntry]
|
|
53
|
+
"""Every fee tier, from the entry tier up."""
|
|
54
|
+
trial_tier: NotRequired[int]
|
|
55
|
+
"""present only if an active trial exceeds the earned tier"""
|
|
56
|
+
trial_ends_at: TimestampIso | Literal['']
|
|
57
|
+
"""End of an active fee-tier trial (RFC 3339); empty when there is none."""
|
|
58
|
+
earned_tier: int
|
|
59
|
+
"""the tier the account reverts to when any active trial ends"""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Fees(RpcEndpoint):
|
|
63
|
+
"""Get the caller's current fee tier, taker/maker bps, 14d weighted volume as of the last daily cutover, next-tier progress, and the full fee schedule. Requires JWT; always scoped to the caller's own account."""
|
|
64
|
+
|
|
65
|
+
async def fees(self, *, validate: bool | None = None) -> UserFees:
|
|
66
|
+
"""Get the caller's current fee tier, taker/maker bps, 14d weighted volume as of the last daily cutover, next-tier progress, and the full fee schedule. Requires JWT; always scoped to the caller's own account.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
validate: Override this call's response validation; falls back to the client-level default when omitted.
|
|
70
|
+
|
|
71
|
+
References:
|
|
72
|
+
- [Official docs](https://developer.rise.trade/reference/feetierservice_getuserfees)
|
|
73
|
+
"""
|
|
74
|
+
return await self.request(
|
|
75
|
+
None,
|
|
76
|
+
method='GET',
|
|
77
|
+
path='/v1/user/fees',
|
|
78
|
+
meta={'auth': 'jwt'},
|
|
79
|
+
validate=validate,
|
|
80
|
+
response_type=UserFees,
|
|
81
|
+
)
|