MutualFunds
in package
uses
UniversalParameters, ValidatesInputs
MutualFunds class for handling mutual fund-related API endpoints.
Table of Contents
Constants
- BASE_URL = "v1/funds/"
Properties
Methods
- __construct() : mixed
- MutualFunds constructor.
- candles() : Candles
- Get historical price candles for a mutual fund.
- canParseAsDate() : bool
- Check if a string can be parsed as a date.
- execute() : object
- Execute a single API request with universal parameters.
- execute_in_parallel() : array<string|int, mixed>
- Execute multiple API requests in parallel with universal parameters.
- mergeParameters() : Parameters
- Merge method-level parameters with client default parameters.
- parseDateToTimestamp() : int|null
- Parse a date string to unix timestamp.
- validateCountryCode() : void
- Validate ISO 3166 two-letter country code.
- validateDateRange() : void
- Validate date range logic.
- validateNonEmptyArray() : void
- Validate that an array is non-empty.
- validateNonEmptyString() : void
- Validate that a string is non-empty.
- validateNumericRange() : void
- Validate that min < max when both are provided.
- validatePositiveInteger() : void
- Validate that an integer is positive if provided.
- validatePositiveNumber() : void
- Validate that a number (int or float) is positive if provided.
- validateResolution() : void
- Validate resolution format.
- validateSymbols() : void
- Validate symbols array (trim and ensure non-empty).
Constants
BASE_URL
public
string
BASE_URL
= "v1/funds/"
The base URL for mutual fund endpoints.
Properties
$client
private
Client
$client
The Market Data API client instance.
Methods
__construct()
MutualFunds constructor.
public
__construct(Client $client) : mixed
Parameters
- $client : Client
-
The Market Data API client instance.
candles()
Get historical price candles for a mutual fund.
public
candles(string $symbol, string $from[, string|null $to = null ][, string $resolution = 'D' ][, int|null $countback = null ][, Parameters|null $parameters = null ]) : Candles
Parameters
- $symbol : string
-
The mutual fund's ticker symbol.
- $from : string
-
The leftmost candle on a chart (inclusive). If you use countback, to is not required. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
- $to : string|null = null
-
The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix, spreadsheet.
- $resolution : string = 'D'
-
The duration of each candle.
- Minutely Resolutions: (minutely, 1, 3, 5, 15, 30, 45, ...)
- Hourly Resolutions: (hourly, H, 1H, 2H, ...)
- Daily Resolutions: (daily, D, 1D, 2D, ...)
- Weekly Resolutions: (weekly, W, 1W, 2W, ...)
- Monthly Resolutions: (monthly, M, 1M, 2M, ...)
- Yearly Resolutions:(yearly, Y, 1Y, 2Y, ...)
- $countback : int|null = null
-
Will fetch a number of candles before (to the left of) to. If you use from, countback is not required.
- $parameters : Parameters|null = null
-
Universal parameters for all methods (such as format).
Tags
Return values
CandlescanParseAsDate()
Check if a string can be parsed as a date.
protected
canParseAsDate(string|null $value) : bool
Similar to Python SDK's check_is_date() function. Returns true if the value contains "-" or "/" (indicating parseable date format) or is numeric (unix timestamp or spreadsheet format).
This allows relative dates ("today", "yesterday", "-5 days") and option expiration dates ("December expiration") to pass through without validation.
Parameters
- $value : string|null
-
The value to check
Return values
bool —True if the value can be parsed as a date
execute()
Execute a single API request with universal parameters.
protected
execute(string $method, array<string|int, mixed> $arguments, Parameters|null $parameters) : object
Parameters
- $method : string
-
The API method to call.
- $arguments : array<string|int, mixed>
-
The arguments for the API call.
- $parameters : Parameters|null
-
Optional Parameters object for additional settings.
Return values
object —The API response as an object.
execute_in_parallel()
Execute multiple API requests in parallel with universal parameters.
protected
execute_in_parallel(array<string|int, mixed> $calls[, Parameters|null $parameters = null ][, array<string|int, mixed>|null &$failedRequests = null ]) : array<string|int, mixed>
Parameters
- $calls : array<string|int, mixed>
-
An array of method calls, each containing the method name and arguments.
- $parameters : Parameters|null = null
-
Optional Parameters object for additional settings.
- $failedRequests : array<string|int, mixed>|null = null
-
Optional by-reference array to collect failed requests instead of throwing. When provided, exceptions are stored here keyed by their call index.
Tags
Return values
array<string|int, mixed> —An array of API responses. When $failedRequests is provided, results are keyed by original call index.
mergeParameters()
Merge method-level parameters with client default parameters.
protected
mergeParameters(Parameters|null $methodParams) : Parameters
Priority order (highest to lowest):
- Method-level parameters (if provided)
- Client default parameters ($this->client->default_params)
- Default Parameters() values
Parameters
- $methodParams : Parameters|null
-
Method-level parameters, or null to use only client defaults.
Return values
Parameters —Merged parameters instance.
parseDateToTimestamp()
Parse a date string to unix timestamp.
protected
parseDateToTimestamp(string|null $value) : int|null
Handles ISO 8601, unix timestamps, spreadsheet dates, and American format.
Parameters
- $value : string|null
-
The date string to parse
Return values
int|null —Unix timestamp or null if cannot be parsed
validateCountryCode()
Validate ISO 3166 two-letter country code.
protected
validateCountryCode(string $country) : void
Parameters
- $country : string
-
The country code to validate
Tags
validateDateRange()
Validate date range logic.
protected
validateDateRange(string|null $from, string|null $to[, int|null $countback = null ][, string $context = '' ]) : void
Rules:
- If
tois provided, it requires eitherfromORcountback(but not both) - If both
fromandtoare parseable dates, validates thatfrom<to - If
countbackis provided, it must be a positive integer
This allows relative dates and option expiration dates to pass through without strict format validation.
Parameters
- $from : string|null
-
The start date
- $to : string|null
-
The end date
- $countback : int|null = null
-
The countback value
- $context : string = ''
-
Optional context for error messages
Tags
validateNonEmptyArray()
Validate that an array is non-empty.
protected
validateNonEmptyArray(array<string|int, mixed> $value, string $fieldName) : void
Parameters
- $value : array<string|int, mixed>
-
The value to validate
- $fieldName : string
-
The field name for error messages
Tags
validateNonEmptyString()
Validate that a string is non-empty.
protected
validateNonEmptyString(string $value, string $fieldName) : void
Parameters
- $value : string
-
The value to validate
- $fieldName : string
-
The field name for error messages
Tags
validateNumericRange()
Validate that min < max when both are provided.
protected
validateNumericRange(float|null $min, float|null $max, string $minField, string $maxField) : void
Parameters
- $min : float|null
-
The minimum value
- $max : float|null
-
The maximum value
- $minField : string
-
The minimum field name for error messages
- $maxField : string
-
The maximum field name for error messages
Tags
validatePositiveInteger()
Validate that an integer is positive if provided.
protected
validatePositiveInteger(int|null $value, string $fieldName) : void
Parameters
- $value : int|null
-
The value to validate
- $fieldName : string
-
The field name for error messages
Tags
validatePositiveNumber()
Validate that a number (int or float) is positive if provided.
protected
validatePositiveNumber(int|float|null $value, string $fieldName) : void
Parameters
- $value : int|float|null
-
The value to validate
- $fieldName : string
-
The field name for error messages
Tags
validateResolution()
Validate resolution format.
protected
validateResolution(string $resolution) : void
Valid resolutions: minutely, hourly, daily, weekly, monthly, yearly, or numeric with optional suffix (1, 3, 5, 15, 30, 45, H, 1H, 2H, D, 1D, 2D, etc.)
Parameters
- $resolution : string
-
The resolution to validate
Tags
validateSymbols()
Validate symbols array (trim and ensure non-empty).
protected
validateSymbols(array<string|int, mixed> $symbols) : void
Parameters
- $symbols : array<string|int, mixed>
-
The symbols array to validate