Struct stellar_client::endpoint::trade::Aggregations[][src]

pub struct Aggregations { /* fields omitted */ }

Represents an endpoint that returns trade aggregations.

https://www.stellar.org/developers/horizon/reference/endpoints/trade_aggregations.html

Example

use stellar_client::sync::Client;
use stellar_client::endpoint::{Direction, Order, trade};
use stellar_client::resources::AssetIdentifier;
use std::time::{SystemTime, UNIX_EPOCH};

let client = Client::horizon_test().unwrap();

// Grab a trade so that we know aggregations should exist.
let trades = trade::All::default().with_order(Direction::Asc);
let trades = client.request(trades).unwrap();
let trade = &trades.records()[0];
let base = trade.base_asset();
let counter = trade.counter_asset();

// Determine the current end time
let now = SystemTime::now()
    .duration_since(UNIX_EPOCH)
    .unwrap()
    .as_secs() * 1000;

// Place the start time in the past so we capture it.
let agg = trade::Aggregations::new(base, counter)
    .with_start_time(0)
    .with_end_time(now)
    .with_resolution(trade::SegmentResolution::OneWeek);

let records = client.request(agg).unwrap();

Methods

impl Aggregations
[src]

Creates a new aggregations endpoint. There are some defaults but generally these can be constructed with the with_* commands.

Sets the resolution to bin by. The pagination will increment at this interval of milliseconds.

Examples

use stellar_client::sync::Client;
use stellar_client::endpoint::trade;
use stellar_client::resources::AssetIdentifier;

let base = AssetIdentifier::native();
let counter = AssetIdentifier::native();

let endpoint = trade::Aggregations::new(&base, &counter)
    .with_resolution(trade::SegmentResolution::FiveMin);

Sets the start_time to begin the aggregations at. Taken as milliseconds from epoch.

Examples

use stellar_client::sync::Client;
use stellar_client::endpoint::trade;
use stellar_client::resources::AssetIdentifier;

let base = AssetIdentifier::native();
let counter = AssetIdentifier::native();

let endpoint = trade::Aggregations::new(&base, &counter)
    .with_start_time(300_000);

Sets the end_time to begin the aggregations at. Taken as milliseconds from epoch.

Examples

use stellar_client::sync::Client;
use stellar_client::endpoint::trade;
use stellar_client::resources::AssetIdentifier;

let base = AssetIdentifier::native();
let counter = AssetIdentifier::native();

let endpoint = trade::Aggregations::new(&base, &counter)
    .with_end_time(300_000);

Trait Implementations

impl Debug for Aggregations
[src]

Formats the value using the given formatter. Read more

impl Clone for Aggregations
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Limit for Aggregations
[src]

Sets a limit on the struct and returns an owned version.

Returns the limit or None.

impl Order for Aggregations
[src]

Sets the order on the struct and returns an owned version.

Returns the order that has been set, if it has been set.

impl IntoRequest for Aggregations
[src]

The deserializable type that is expected to come back from the stellar server.

The request body to be sent to stellar. Generally this is just a () unit. Converts the implementing struct into an http request. Read more

Auto Trait Implementations