liquidtrading-python 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.
- liquidtrading_python-0.1.0/.gitignore +8 -0
- liquidtrading_python-0.1.0/.python-version +1 -0
- liquidtrading_python-0.1.0/.uv-cache/.gitignore +1 -0
- liquidtrading_python-0.1.0/.uv-cache/.lock +0 -0
- liquidtrading_python-0.1.0/.uv-cache/CACHEDIR.TAG +1 -0
- liquidtrading_python-0.1.0/.uv-cache/sdists-v9/.git +0 -0
- liquidtrading_python-0.1.0/.uv-cache/sdists-v9/.gitignore +0 -0
- liquidtrading_python-0.1.0/PKG-INFO +180 -0
- liquidtrading_python-0.1.0/PUBLISHING.md +104 -0
- liquidtrading_python-0.1.0/README.md +167 -0
- liquidtrading_python-0.1.0/docs/SDK.md +581 -0
- liquidtrading_python-0.1.0/examples/smoke_demo.py +5 -0
- liquidtrading_python-0.1.0/liquid/__init__.py +23 -0
- liquidtrading_python-0.1.0/liquidtrading/__init__.py +92 -0
- liquidtrading_python-0.1.0/liquidtrading/auth.py +182 -0
- liquidtrading_python-0.1.0/liquidtrading/client.py +476 -0
- liquidtrading_python-0.1.0/liquidtrading/constants.py +15 -0
- liquidtrading_python-0.1.0/liquidtrading/demo.py +91 -0
- liquidtrading_python-0.1.0/liquidtrading/errors.py +208 -0
- liquidtrading_python-0.1.0/liquidtrading/http.py +237 -0
- liquidtrading_python-0.1.0/liquidtrading/models.py +296 -0
- liquidtrading_python-0.1.0/pyproject.toml +34 -0
- liquidtrading_python-0.1.0/scripts/create_test_keys.py +77 -0
- liquidtrading_python-0.1.0/scripts/run_smoke_demo.sh +24 -0
- liquidtrading_python-0.1.0/tests/__init__.py +0 -0
- liquidtrading_python-0.1.0/tests/conftest.py +18 -0
- liquidtrading_python-0.1.0/tests/package_smoke_test.py +17 -0
- liquidtrading_python-0.1.0/tests/test_auth.py +231 -0
- liquidtrading_python-0.1.0/tests/test_client.py +272 -0
- liquidtrading_python-0.1.0/tests/test_compat_imports.py +10 -0
- liquidtrading_python-0.1.0/tests/test_demo.py +104 -0
- liquidtrading_python-0.1.0/tests/test_errors.py +189 -0
- liquidtrading_python-0.1.0/tests/test_http.py +267 -0
- liquidtrading_python-0.1.0/tests/test_integration.py +131 -0
- liquidtrading_python-0.1.0/tests/test_models.py +206 -0
- liquidtrading_python-0.1.0/tests/test_package_exports.py +11 -0
- liquidtrading_python-0.1.0/uv.lock +371 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Signature: 8a477f597d28d172789f06886806bc55
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: liquidtrading-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Liquid trading API
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Requires-Dist: httpx>=0.25.0
|
|
8
|
+
Provides-Extra: dev
|
|
9
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
10
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
11
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# liquidtrading-python
|
|
15
|
+
|
|
16
|
+
Official Python SDK for the Liquid trading API.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install liquidtrading-python
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv add liquidtrading-python
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from liquidtrading import LiquidClient
|
|
32
|
+
|
|
33
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...")
|
|
34
|
+
ticker = client.get_ticker("BTC-PERP")
|
|
35
|
+
print(f"BTC: {ticker.mark_price}")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Legacy compatibility import:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from liquid import Client
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Authentication
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Hosted Liquid API requests currently require credentials:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...")
|
|
54
|
+
markets = client.get_markets()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Quick connectivity check after install:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
liquidtrading-demo --base-url http://localhost:8001 --api-key lq_... --api-secret sk_...
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you also want to query open orders:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
liquidtrading-demo --base-url http://localhost:8001 --api-key lq_... --api-secret sk_... --include-open-orders
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Easiest local repo smoke test:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
bash scripts/run_smoke_demo.sh --base-url http://localhost:8001 --api-key lq_... --api-secret sk_...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Alternative local repo smoke test:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uv run python examples/smoke_demo.py --base-url http://localhost:8001 --api-key lq_... --api-secret sk_...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Publishing guide:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
See PUBLISHING.md
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Methods
|
|
88
|
+
|
|
89
|
+
### Market Data (public)
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
client.get_markets() # list[dict]
|
|
93
|
+
client.get_ticker("BTC-PERP") # Ticker
|
|
94
|
+
client.get_orderbook("BTC-PERP", depth=20) # Orderbook
|
|
95
|
+
client.get_candles("BTC-PERP", interval="1h", limit=100) # list[Candle]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Account (read scope)
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
client.get_account() # Account
|
|
102
|
+
client.get_balances() # Balance
|
|
103
|
+
client.get_positions() # list[Position]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Orders (trade scope)
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
client.place_order("BTC-PERP", "buy", size=100, leverage=10) # Order
|
|
110
|
+
client.place_order("ETH-PERP", "sell", type="limit", size=500, leverage=5,
|
|
111
|
+
price=4000, tp=3800, sl=4200, time_in_force="gtc") # Order
|
|
112
|
+
client.get_open_orders() # list[OpenOrder]
|
|
113
|
+
client.get_order("order-id") # Order
|
|
114
|
+
client.cancel_order("order-id") # bool
|
|
115
|
+
client.cancel_all_orders() # int
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Positions (trade scope)
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
client.close_position("BTC-PERP") # CloseResult
|
|
122
|
+
client.set_tp_sl("BTC-PERP", tp=70000, sl=60000) # TpSlResult
|
|
123
|
+
client.update_leverage("BTC-PERP", leverage=20) # LeverageResult
|
|
124
|
+
client.update_margin("BTC-PERP", amount=50) # MarginResult
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Error Handling
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from liquidtrading import (
|
|
131
|
+
LiquidClient,
|
|
132
|
+
AuthenticationError,
|
|
133
|
+
InvalidSignatureError,
|
|
134
|
+
InvalidApiKeyError,
|
|
135
|
+
RateLimitError,
|
|
136
|
+
InsufficientBalanceError,
|
|
137
|
+
InsufficientScopeError,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
order = client.place_order("BTC-PERP", "buy", size=100, leverage=10)
|
|
142
|
+
except InvalidApiKeyError:
|
|
143
|
+
print("API key is invalid or revoked")
|
|
144
|
+
except InvalidSignatureError:
|
|
145
|
+
print("Check your API secret")
|
|
146
|
+
except InsufficientScopeError:
|
|
147
|
+
print("API key needs trade permissions")
|
|
148
|
+
except RateLimitError as e:
|
|
149
|
+
print(f"Rate limited, retry after {e.retry_after}s")
|
|
150
|
+
except InsufficientBalanceError:
|
|
151
|
+
print("Not enough balance")
|
|
152
|
+
except AuthenticationError:
|
|
153
|
+
print("Other auth error")
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
All errors inherit from `LiquidError`. Auth errors: `AuthenticationError`, `InvalidApiKeyError`, `InvalidSignatureError`, `ExpiredTimestampError`, `ReplayedNonceError`. Permission errors: `ForbiddenError`, `IpForbiddenError`, `InsufficientScopeError`. Others: `RateLimitError`, `ValidationError`, `InsufficientBalanceError`, `OrderRejectedError`, `SymbolNotFoundError`, `TimeoutError`, `ConnectionError`, `ServiceUnavailableError`.
|
|
157
|
+
|
|
158
|
+
Client-side validation raises `ValueError` before the request is sent.
|
|
159
|
+
|
|
160
|
+
## Rate Limits
|
|
161
|
+
|
|
162
|
+
| Tier | Requests/sec | Orders/sec |
|
|
163
|
+
|--------|-------------|------------|
|
|
164
|
+
| free | 10 | 2 |
|
|
165
|
+
| trader | 30 | 10 |
|
|
166
|
+
| pro | 100 | 50 |
|
|
167
|
+
|
|
168
|
+
Enable retries for transient 429s (GET only, exponential backoff):
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...", max_retries=3)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## MCP Server
|
|
175
|
+
|
|
176
|
+
The MCP server lives in the sibling `../liquidtrading-mcp/` repo and depends on this SDK as a published package.
|
|
177
|
+
|
|
178
|
+
## Requirements
|
|
179
|
+
|
|
180
|
+
Python 3.9+ · httpx >= 0.25.0
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Publishing `liquidtrading-python`
|
|
2
|
+
|
|
3
|
+
This package is set up to publish as:
|
|
4
|
+
|
|
5
|
+
- package name: `liquidtrading-python`
|
|
6
|
+
- canonical import path: `from liquidtrading import LiquidClient`
|
|
7
|
+
- legacy compatibility import: `from liquid import Client`
|
|
8
|
+
- console scripts: `liquidtrading-demo` (primary) and `liquid-demo` (compatibility)
|
|
9
|
+
|
|
10
|
+
## One-time setup
|
|
11
|
+
|
|
12
|
+
1. Create accounts on both [PyPI](https://pypi.org/) and [TestPyPI](https://test.pypi.org/).
|
|
13
|
+
2. Verify the email address on both sites.
|
|
14
|
+
3. Confirm that the name `liquidtrading-python` is still available on both indexes before you publish. If it is already taken, pick a different package name before going further.
|
|
15
|
+
4. In GitHub, create two repository environments:
|
|
16
|
+
- `testpypi`
|
|
17
|
+
- `pypi`
|
|
18
|
+
5. In TestPyPI, create a pending GitHub trusted publisher for project `liquidtrading-python` with:
|
|
19
|
+
- owner: your GitHub org or username
|
|
20
|
+
- repository: this repository
|
|
21
|
+
- workflow filename: `.github/workflows/publish-liquidtrading-python.yml`
|
|
22
|
+
- environment: `testpypi`
|
|
23
|
+
6. In PyPI, create the same pending trusted publisher, but set the environment to `pypi`.
|
|
24
|
+
|
|
25
|
+
Pending publishers let the first successful upload create the project. They do not reserve the name until that first publish succeeds.
|
|
26
|
+
|
|
27
|
+
## Release flow
|
|
28
|
+
|
|
29
|
+
### 1. Update the version
|
|
30
|
+
|
|
31
|
+
Edit [pyproject.toml](/Users/raymondcosgrove/Liquid/Public%20Apis/liquidtrading-python/pyproject.toml) and bump:
|
|
32
|
+
|
|
33
|
+
```toml
|
|
34
|
+
version = "0.1.0"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Run the SDK tests
|
|
38
|
+
|
|
39
|
+
From the repo root:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
PYTHONPATH=. .venv/bin/python -m pytest \
|
|
43
|
+
tests/test_auth.py \
|
|
44
|
+
tests/test_client.py \
|
|
45
|
+
tests/test_demo.py \
|
|
46
|
+
tests/test_errors.py \
|
|
47
|
+
tests/test_models.py \
|
|
48
|
+
tests/test_package_exports.py -q
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. Publish to TestPyPI
|
|
52
|
+
|
|
53
|
+
In GitHub Actions, run the `Publish liquidtrading-python` workflow manually. That will:
|
|
54
|
+
|
|
55
|
+
- build the package from this repository
|
|
56
|
+
- run import smoke tests against both the wheel and source distribution
|
|
57
|
+
- publish to TestPyPI using GitHub Trusted Publishing
|
|
58
|
+
|
|
59
|
+
### 4. Verify the TestPyPI package
|
|
60
|
+
|
|
61
|
+
After the workflow succeeds:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
python3 -m venv /tmp/liquidtrading-python-test
|
|
65
|
+
source /tmp/liquidtrading-python-test/bin/activate
|
|
66
|
+
python -m pip install --upgrade pip
|
|
67
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ liquidtrading-python
|
|
68
|
+
python -c "from liquidtrading import LiquidClient; print(LiquidClient)"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 5. Publish to real PyPI
|
|
72
|
+
|
|
73
|
+
Create and push a tag that starts with `liquidtrading-python-v`:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git tag -a liquidtrading-python-v0.1.0 -m "liquidtrading-python v0.1.0"
|
|
77
|
+
git push origin liquidtrading-python-v0.1.0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
That tag triggers the same workflow, but publishes to PyPI instead of TestPyPI.
|
|
81
|
+
|
|
82
|
+
### 6. Verify the real package
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python3 -m venv /tmp/liquidtrading-python-prod
|
|
86
|
+
source /tmp/liquidtrading-python-prod/bin/activate
|
|
87
|
+
python -m pip install --upgrade pip
|
|
88
|
+
python -m pip install liquidtrading-python
|
|
89
|
+
python -c "from liquidtrading import LiquidClient; print(LiquidClient)"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Fallback manual publish
|
|
93
|
+
|
|
94
|
+
If you do not want to use Trusted Publishing, you can publish with an API token instead:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
cd /path/to/liquidtrading-python
|
|
98
|
+
python3 -m pip install --upgrade build twine
|
|
99
|
+
python3 -m build
|
|
100
|
+
python3 -m twine upload --repository testpypi dist/*
|
|
101
|
+
python3 -m twine upload dist/*
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Use a project-scoped API token when prompted.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# liquidtrading-python
|
|
2
|
+
|
|
3
|
+
Official Python SDK for the Liquid trading API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install liquidtrading-python
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv add liquidtrading-python
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from liquidtrading import LiquidClient
|
|
19
|
+
|
|
20
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...")
|
|
21
|
+
ticker = client.get_ticker("BTC-PERP")
|
|
22
|
+
print(f"BTC: {ticker.mark_price}")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Legacy compatibility import:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from liquid import Client
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Authentication
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Hosted Liquid API requests currently require credentials:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...")
|
|
41
|
+
markets = client.get_markets()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Quick connectivity check after install:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
liquidtrading-demo --base-url http://localhost:8001 --api-key lq_... --api-secret sk_...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you also want to query open orders:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
liquidtrading-demo --base-url http://localhost:8001 --api-key lq_... --api-secret sk_... --include-open-orders
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Easiest local repo smoke test:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
bash scripts/run_smoke_demo.sh --base-url http://localhost:8001 --api-key lq_... --api-secret sk_...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Alternative local repo smoke test:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv run python examples/smoke_demo.py --base-url http://localhost:8001 --api-key lq_... --api-secret sk_...
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Publishing guide:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
See PUBLISHING.md
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Methods
|
|
75
|
+
|
|
76
|
+
### Market Data (public)
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
client.get_markets() # list[dict]
|
|
80
|
+
client.get_ticker("BTC-PERP") # Ticker
|
|
81
|
+
client.get_orderbook("BTC-PERP", depth=20) # Orderbook
|
|
82
|
+
client.get_candles("BTC-PERP", interval="1h", limit=100) # list[Candle]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Account (read scope)
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
client.get_account() # Account
|
|
89
|
+
client.get_balances() # Balance
|
|
90
|
+
client.get_positions() # list[Position]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Orders (trade scope)
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
client.place_order("BTC-PERP", "buy", size=100, leverage=10) # Order
|
|
97
|
+
client.place_order("ETH-PERP", "sell", type="limit", size=500, leverage=5,
|
|
98
|
+
price=4000, tp=3800, sl=4200, time_in_force="gtc") # Order
|
|
99
|
+
client.get_open_orders() # list[OpenOrder]
|
|
100
|
+
client.get_order("order-id") # Order
|
|
101
|
+
client.cancel_order("order-id") # bool
|
|
102
|
+
client.cancel_all_orders() # int
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Positions (trade scope)
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
client.close_position("BTC-PERP") # CloseResult
|
|
109
|
+
client.set_tp_sl("BTC-PERP", tp=70000, sl=60000) # TpSlResult
|
|
110
|
+
client.update_leverage("BTC-PERP", leverage=20) # LeverageResult
|
|
111
|
+
client.update_margin("BTC-PERP", amount=50) # MarginResult
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Error Handling
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from liquidtrading import (
|
|
118
|
+
LiquidClient,
|
|
119
|
+
AuthenticationError,
|
|
120
|
+
InvalidSignatureError,
|
|
121
|
+
InvalidApiKeyError,
|
|
122
|
+
RateLimitError,
|
|
123
|
+
InsufficientBalanceError,
|
|
124
|
+
InsufficientScopeError,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
try:
|
|
128
|
+
order = client.place_order("BTC-PERP", "buy", size=100, leverage=10)
|
|
129
|
+
except InvalidApiKeyError:
|
|
130
|
+
print("API key is invalid or revoked")
|
|
131
|
+
except InvalidSignatureError:
|
|
132
|
+
print("Check your API secret")
|
|
133
|
+
except InsufficientScopeError:
|
|
134
|
+
print("API key needs trade permissions")
|
|
135
|
+
except RateLimitError as e:
|
|
136
|
+
print(f"Rate limited, retry after {e.retry_after}s")
|
|
137
|
+
except InsufficientBalanceError:
|
|
138
|
+
print("Not enough balance")
|
|
139
|
+
except AuthenticationError:
|
|
140
|
+
print("Other auth error")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
All errors inherit from `LiquidError`. Auth errors: `AuthenticationError`, `InvalidApiKeyError`, `InvalidSignatureError`, `ExpiredTimestampError`, `ReplayedNonceError`. Permission errors: `ForbiddenError`, `IpForbiddenError`, `InsufficientScopeError`. Others: `RateLimitError`, `ValidationError`, `InsufficientBalanceError`, `OrderRejectedError`, `SymbolNotFoundError`, `TimeoutError`, `ConnectionError`, `ServiceUnavailableError`.
|
|
144
|
+
|
|
145
|
+
Client-side validation raises `ValueError` before the request is sent.
|
|
146
|
+
|
|
147
|
+
## Rate Limits
|
|
148
|
+
|
|
149
|
+
| Tier | Requests/sec | Orders/sec |
|
|
150
|
+
|--------|-------------|------------|
|
|
151
|
+
| free | 10 | 2 |
|
|
152
|
+
| trader | 30 | 10 |
|
|
153
|
+
| pro | 100 | 50 |
|
|
154
|
+
|
|
155
|
+
Enable retries for transient 429s (GET only, exponential backoff):
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
client = LiquidClient(api_key="lq_...", api_secret="sk_...", max_retries=3)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## MCP Server
|
|
162
|
+
|
|
163
|
+
The MCP server lives in the sibling `../liquidtrading-mcp/` repo and depends on this SDK as a published package.
|
|
164
|
+
|
|
165
|
+
## Requirements
|
|
166
|
+
|
|
167
|
+
Python 3.9+ · httpx >= 0.25.0
|