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

# Market Agent: real-time BTC, ETH, and SOL price feeds

> Fetch real-time BTC, ETH, and SOL prices from Binance in one call. Use the Market Agent standalone or as the first stage of Elyra's research pipeline.

The Market Agent queries Binance's public ticker API for the three major assets — BTC, ETH, and SOL — and returns their current prices denominated in USDT. It runs as the first stage of Elyra's six-step research pipeline, and you can also call it directly from Python or the CLI whenever you need a quick price snapshot.

## CLI usage

Run the agent on its own to print live prices to stdout:

```bash theme={null}
python3 agents/market_agent.py
```

To run the full six-stage pipeline, which includes market prices as stage 1/6:

```bash theme={null}
python3 main.py          # full pipeline
python3 main.py crypto   # identical — "crypto" is the default command
```

## Python usage

```python theme={null}
from agents.market_agent import analyze_market

prices = analyze_market()
# Returns: {"BTC": "67234.50", "ETH": "3421.20", "SOL": "180.45"}
```

## `analyze_market()`

The `analyze_market` function takes no parameters. It fetches the spot price for `BTCUSDT`, `ETHUSDT`, and `SOLUSDT` from the Binance `/api/v3/ticker/price` endpoint and returns the results as a plain dictionary.

**Signature**

```python theme={null}
def analyze_market() -> dict[str, str]
```

### Parameters

This function accepts no parameters.

### Return value

Returns `dict[str, str]`. Each key is an asset ticker and each value is the current price as a USDT-denominated string, preserving the precision returned by Binance.

<ResponseField name="BTC" type="string" required>
  Current BTC/USDT spot price as a decimal string (e.g. `"67234.50000000"`).
</ResponseField>

<ResponseField name="ETH" type="string" required>
  Current ETH/USDT spot price as a decimal string (e.g. `"3421.20000000"`).
</ResponseField>

<ResponseField name="SOL" type="string" required>
  Current SOL/USDT spot price as a decimal string (e.g. `"180.45000000"`).
</ResponseField>

### Example response

```json theme={null}
{
  "BTC": "67234.50000000",
  "ETH": "3421.20000000",
  "SOL": "180.45000000"
}
```

## Error handling

The agent raises a `requests.RequestException` for network timeouts or connectivity issues, and an HTTP error for API-level failures. Wrap the call if you need fault-tolerant behavior:

```python theme={null}
from agents.market_agent import analyze_market
import requests

try:
    prices = analyze_market()
except requests.RequestException as e:
    print(f"Network or API error: {e}")
```

<Note>
  No API key is required. Binance's `/ticker/price` endpoint is publicly accessible without authentication.
</Note>
