Metadata-Version: 2.4
Name: arthur-sdk
Version: 0.2.0
Summary: Simple trading for AI agents on Arthur DEX / Orderly Network
Project-URL: Homepage, https://arthurdex.com
Project-URL: Documentation, https://arthurdex.com/docs
Project-URL: Repository, https://github.com/arthur-orderly/arthur-sdk
Project-URL: Issues, https://github.com/arthur-orderly/arthur-sdk/issues
Project-URL: Changelog, https://github.com/arthur-orderly/arthur-sdk/blob/main/CHANGELOG.md
Author-email: Arthur DEX <dev@arthurdex.com>
License-Expression: MIT
License-File: LICENSE
Keywords: ai-agent,arthur,bot,crypto,defi,market-maker,orderly,perps,trading
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: pynacl>=1.5.0
Provides-Extra: dev
Requires-Dist: black>=23.0; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: strategies
Requires-Dist: numpy>=1.24; extra == 'strategies'
Requires-Dist: pandas>=2.0; extra == 'strategies'
Description-Content-Type: text/markdown

# Arthur SDK

[![PyPI version](https://badge.fury.io/py/arthur-sdk.svg)](https://badge.fury.io/py/arthur-sdk)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Simple trading for AI agents on Arthur DEX.**

Trade in 3 lines of code. No complex signatures. No confusing structs. Just trade.

```python
from arthur_sdk import Arthur

client = Arthur.from_credentials_file("credentials.json")
client.buy("ETH", usd=100)
```

Built for [Arthur DEX](https://arthurdex.com) on Orderly Network.

## Installation

```bash
pip install arthur-sdk
```

## Quick Start

```python
from arthur_sdk import Arthur

# Initialize with credentials
client = Arthur(
    api_key="ed25519:xxx",
    secret_key="ed25519:xxx",
    account_id="0x..."
)

# Or load from file
client = Arthur.from_credentials_file("credentials.json")

# Trade
client.buy("ETH", usd=100)      # Buy $100 worth of ETH
client.sell("BTC", size=0.01)   # Sell 0.01 BTC
client.close("ETH")             # Close ETH position
client.close_all()              # Close all positions

# Check status
print(client.balance())         # Available USDC
print(client.pnl())             # Total unrealized PnL
print(client.positions())       # All open positions
```

## Features

### Simple Trading

```python
# Market orders (instant execution)
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 specific position
client.close("ETH", size=0.05)  # Partial close
client.close_all()              # Close everything
```

### Position Management

```python
# 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 Making

```python
# Place two-sided quotes
quotes = client.quote(
    symbol="ETH",
    bid_price=2000,
    ask_price=2010,
    size=0.1
)

# Post-only limit orders
client.limit_buy("ETH", price=2000, size=0.1, post_only=True)

# Get spread info
spread = client.spread("ETH")
print(f"Spread: {spread['spread_bps']:.1f} bps")
```

### Strategy Execution

```python
from arthur_sdk import StrategyRunner

# Run strategies from JSON configs
runner = StrategyRunner(client)
result = runner.run("strategies/momentum.json")
```

## CLI

```bash
# Get prices
arthur price BTC ETH SOL

# Check account status
arthur status -c credentials.json

# Execute trades
arthur trade buy ETH --usd 100 -c credentials.json

# Run strategies
arthur run strategy.json -c credentials.json
```

## Credentials File

```json
{
    "api_key": "ed25519:xxx",
    "secret_key": "ed25519:xxx",
    "account_id": "0x..."
}
```

## Supported Symbols

Short symbols are automatically converted:

| Short | Full Symbol |
|-------|-------------|
| BTC | PERP_BTC_USDC |
| ETH | PERP_ETH_USDC |
| SOL | PERP_SOL_USDC |
| ARB | PERP_ARB_USDC |
| OP | PERP_OP_USDC |
| AVAX | PERP_AVAX_USDC |
| ... | ... |

## Testnet

```python
client = Arthur(
    api_key="...",
    secret_key="...",
    account_id="...",
    testnet=True  # Use testnet
)
```

## Error Handling

```python
from arthur_sdk 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

- **Arthur DEX:** https://arthurdex.com
- **Documentation:** https://arthurdex.com/docs
- **Orderly Network:** https://orderly.network
- **GitHub:** https://github.com/arthur-orderly/arthur-sdk

## License

MIT

---

Built by Arthur 🦊 for AI agents, on Orderly Network.
