arthur-sdk 0.2.1__py3-none-any.whl
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.
- arthur_sdk/__init__.py +35 -0
- arthur_sdk/auth.py +149 -0
- arthur_sdk/cli.py +183 -0
- arthur_sdk/client.py +1075 -0
- arthur_sdk/exceptions.py +31 -0
- arthur_sdk/market_maker.py +326 -0
- arthur_sdk/strategies.py +576 -0
- arthur_sdk-0.2.1.dist-info/METADATA +225 -0
- arthur_sdk-0.2.1.dist-info/RECORD +13 -0
- arthur_sdk-0.2.1.dist-info/WHEEL +5 -0
- arthur_sdk-0.2.1.dist-info/entry_points.txt +2 -0
- arthur_sdk-0.2.1.dist-info/licenses/LICENSE +21 -0
- arthur_sdk-0.2.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arthur-sdk
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Simple trading for AI agents on Orderly Network
|
|
5
|
+
Home-page: https://github.com/ranyi1115/arthur-sdk
|
|
6
|
+
Author: Arthur
|
|
7
|
+
Author-email: Arthur <arthur.orderly@proton.me>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://arthurdex.com
|
|
10
|
+
Project-URL: Documentation, https://arthurdex.com/docs
|
|
11
|
+
Project-URL: Repository, https://github.com/ranyi1115/arthur-sdk
|
|
12
|
+
Project-URL: Issues, https://github.com/ranyi1115/arthur-sdk/issues
|
|
13
|
+
Project-URL: Changelog, https://github.com/ranyi1115/arthur-sdk/blob/main/CHANGELOG.md
|
|
14
|
+
Keywords: trading,crypto,orderly,defi,perpetuals,ai,agents
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: pynacl>=1.5.0
|
|
29
|
+
Provides-Extra: withdraw
|
|
30
|
+
Requires-Dist: eth-account>=0.10.0; extra == "withdraw"
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: eth-account>=0.10.0; extra == "all"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
35
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
37
|
+
Requires-Dist: eth-account>=0.10.0; extra == "dev"
|
|
38
|
+
Dynamic: author
|
|
39
|
+
Dynamic: home-page
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
|
|
43
|
+
# Arthur SDK
|
|
44
|
+
|
|
45
|
+
Simple trading for AI agents on [Orderly Network](https://orderly.network).
|
|
46
|
+
|
|
47
|
+
Built for [Arthur DEX](https://arthurdex.com).
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install arthur-sdk
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For withdrawal support (requires wallet signing):
|
|
56
|
+
```bash
|
|
57
|
+
pip install arthur-sdk[withdraw]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from arthur_sdk import Arthur
|
|
64
|
+
|
|
65
|
+
# Initialize client
|
|
66
|
+
client = Arthur(
|
|
67
|
+
api_key="ed25519:...",
|
|
68
|
+
secret_key="ed25519:...",
|
|
69
|
+
account_id="0x..."
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Trade in one line
|
|
73
|
+
client.buy("ETH", usd=100) # Buy $100 of ETH
|
|
74
|
+
client.sell("BTC", usd=50) # Short $50 of BTC
|
|
75
|
+
|
|
76
|
+
# Check positions
|
|
77
|
+
for pos in client.positions():
|
|
78
|
+
print(f"{pos.symbol}: {pos.side} {pos.size} @ {pos.entry_price}")
|
|
79
|
+
|
|
80
|
+
# Get account summary
|
|
81
|
+
print(client.summary())
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
### Trading
|
|
87
|
+
```python
|
|
88
|
+
# Market orders
|
|
89
|
+
client.buy("ETH", usd=100) # Buy $100 worth
|
|
90
|
+
client.buy("ETH", size=0.1) # Buy 0.1 ETH
|
|
91
|
+
client.sell("BTC", usd=500) # Short $500 worth
|
|
92
|
+
|
|
93
|
+
# Limit orders
|
|
94
|
+
client.limit_buy("ETH", price=3000, usd=100)
|
|
95
|
+
client.limit_sell("ETH", price=4000, size=0.1)
|
|
96
|
+
|
|
97
|
+
# Close positions
|
|
98
|
+
client.close("ETH") # Close entire position
|
|
99
|
+
client.close("ETH", size=0.05) # Partial close
|
|
100
|
+
client.close_all() # Close all positions
|
|
101
|
+
|
|
102
|
+
# Cancel orders
|
|
103
|
+
client.cancel_all() # Cancel all orders
|
|
104
|
+
client.cancel_all("ETH") # Cancel ETH orders only
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Account
|
|
108
|
+
```python
|
|
109
|
+
# Balances
|
|
110
|
+
client.balance() # Available USDC
|
|
111
|
+
client.equity() # Total equity (balance + unrealized PnL)
|
|
112
|
+
client.free_collateral() # Withdrawable amount
|
|
113
|
+
|
|
114
|
+
# Positions
|
|
115
|
+
client.positions() # List all positions
|
|
116
|
+
client.position("ETH") # Get specific position
|
|
117
|
+
client.pnl() # Total unrealized PnL
|
|
118
|
+
|
|
119
|
+
# Orders
|
|
120
|
+
client.orders() # List recent orders
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Withdrawal (New in 0.2.1)
|
|
124
|
+
```python
|
|
125
|
+
# Withdraw to wallet
|
|
126
|
+
result = client.withdraw(
|
|
127
|
+
amount=100,
|
|
128
|
+
wallet_private_key="0x...",
|
|
129
|
+
chain_id=42161, # Arbitrum
|
|
130
|
+
)
|
|
131
|
+
print(f"Withdrawal ID: {result['withdraw_id']}")
|
|
132
|
+
|
|
133
|
+
# Withdraw all available
|
|
134
|
+
result = client.withdraw_all(wallet_private_key="0x...")
|
|
135
|
+
|
|
136
|
+
# Settle PnL before withdrawing
|
|
137
|
+
client.settle_pnl()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Market Data
|
|
141
|
+
```python
|
|
142
|
+
client.price("ETH") # Current ETH price
|
|
143
|
+
client.prices() # All prices
|
|
144
|
+
client.orderbook("ETH") # Order book
|
|
145
|
+
client.spread("ETH") # Bid/ask spread
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Supported Symbols
|
|
149
|
+
|
|
150
|
+
Short names: `BTC`, `ETH`, `SOL`, `ARB`, `OP`, `AVAX`, `LINK`, `DOGE`, `SUI`, `TIA`, `WOO`, `ORDER`
|
|
151
|
+
|
|
152
|
+
Or use full Orderly symbols: `PERP_ETH_USDC`, `PERP_BTC_USDC`, etc.
|
|
153
|
+
|
|
154
|
+
## Strategy Runner
|
|
155
|
+
|
|
156
|
+
Run automated trading strategies:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from arthur_sdk import StrategyRunner, StrategyConfig, Signal
|
|
160
|
+
|
|
161
|
+
def my_strategy(client, config):
|
|
162
|
+
price = client.price("ETH")
|
|
163
|
+
# Your logic here
|
|
164
|
+
return Signal.HOLD
|
|
165
|
+
|
|
166
|
+
config = StrategyConfig(
|
|
167
|
+
symbol="ETH",
|
|
168
|
+
usd_size=100,
|
|
169
|
+
interval_seconds=60,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
runner = StrategyRunner(client, my_strategy, config)
|
|
173
|
+
runner.run()
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Market Making
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from arthur_sdk import MarketMaker
|
|
180
|
+
|
|
181
|
+
mm = MarketMaker(
|
|
182
|
+
client=client,
|
|
183
|
+
symbol="ETH",
|
|
184
|
+
spread_bps=10, # 0.1% spread
|
|
185
|
+
order_size_usd=100,
|
|
186
|
+
num_levels=3,
|
|
187
|
+
)
|
|
188
|
+
mm.run()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Configuration
|
|
192
|
+
|
|
193
|
+
### From file
|
|
194
|
+
```python
|
|
195
|
+
client = Arthur.from_credentials_file("creds.json")
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Testnet
|
|
199
|
+
```python
|
|
200
|
+
client = Arthur(
|
|
201
|
+
api_key="...",
|
|
202
|
+
secret_key="...",
|
|
203
|
+
account_id="...",
|
|
204
|
+
testnet=True
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Chain IDs
|
|
209
|
+
|
|
210
|
+
| Chain | ID |
|
|
211
|
+
|-------|-----|
|
|
212
|
+
| Arbitrum | 42161 |
|
|
213
|
+
| Base | 8453 |
|
|
214
|
+
| Optimism | 10 |
|
|
215
|
+
| Ethereum | 1 |
|
|
216
|
+
|
|
217
|
+
## Links
|
|
218
|
+
|
|
219
|
+
- [Arthur DEX](https://arthurdex.com)
|
|
220
|
+
- [Orderly Network](https://orderly.network)
|
|
221
|
+
- [API Documentation](https://docs-api.orderly.network)
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
arthur_sdk/__init__.py,sha256=zkTM_nXHIvmU82pShrid_sfqB4cV3absfOFzzXlelig,809
|
|
2
|
+
arthur_sdk/auth.py,sha256=b1gmnr-V4Liw9_gF4QQNZxfsKBAnYJ5BdBMrZFeUxsk,3664
|
|
3
|
+
arthur_sdk/cli.py,sha256=GLDBJ5UodkNGb2iCFyhqZ--GxhjwPNjVYV9B4Re9TcU,6575
|
|
4
|
+
arthur_sdk/client.py,sha256=RWmBZr_y1IPj-uns1xPz1rDjFXjfh7-6STZyytZjQxE,33374
|
|
5
|
+
arthur_sdk/exceptions.py,sha256=S821SEqLZeIxYkx2H3eeSlbibECz_g51phiChrKdYs8,511
|
|
6
|
+
arthur_sdk/market_maker.py,sha256=Q8lclEIoyfAswSXCRUBmWTcoriiHQc2xgbaoNEYwlLY,11250
|
|
7
|
+
arthur_sdk/strategies.py,sha256=3lXgpvfatEKHM7OZuUj1nssdvcX5nzBw-U5ZDH2Xgyg,19212
|
|
8
|
+
arthur_sdk-0.2.1.dist-info/licenses/LICENSE,sha256=8DZhA-icWyGv4_QUwfcI36Lm0mHlTNLqG4k8shiOph4,1063
|
|
9
|
+
arthur_sdk-0.2.1.dist-info/METADATA,sha256=-wTnYJhVpIJaU24LrS-cSZgSkW4uHI__lbboiknoXEk,5367
|
|
10
|
+
arthur_sdk-0.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
11
|
+
arthur_sdk-0.2.1.dist-info/entry_points.txt,sha256=6wEFeQwawLLRmJZRJswmN2GMOO39l9YsqV1uBwP2rGU,47
|
|
12
|
+
arthur_sdk-0.2.1.dist-info/top_level.txt,sha256=Dp8_h8YrHYTZ5IUfhdNpC-LFVxu9FSoUqkWMo2VCV_c,11
|
|
13
|
+
arthur_sdk-0.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arthur
|
|
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 @@
|
|
|
1
|
+
arthur_sdk
|