# Indicators

The `Indicators` class provides methods to interact with various technical indicator endpoints of the Alphavantage API. It includes methods for fetching different types of moving averages and other technical indicators for a given stock symbol.

### Methods

#### 1. Private Method: getIndicator

This is a private method used internally to fetch data for various technical indicators.

**Signature:**

```php
private function getIndicator(
    string $function, 
    string $symbol, 
    string $interval, 
    int $timePeriod, 
    string $seriesType, 
    ?string $month = null, 
    string $dataType = 'json'
): array
```

**Parameters:**

* `function` (string): The technical indicator function to call (e.g., 'SMA').
* `symbol` (string): The stock symbol to fetch data for.
* `interval` (string): The time interval between data points. Must be one of: '1min', '5min', '15min', '30min', '60min', 'daily', 'weekly', 'monthly'.
* `timePeriod` (int): The number of data points used to calculate the indicator.
* `seriesType` (string): The desired price series type. Must be one of: 'close', 'open', 'high', 'low'.
* `month` (string|null): Optional month parameter, valid only for intraday intervals.
* `dataType` (string): The data type of the response. Must be 'json' or 'csv'.

**Returns:**

* `array`: An array containing the indicator data.

**Exceptions:**

* `ApiVolumeReached`
* `ConnectionException`
* `InvalidArgumentException`: Thrown if any of the parameters are invalid.

#### 2. Simple Moving Average (SMA)

Fetches the Simple Moving Average (SMA) for a given stock symbol.

**Signature:**

```php
public function sma(
    string $symbol, 
    string $interval, 
    int $timePeriod, 
    string $seriesType, 
    ?string $month = null, 
    string $dataType = 'json'
): array
```

**Parameters:**

* `symbol` (string): The stock symbol to fetch the SMA for.
* `interval` (string): The time interval between data points. Must be one of: '1min', '5min', '15min', '30min', '60min', 'daily', 'weekly', 'monthly'.
* `timePeriod` (int): The number of data points used to calculate the SMA.
* `seriesType` (string): The desired price series type. Must be one of: 'close', 'open', 'high', 'low'.
* `month` (string|null): Optional month parameter, valid only for intraday intervals.
* `dataType` (string): The data type of the response. Must be 'json' or 'csv'.

**Returns:**

* `array`: An array containing the SMA data.

**Exceptions:**

* `ApiVolumeReached`
* `ConnectionException`
* `InvalidArgumentException`: Thrown if any of the parameters are invalid.

***

The `Indicators` class is designed to provide an easy way to fetch various technical indicators using the Alphavantage API. The `getIndicator` method serves as a utility function to handle common logic for different indicators, while the `sma` method provides a specific implementation for fetching the Simple Moving Average. Be sure to handle the possible exceptions when using these methods to ensure robust error handling in your application.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://alphavantage-api.marcelwagner.dev/deep-dive/indicators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
