> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kuru.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Reference

> Order types, configuration, and production guidance for the Python SDK

## Order Types

### Limit Orders

```python theme={null}
from kuru_sdk_py.manager.order import Order, OrderType, OrderSide

Order(
    cloid="my-bid-1",
    order_type=OrderType.LIMIT,
    side=OrderSide.BUY,
    price=100.0,
    size=1.0,
)
```

### Market Orders

```python theme={null}
await client.place_market_buy(quote_amount=100.0, min_amount_out=0.9)
await client.place_market_sell(size=1.0, min_amount_out=90.0)
```

### Cancel Orders

```python theme={null}
Order(cloid="my-bid-1", order_type=OrderType.CANCEL)
```

### Batch Updates

Combine limit orders and cancels into a single atomic transaction:

```python theme={null}
orders = [
    Order(cloid="bid-1", order_type=OrderType.LIMIT, side=OrderSide.BUY, price=99.0, size=1.0),
    Order(cloid="ask-1", order_type=OrderType.LIMIT, side=OrderSide.SELL, price=101.0, size=1.0),
    Order(cloid="old-bid", order_type=OrderType.CANCEL),
]
txhash = await client.place_orders(orders, post_only=True)
```

## Configuration

### ConfigManager

The SDK uses `ConfigManager` to load configuration from environment variables with sensible defaults. See the [Quick Start](/sdk/py-sdk-quickstart) for the full list of environment variables.

```python theme={null}
import os
from kuru_sdk_py.client import KuruClient
from kuru_sdk_py.configs import ConfigManager

configs = ConfigManager.load_all_configs(
    market_address=os.environ["MARKET_ADDRESS"],
)
client = await KuruClient.create(**configs)
```

### ConfigPresets

Use presets for common scenarios:

```python theme={null}
from kuru_sdk_py.configs import ConfigPresets

preset = ConfigPresets.conservative()  # Longer timeouts, more retries (production)
preset = ConfigPresets.aggressive()    # Shorter timeouts, fewer retries (HFT)
preset = ConfigPresets.testnet()       # Optimized for slower testnets
```

| Preset           | Use Case                                                 |
| ---------------- | -------------------------------------------------------- |
| `conservative()` | Production environments — longer timeouts, more retries  |
| `aggressive()`   | High-frequency trading — shorter timeouts, fewer retries |
| `testnet()`      | Testnets — optimized for slower block times              |

## Production Guidance

### Use a Dedicated RPC

The default public endpoints can be rate-limited. For production, use a dedicated RPC provider via `RPC_URL` and `RPC_WS_URL`.

### Quote Cadence and Gas

Batch cancel/replace every second is expensive on-chain. Common approaches:

* Update only when mid price moves beyond a threshold
* Update at a slower cadence (e.g., 5-15s) unless volatility spikes
* Use fewer levels or smaller grids
* Enable EIP-2930 access list optimization (`KURU_USE_ACCESS_LIST=true`)

If you see "out of gas" or "gas too low" transaction failures, increase the gas buffer multiplier:

```bash theme={null}
KURU_GAS_BUFFER_MULTIPLIER=1.5  # default is 1.35; try 1.5 to 2.0
```

### Safety Checks

<Warning>
  Always implement these safety checks before running in production.
</Warning>

* **Stale data guard** - Don't quote if your market data feed is older than N milliseconds
* **Min/max size** - Ensure order sizes meet market constraints (or the tx will revert)
* **Balance guard** - Ensure margin balances can support your outstanding orders
* **Circuit breakers** - Stop quoting on repeated failures, disconnects, or extreme spreads. Use `await client.cancel_all_active_orders_for_market()` to cancel all outstanding orders when the circuit breaker triggers

## Running Examples

```bash theme={null}
# End-to-end market making bot (requires PRIVATE_KEY + MARKET_ADDRESS)
PYTHONPATH=. uv run python examples/simple_market_making_bot.py

# Read-only frontend orderbook stream (full snapshots, no wallet required)
PYTHONPATH=. uv run python examples/get_orderbook_ws.py

# Read-only exchange orderbook stream (Binance-compatible format, no wallet required)
PYTHONPATH=. uv run python examples/get_exchange_orderbook_ws.py

# Repeated batch placement + cancels
PYTHONPATH=. uv run python examples/place_many_orders.py
```
