TradeAggregationResponse
extends Response
in package
Represents aggregated trade statistics for a time period
This response contains OHLC (Open-High-Low-Close) candlestick data and volume statistics for trades of a specific asset pair over a defined time period. Trade aggregations enable historical price analysis, charting, and market trend identification by summarizing multiple individual trades into time-based buckets.
Key fields:
- Timestamp marking the start of the aggregation period
- Trade count for the period
- Base and counter asset volumes
- Average price for the period
- OHLC prices (open, high, low, close) in decimal and rational formats
Prices are provided as both decimal strings and rational fractions (price_r fields) for precision. The aggregation period (resolution) is specified when querying the endpoint and can range from minutes to days.
Returned by Horizon endpoint:
- GET /trade_aggregations - Aggregated trade statistics by time period
Tags
Table of Contents
Properties
- $httpClient : Client|null
- $rateLimitLimit : int|null
- $rateLimitRemaining : int|null
- $rateLimitReset : int|null
Methods
- fromJson() : TradeAggregationResponse
- Creates a TradeAggregationResponse from JSON data
- getAveragePrice() : string
- Gets the average price during this period
- getBaseVolume() : string
- Gets the total volume of the base asset traded
- getClosePrice() : string
- Gets the closing price at the end of this period
- getClosePriceR() : TradePriceResponse
- Gets the rational representation of the close price
- getCounterVolume() : string
- Gets the total volume of the counter asset traded
- getHighPrice() : string
- Gets the highest price reached during this period
- getHighPriceR() : TradePriceResponse
- Gets the rational representation of the high price
- getHttpClient() : Client|null
- Gets the HTTP client used for pagination requests
- getLowPrice() : string
- Gets the lowest price reached during this period
- getLowPriceR() : TradePriceResponse
- Gets the rational representation of the low price
- getOpenPrice() : string
- Gets the opening price at the start of this period
- getOpenPriceR() : TradePriceResponse
- Gets the rational representation of the open price
- getRateLimitLimit() : int|null
- Returns X-RateLimit-Limit header from the response.
- getRateLimitRemaining() : int|null
- Returns X-RateLimit-Remaining header from the response.
- getRateLimitReset() : int|null
- Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.
- getTimestamp() : string
- Gets the timestamp marking the start of this aggregation period
- getTradeCount() : string
- Gets the number of trades in this aggregation period
- setHeaders() : void
- Extracts and sets rate limiting information from HTTP response headers
- setHttpClient() : void
- Sets the HTTP client for making follow-up requests
- loadFromJson() : void
- Loads response data from a JSON array
Properties
$httpClient
protected
Client|null
$httpClient
= null
$rateLimitLimit
protected
int|null
$rateLimitLimit
= null
$rateLimitRemaining
protected
int|null
$rateLimitRemaining
= null
$rateLimitReset
protected
int|null
$rateLimitReset
= null
Methods
fromJson()
Creates a TradeAggregationResponse from JSON data
public
static fromJson(array<string|int, mixed> $json) : TradeAggregationResponse
Parameters
- $json : array<string|int, mixed>
-
Associative array of parsed JSON response
Return values
TradeAggregationResponse —The populated aggregation response
getAveragePrice()
Gets the average price during this period
public
getAveragePrice() : string
Return values
string —The average price as a decimal string
getBaseVolume()
Gets the total volume of the base asset traded
public
getBaseVolume() : string
Return values
string —The base asset volume
getClosePrice()
Gets the closing price at the end of this period
public
getClosePrice() : string
Return values
string —The close price as a decimal string
getClosePriceR()
Gets the rational representation of the close price
public
getClosePriceR() : TradePriceResponse
Return values
TradePriceResponse —The close price as a fraction
getCounterVolume()
Gets the total volume of the counter asset traded
public
getCounterVolume() : string
Return values
string —The counter asset volume
getHighPrice()
Gets the highest price reached during this period
public
getHighPrice() : string
Return values
string —The high price as a decimal string
getHighPriceR()
Gets the rational representation of the high price
public
getHighPriceR() : TradePriceResponse
Return values
TradePriceResponse —The high price as a fraction
getHttpClient()
Gets the HTTP client used for pagination requests
public
getHttpClient() : Client|null
Return values
Client|null —The HTTP client instance, or null if not set
getLowPrice()
Gets the lowest price reached during this period
public
getLowPrice() : string
Return values
string —The low price as a decimal string
getLowPriceR()
Gets the rational representation of the low price
public
getLowPriceR() : TradePriceResponse
Return values
TradePriceResponse —The low price as a fraction
getOpenPrice()
Gets the opening price at the start of this period
public
getOpenPrice() : string
Return values
string —The open price as a decimal string
getOpenPriceR()
Gets the rational representation of the open price
public
getOpenPriceR() : TradePriceResponse
Return values
TradePriceResponse —The open price as a fraction
getRateLimitLimit()
Returns X-RateLimit-Limit header from the response.
public
getRateLimitLimit() : int|null
This number represents the he maximum number of requests that the current client can make in one hour.
Tags
Return values
int|nullgetRateLimitRemaining()
Returns X-RateLimit-Remaining header from the response.
public
getRateLimitRemaining() : int|null
The number of remaining requests for the current window.
Tags
Return values
int|nullgetRateLimitReset()
Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.
public
getRateLimitReset() : int|null
Tags
Return values
int|nullgetTimestamp()
Gets the timestamp marking the start of this aggregation period
public
getTimestamp() : string
Return values
string —The timestamp in milliseconds since epoch
getTradeCount()
Gets the number of trades in this aggregation period
public
getTradeCount() : string
Return values
string —The total count of executed trades
setHeaders()
Extracts and sets rate limiting information from HTTP response headers
public
setHeaders(array<string|int, mixed> $headers) : void
This method processes the X-Ratelimit-* headers from the HTTP response and stores them for client access.
Parameters
- $headers : array<string|int, mixed>
-
Associative array of HTTP headers from the response
setHttpClient()
Sets the HTTP client for making follow-up requests
public
setHttpClient([Client|null $httpClient = null ]) : void
Paginated responses contain links to next/previous pages. This HTTP client is used when following those links to fetch additional pages.
Parameters
- $httpClient : Client|null = null
-
The Guzzle HTTP client to use for pagination
loadFromJson()
Loads response data from a JSON array
protected
loadFromJson(array<string|int, mixed> $json) : void
This method is used internally to populate response objects from parsed JSON. Subclasses override this to extract their specific data fields.
Parameters
- $json : array<string|int, mixed>
-
Associative array of parsed JSON data