Stellar PHP SDK API Documentation

TradeAggregationResponse extends Response

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
see
TradePriceResponse

For rational price representation

see
TradeAggregationsPageResponse

For paginated aggregation results

see
https://developers.stellar.org

Stellar developer docs Horizon Trade Aggregations API

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

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

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

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

getOpenPrice()

Gets the opening price at the start of this period

public getOpenPrice() : string
Return values
string

The open price as a decimal string

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
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getRateLimitRemaining()

Returns X-RateLimit-Remaining header from the response.

public getRateLimitRemaining() : int|null

The number of remaining requests for the current window.

Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getRateLimitReset()

Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.

public getRateLimitReset() : int|null
Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getTimestamp()

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


        
On this page

Search results