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

# Stocks API

> Access stock market data including tickers, quotes, and historical prices

## Overview

The Stocks API provides comprehensive access to equity market data, including ticker information, current quotes, and historical price data across global exchanges.

## Methods

### tickers()

Retrieve a list of available stock tickers with optional filtering.

```typescript theme={null}
const axion = new Axion('your-api-key');

// Get all stock tickers
const allTickers = await axion.stocks.tickers();

// Filter by country
const usTickers = await axion.stocks.tickers({ country: 'US' });

// Filter by exchange
const nasdaqTickers = await axion.stocks.tickers({ exchange: 'NASDAQ' });

// Filter by both country and exchange
const filtered = await axion.stocks.tickers({ 
  country: 'US', 
  exchange: 'NYSE' 
});
```

<ParamField path="country" type="string" optional>
  Filter tickers by country code (e.g., 'US', 'GB', 'JP')
</ParamField>

<ParamField path="exchange" type="string" optional>
  Filter tickers by exchange name (e.g., 'NYSE', 'NASDAQ', 'LSE')
</ParamField>

<ResponseField name="data" type="array">
  Array of ticker objects

  <ResponseField name="ticker" type="string">
    Stock ticker symbol
  </ResponseField>

  <ResponseField name="name" type="string">
    Company name
  </ResponseField>

  <ResponseField name="exchange" type="string">
    Exchange where the stock is traded
  </ResponseField>

  <ResponseField name="country" type="string">
    Country code
  </ResponseField>
</ResponseField>

### ticker()

Get detailed information about a specific stock ticker.

```typescript theme={null}
const axion = new Axion('your-api-key');

// Get information for Apple Inc.
const appleData = await axion.stocks.ticker('AAPL');

// Get information for Tesla
const teslaData = await axion.stocks.ticker('TSLA');
```

<ParamField path="ticker" type="string" required>
  The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT')
</ParamField>

<ResponseField name="data" type="object">
  Detailed ticker information

  <ResponseField name="ticker" type="string">
    Stock ticker symbol
  </ResponseField>

  <ResponseField name="name" type="string">
    Company name
  </ResponseField>

  <ResponseField name="price" type="number">
    Current price
  </ResponseField>

  <ResponseField name="volume" type="number">
    Trading volume
  </ResponseField>

  <ResponseField name="marketCap" type="number">
    Market capitalization
  </ResponseField>

  <ResponseField name="change" type="number">
    Price change
  </ResponseField>

  <ResponseField name="changePercent" type="number">
    Percentage change
  </ResponseField>
</ResponseField>

### prices()

Retrieve historical price data for a stock with optional date range and time frame.

```typescript theme={null}
const axion = new Axion('your-api-key');

// Get all available historical prices
const allPrices = await axion.stocks.prices('AAPL');

// Get prices for a specific date range
const rangedPrices = await axion.stocks.prices('AAPL', {
  from: '2024-01-01',
  to: '2024-12-31'
});

// Get daily prices for the last year
const dailyPrices = await axion.stocks.prices('AAPL', {
  from: '2024-01-01',
  to: '2024-12-31',
  frame: 'daily'
});

// Get weekly prices
const weeklyPrices = await axion.stocks.prices('MSFT', {
  from: '2023-01-01',
  to: '2024-01-01',
  frame: 'weekly'
});
```

<ParamField path="ticker" type="string" required>
  The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT')
</ParamField>

<ParamField path="from" type="string" optional>
  Start date in YYYY-MM-DD format
</ParamField>

<ParamField path="to" type="string" optional>
  End date in YYYY-MM-DD format
</ParamField>

<ParamField path="frame" type="string" optional>
  Time frame for price data ('daily', 'weekly', 'monthly')
</ParamField>

<ResponseField name="data" type="array">
  Array of historical price points

  <ResponseField name="date" type="string">
    Date of the price point
  </ResponseField>

  <ResponseField name="open" type="number">
    Opening price
  </ResponseField>

  <ResponseField name="high" type="number">
    Highest price
  </ResponseField>

  <ResponseField name="low" type="number">
    Lowest price
  </ResponseField>

  <ResponseField name="close" type="number">
    Closing price
  </ResponseField>

  <ResponseField name="volume" type="number">
    Trading volume
  </ResponseField>

  <ResponseField name="adjustedClose" type="number">
    Adjusted closing price
  </ResponseField>
</ResponseField>

## Example: Building a Stock Dashboard

```typescript theme={null}
import { Axion } from 'axion-sdk';

const axion = new Axion('your-api-key');

async function buildStockDashboard(tickers: string[]) {
  const dashboard = [];

  for (const ticker of tickers) {
    // Get current quote
    const quote = await axion.stocks.ticker(ticker);
    
    // Get 30-day price history
    const thirtyDaysAgo = new Date();
    thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
    
    const prices = await axion.stocks.prices(ticker, {
      from: thirtyDaysAgo.toISOString().split('T')[0],
      to: new Date().toISOString().split('T')[0],
      frame: 'daily'
    });

    dashboard.push({
      ticker,
      currentPrice: quote.data.price,
      change: quote.data.change,
      changePercent: quote.data.changePercent,
      priceHistory: prices.data
    });
  }

  return dashboard;
}

// Build dashboard for tech stocks
const techDashboard = await buildStockDashboard(['AAPL', 'MSFT', 'GOOGL', 'AMZN']);
console.log(techDashboard);
```

## Error Handling

```typescript theme={null}
try {
  const data = await axion.stocks.ticker('INVALID');
} catch (error) {
  if (error.message.includes('HTTP Error 404')) {
    console.error('Ticker not found');
  } else if (error.message.includes('Authentication required')) {
    console.error('API key is missing or invalid');
  } else {
    console.error('An error occurred:', error.message);
  }
}
```
