Stellar PHP SDK API Documentation

TradePriceResponse

Rational representation of trade price as a fraction

This response represents a trade price as a rational number using numerator (n) and denominator (d) components. This precise fractional representation avoids floating-point rounding errors and maintains exact price ratios as recorded in executed trades.

The price represents the ratio of counter asset units to base asset units. For example, if n=3 and d=2, the price is 1.5 counter units per base unit. This format preserves the exact price at which the trade executed on the Stellar network.

Companion to the decimal string price fields in TradeResponse and TradeAggregationResponse for applications requiring exact arithmetic.

Tags
see
TradeResponse

For executed trade details with decimal price

see
TradeAggregationResponse

For aggregated trade statistics

see
https://developers.stellar.org

Stellar developer docs Horizon Trades API

Table of Contents

Methods

fromJson()  : TradePriceResponse
Creates a TradePriceResponse from JSON data
getD()  : string
Gets the denominator of the price fraction
getN()  : string
Gets the numerator of the price fraction
loadFromJson()  : void

Methods

fromJson()

Creates a TradePriceResponse from JSON data

public static fromJson(array<string|int, mixed> $json) : TradePriceResponse
Parameters
$json : array<string|int, mixed>

Associative array of parsed JSON response

Return values
TradePriceResponse

The populated price response

getD()

Gets the denominator of the price fraction

public getD() : string
Return values
string

The denominator (d) value as string for large number support

getN()

Gets the numerator of the price fraction

public getN() : string
Return values
string

The numerator (n) value as string for large number support

loadFromJson()

protected loadFromJson(array<string|int, mixed> $json) : void
Parameters
$json : array<string|int, mixed>

        
On this page

Search results