Arthur SDK
The easiest way for AI agents to trade crypto perpetuals.
3 lines of Python. No complex signatures. No confusing structs. Just trade.
from orderly_agent import Arthur
client = Arthur.from_credentials_file("credentials.json")
client.buy("ETH", usd=100) # Done.
Why Arthur?
- 🚀 Dead simple - Trade in 3 lines of code
- 🤖 Built for agents - Clean API, no boilerplate
- ⚡ Fast execution - Powered by Orderly Network
- 📊 50+ markets - BTC, ETH, SOL, ARB, and more
- 🔒 Non-custodial - Your keys, your coins
Installation
pip install agent-trading-sdk
Quick Start
from orderly_agent import Arthur
# Load credentials
client = Arthur.from_credentials_file("credentials.json")
# Trade
client.buy("ETH", usd=100) # Long $100 of ETH
client.sell("BTC", size=0.01) # Short 0.01 BTC
client.close("ETH") # Close position
client.close_all() # Close everything
# Check status
print(client.balance()) # Available USDC
print(client.pnl()) # Total unrealized PnL
print(client.positions()) # All open positions
Strategy Examples
RSI Strategy
# Buy oversold, sell overbought
if rsi < 30:
client.buy("ETH", usd=100)
elif rsi > 70:
client.sell("ETH", usd=100)
Momentum Strategy
# Trend following with trailing stops
if price > recent_high:
client.buy("BTC", usd=200)
Grid Trading
# Profit from sideways markets
for level in grid_levels:
client.buy(symbol, price=level, usd=50)
AI Agent
# Let your LLM make decisions
context = get_market_context(client, ["BTC", "ETH"])
decision = llm.chat(TRADING_PROMPT, context)
execute_trade(client, decision)
Portfolio Rebalancer
# Maintain target allocations
targets = {"BTC": 50, "ETH": 30, "SOL": 20}
rebalance_portfolio(client, targets)
API Reference
Trading
# Market orders
client.buy("ETH", usd=100) # Buy by USD value
client.buy("BTC", size=0.01) # Buy by size
# Limit orders
client.buy("ETH", size=0.1, price=2000)
# Close positions
client.close("ETH") # Close all of symbol
client.close("ETH", size=0.05) # Partial close
client.close_all() # Close everything
Position Management
# Get all positions
for pos in client.positions():
print(f"{pos.symbol}: {pos.side} {pos.size}")
print(f" Entry: ${pos.entry_price}")
print(f" PnL: ${pos.unrealized_pnl} ({pos.pnl_percent}%)")
# Get specific position
eth_pos = client.position("ETH")
# Total PnL
total_pnl = client.pnl()
Market Data
# Get price
btc_price = client.price("BTC")
# Get all prices
prices = client.prices()
Account Info
balance = client.balance() # Available USDC
equity = client.equity() # Total value
summary = client.summary() # Full details
Withdrawals
# Initialize with wallet for withdrawals
client = Arthur(
api_key="...",
secret_key="...",
account_id="...",
wallet_private_key="...", # Required for withdrawals!
chain_id=42161, # Arbitrum One
)
# Withdraw 100 USDC to your wallet
result = client.withdraw(100)
print(f"Withdrawal ID: {result['withdraw_id']}")
# Withdraw to a different chain
client.withdraw(50, to_chain_id=10) # Optimism
# Check withdrawal history
for w in client.withdrawal_history():
print(f"{w['id']}: {w['amount']} USDC - {w['status']}")
Risk Management
client.set_leverage("ETH", 10)
client.set_stop_loss("ETH", price=1900)
client.set_stop_loss("ETH", pct=5) # 5% stop
Credentials
Create a credentials.json:
{
"api_key": "ed25519:xxx",
"secret_key": "ed25519:xxx",
"account_id": "0x..."
}
Get credentials from Arthur DEX or any Orderly-powered DEX.
Supported Markets
Short symbols work automatically:
| Short | Full Symbol |
|---|---|
| BTC | PERP_BTC_USDC |
| ETH | PERP_ETH_USDC |
| SOL | PERP_SOL_USDC |
| ARB, OP, AVAX, LINK... | PERP_*_USDC |
50+ perpetual markets available.
Testnet
client = Arthur(..., testnet=True)
Error Handling
from orderly_agent import Arthur, OrderError, InsufficientFundsError
try:
client.buy("ETH", usd=100)
except InsufficientFundsError:
print("Not enough balance")
except OrderError as e:
print(f"Order failed: {e}")
Links
- Trade: arthurdex.com
- Twitter: @Arthur_Orderly
- Orderly Network: orderly.network
License
MIT
Built by Arthur 🤖 for AI agents, powered by Orderly Network.
Metadata
Release files for arthur-sdk 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arthur_sdk-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for arthur_sdk-0.4.1-py3-none-any.whl |
Release files / arthur_sdk-0.4.1-py3-none-any.whl
| Download URL | arthur_sdk-0.4.1-py3-none-any.whl |
|---|---|
| Size | 38.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca81d41c959a918efe2e2343852bab41528f5d0cfed216035e2c7a05fed15f5b
|
|
BLAKE2b-256 checksum How to use checksums |
6b6d637324d7bc2103318b9218e8df95ee79f201b876f12f67ff9e26120b4aac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for arthur-sdk 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.