TimeSeries

The TimeSeries class provides methods to interact with various time series endpoints of the Alphavantage API. It includes methods for fetching daily, weekly, and monthly time series data, both adjusted and unadjusted.

Methods

1. Daily

Fetches daily time series data for a given stock symbol.

Signature:

public function daily(string $symbol, string $outputSize = 'compact'): array

Parameters:

  • symbol (string): The stock symbol to fetch daily time series data for.

  • outputSize (string): The size of the output. Must be 'compact' or 'full'. Default is 'compact'.

Returns:

  • array: An array containing the daily time series data.

Exceptions:

  • ApiVolumeReached

  • ConnectionException

2. Daily Adjusted

Fetches adjusted daily time series data for a given stock symbol.

Signature:

public function dailyAdjusted(string $symbol, string $outputSize = 'compact'): array

Parameters:

  • symbol (string): The stock symbol to fetch adjusted daily time series data for.

  • outputSize (string): The size of the output. Must be 'compact' or 'full'. Default is 'compact'.

Returns:

  • array: An array containing the adjusted daily time series data.

Exceptions:

  • ApiVolumeReached

  • ConnectionException

3. Weekly

Fetches weekly time series data for a given stock symbol.

Signature:

public function weekly(string $symbol): array

Parameters:

  • symbol (string): The stock symbol to fetch weekly time series data for.

Returns:

  • array: An array containing the weekly time series data.

Exceptions:

  • ApiVolumeReached

  • ConnectionException

4. Weekly Adjusted

Fetches adjusted weekly time series data for a given stock symbol.

Signature:

public function weeklyAdjusted(string $symbol, string $outputSize = 'compact'): array

Parameters:

  • symbol (string): The stock symbol to fetch adjusted weekly time series data for.

  • outputSize (string): The size of the output. Must be 'compact' or 'full'. Default is 'compact'.

Returns:

  • array: An array containing the adjusted weekly time series data.

Exceptions:

  • ApiVolumeReached

  • ConnectionException

5. Monthly

Fetches monthly time series data for a given stock symbol.

Signature:

public function monthly(string $symbol): array

Parameters:

  • symbol (string): The stock symbol to fetch monthly time series data for.

Returns:

  • array: An array containing the monthly time series data.

Exceptions:

  • ApiVolumeReached

  • ConnectionException

6. Monthly Adjusted

Fetches adjusted monthly time series data for a given stock symbol.

Signature:

public function monthlyAdjusted(string $symbol, string $outputSize = 'compact'): array

Parameters:

  • symbol (string): The stock symbol to fetch adjusted monthly time series data for.

  • outputSize (string): The size of the output. Must be 'compact' or 'full'. Default is 'compact'.

Returns:

  • array: An array containing the adjusted monthly time series data.

Exceptions:

  • ApiVolumeReached

  • ConnectionException


The TimeSeries class is designed to provide an easy way to fetch various time series data using the Alphavantage API. It includes methods for daily, weekly, and monthly time series data, both adjusted and unadjusted. Be sure to handle the possible exceptions when using these methods to ensure robust error handling in your application.

Last updated