List Trade Aggregations
This endpoint displays trade data based on filters set in the arguments.
This is done by dividing a given time range into segments and aggregating statistics, for a given asset pair (base, counter) over each of these segments.
The duration of the segments is specified with the resolution parameter. The start and end of the time range are given by startTime and endTime respectively, which are both rounded to the nearest multiple of resolution since epoch.
The individual segments are also aligned with multiples of resolution since epoch. If you want to change this alignment, the segments can be offset by specifying the offset parameter.
curl https://horizon.stellar.org/trade_aggregations?\
base_asset_type=native&\
counter_asset_code=EURT&\
counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&\
counter_asset_type=credit_alphanum4&\
resolution=3600000&\
start_time=1582156800000&\
end_time=1582178400000
var StellarSdk = require("@stellar/stellar-sdk");
var server = new StellarSdk.Horizon.Server(
"https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/",
);
var base = new StellarSdk.Asset.native();
var counter = new StellarSdk.Asset(
"EURT",
"GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S",
);
var startTime = 1582156800000;
var endTime = 1582178400000;
var resolution = 3600000;
var offset = 0;
server
.tradeAggregation(base, counter, startTime, endTime, resolution, offset)
.call()
.then(function (resp) {
console.log(resp);
})
.catch(function (err) {
console.error(err);
});
import requests
url = "https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations"
response = requests.get(url)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations")
.asString();require 'uri'
require 'net/http'
url = URI("https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"_links": {
"self": {
"href": "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>//trade_aggregations?base_asset_type=native&counter_asset_code=EURT&counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&counter_asset_type=credit_alphanum4&resolution=3600000&start_time=1582156800000&end_time=1582178400001"
},
"next": {
"href": "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>//trade_aggregations?base_asset_type=native&counter_asset_code=EURT&counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&counter_asset_type=credit_alphanum4&end_time=1582178400001&resolution=3600000&start_time=1582171200000"
},
"prev": {
"href": ""
}
},
"_embedded": {
"records": [
{
"timestamp": 1582164000000,
"trade_count": 3,
"base_volume": "399.3873200",
"counter_volume": "25.5368082",
"avg": "0.0639400",
"high": "0.0652169",
"high_r": {
"N": 652169,
"D": 10000000
},
"low": "0.0638338",
"low_r": {
"N": 8107550,
"D": 127010393
},
"open": "0.0652169",
"open_r": {
"N": 652169,
"D": 10000000
},
"close": "0.0638338",
"close_r": {
"N": 8107550,
"D": 127010393
}
},
{
"timestamp": 1582167600000,
"trade_count": 1,
"base_volume": "149.8415320",
"counter_volume": "9.7149804",
"avg": "0.0648350",
"high": "0.0648350",
"high_r": {
"N": 5000000,
"D": 77118803
},
"low": "0.0648350",
"low_r": {
"N": 5000000,
"D": 77118803
},
"open": "0.0648350",
"open_r": {
"N": 5000000,
"D": 77118803
},
"close": "0.0648350",
"close_r": {
"N": 5000000,
"D": 77118803
}
}
]
}
}40 Compute Units.Query Parameters
The lower time boundary represented as milliseconds since epoch.
The upper time boundary represented as milliseconds since epoch.
1 minute
Segments can be offset using this parameter. Expressed in milliseconds. Can only be used if the resolution is greater than 1 hour. Value must be in whole hours, less than the provided resolution, and less than 24 hours.
The type for the base asset. Either native, credit_alphanum4, or credit_alphanum12.
native, credit_alphanum4, credit_alphanum12 The Stellar address of the base asset’s issuer. Required if the base_asset_type is not native.
"GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX"
The code for the base asset. Required if the base_asset_type is not native.
"USD"
The type for the counter asset. Either native, credit_alphanum4, or credit_alphanum12.
native, credit_alphanum4, credit_alphanum12 The Stellar address of the counter asset’s issuer. Required if the counter_asset_type is not native.
"GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX"
The code for the counter asset. Required if the counter_asset_type is not native.
"USD"
A designation of the order in which records should appear. Options include asc (ascending) or desc (descending). If this argument isn’t set, it defaults to asc.
asc, desc The maximum number of records returned. The limit can range from 1 to 200 - an upper limit that is hardcoded in Horizon for performance reasons. If this argument isn’t designated, it defaults to 10.
10
Response
Success
Show child attributes
Show child attributes
curl https://horizon.stellar.org/trade_aggregations?\
base_asset_type=native&\
counter_asset_code=EURT&\
counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&\
counter_asset_type=credit_alphanum4&\
resolution=3600000&\
start_time=1582156800000&\
end_time=1582178400000
var StellarSdk = require("@stellar/stellar-sdk");
var server = new StellarSdk.Horizon.Server(
"https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/",
);
var base = new StellarSdk.Asset.native();
var counter = new StellarSdk.Asset(
"EURT",
"GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S",
);
var startTime = 1582156800000;
var endTime = 1582178400000;
var resolution = 3600000;
var offset = 0;
server
.tradeAggregation(base, counter, startTime, endTime, resolution, offset)
.call()
.then(function (resp) {
console.log(resp);
})
.catch(function (err) {
console.error(err);
});
import requests
url = "https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations"
response = requests.get(url)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations")
.asString();require 'uri'
require 'net/http'
url = URI("https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/trade_aggregations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"_links": {
"self": {
"href": "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>//trade_aggregations?base_asset_type=native&counter_asset_code=EURT&counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&counter_asset_type=credit_alphanum4&resolution=3600000&start_time=1582156800000&end_time=1582178400001"
},
"next": {
"href": "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>//trade_aggregations?base_asset_type=native&counter_asset_code=EURT&counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&counter_asset_type=credit_alphanum4&end_time=1582178400001&resolution=3600000&start_time=1582171200000"
},
"prev": {
"href": ""
}
},
"_embedded": {
"records": [
{
"timestamp": 1582164000000,
"trade_count": 3,
"base_volume": "399.3873200",
"counter_volume": "25.5368082",
"avg": "0.0639400",
"high": "0.0652169",
"high_r": {
"N": 652169,
"D": 10000000
},
"low": "0.0638338",
"low_r": {
"N": 8107550,
"D": 127010393
},
"open": "0.0652169",
"open_r": {
"N": 652169,
"D": 10000000
},
"close": "0.0638338",
"close_r": {
"N": 8107550,
"D": 127010393
}
},
{
"timestamp": 1582167600000,
"trade_count": 1,
"base_volume": "149.8415320",
"counter_volume": "9.7149804",
"avg": "0.0648350",
"high": "0.0648350",
"high_r": {
"N": 5000000,
"D": 77118803
},
"low": "0.0648350",
"low_r": {
"N": 5000000,
"D": 77118803
},
"open": "0.0648350",
"open_r": {
"N": 5000000,
"D": 77118803
},
"close": "0.0648350",
"close_r": {
"N": 5000000,
"D": 77118803
}
}
]
}
}