[][src]Struct cbpro::builder::QueryBuilder

pub struct QueryBuilder<'a, T: Params<'a>> { /* fields omitted */ }

Builder returned by the public and private client. All methods are optional but the builder must be consumed with one of the terminal methods. Methods beloging to this struct can be chained and calling the same method more than once will overwrite the previously set value.

Methods

impl<'a, T: Params<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{PublicClient, SANDBOX_URL};

let client = PublicClient::new(SANDBOX_URL);
let products = client.get_products().json().await?;
println!("{}", serde_json::to_string_pretty(&products).unwrap());

pub async fn json(self) -> Result<Value>[src]

General terminal method

impl<'a, T: Params<'a> + ProductID<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{AuthenticatedClient, SANDBOX_URL};

let client = AuthenticatedClient::new("key", "pass", "secret", SANDBOX_URL);
let response = client.cancel_all()
    .product_id("BTC-USD")
    .json()
    .await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());

pub fn product_id(self, value: &'a str) -> Self[src]

Sets product_id param as part of the url query before sending it to the coinbase servers

impl<'a, T: Params<'a> + Book<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{PublicClient, SANDBOX_URL};

let client = PublicClient::new(SANDBOX_URL);
let order_book = client.get_product_order_book("BTC-USD")
    .level(3)
    .json()
    .await?;
println!("{}", serde_json::to_string_pretty(&order_book).unwrap());

pub fn level(self, value: i32) -> Self[src]

Sets level param as part of the url query before sending it to the coinbase servers

impl<'a, T: Params<'a> + Paginate<'a> + Send + Unpin + 'a> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{PublicClient, SANDBOX_URL};
use futures::TryStreamExt;

let client = PublicClient::new(SANDBOX_URL);
let mut pages = client.get_trades("BTC-USD")
    .limit(10)
    .after(7102310) // after or before but not both
    .paginate()?; // or .json().await? for a single request

while let Some(json) = pages.try_next().await? {
    println!("{}", serde_json::to_string_pretty(&json).unwrap());
    tokio::time::delay_for(core::time::Duration::new(1, 0)).await;
}

pub fn limit(self, value: i32) -> Self[src]

Sets limit param as part of the url query before sending it to the coinbase servers

pub fn before(self, value: i32) -> Self[src]

Sets before param as part of the url query before sending it to the coinbase servers

pub fn after(self, value: i32) -> Self[src]

Sets after param as part of the url query before sending it to the coinbase servers

pub fn paginate(self) -> Result<Pages<'a>>[src]

Terminal method returning a stream of json pages

impl<'a, T: Params<'a> + Candle<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{PublicClient, SANDBOX_URL};

let client = PublicClient::new(SANDBOX_URL);
let end = chrono::offset::Utc::now();
let start = end - chrono::Duration::hours(5);

let rates = client.get_historic_rates("BTC-USD", 3600).range(start, end).json().await?;
println!("{}", serde_json::to_string_pretty(&rates).unwrap());

pub fn range<Tz: TimeZone>(self, start: DateTime<Tz>, end: DateTime<Tz>) -> Self where
    Tz::Offset: Display
[src]

Sets start&end params as part of the url query before sending it to the coinbase servers

impl<'a, T: Params<'a> + ClientOID<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{AuthenticatedClient, SANDBOX_URL, QTY};

let client = AuthenticatedClient::new("key", "pass", "secret", SANDBOX_URL);
let response = client.place_market_order("BTC-USD", "buy", QTY::Size(10.00))
    .client_oid("<client_oid>")
    .json()
    .await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());

pub fn client_oid(self, value: &'a str) -> Self[src]

Sets client_oid param as part of the url query before sending it to the coinbase servers

impl<'a, T: Params<'a> + Limit<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{AuthenticatedClient, SANDBOX_URL};

let client = AuthenticatedClient::new("key", "pass", "secret", SANDBOX_URL);
let response = client.place_limit_order("BTC-USD", "sell", 7000.00, 10.00)
    .stp("dc")
    .stop_price(7010.00)
    .time_in_force("GTT")
    .cancel_after("min")
    .post_only(true)
    .json()
    .await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());

pub fn stp(self, value: &'a str) -> Self[src]

Sets stp param as part of the url query before sending it to the coinbase servers

pub fn stop_price(self, value: f64) -> Self[src]

Sets stop&stop_price params as part of the url query before sending it to the coinbase servers Calling this method on a sell limit order will convert it into a stop loss or a stop entry for a buy limit order.

pub fn time_in_force(self, value: &'a str) -> Self[src]

Sets time_in_force param as part of the url query before sending it to the coinbase servers Valid inputs are "GTC", "GTT", "IOC", "FOK" (default is GTC)

pub fn cancel_after(self, value: &'a str) -> Self[src]

Sets cancel_after&time_in_force params as part of the url query before sending it to the coinbase servers Valid inputs "min", "hour", "day"

pub fn post_only(self, value: bool) -> Self[src]

Sets post_only param as part of the url query before sending it to the coinbase servers Invalid when time_in_force is IOC or FOK

impl<'a, T: Params<'a> + Report<'a>> QueryBuilder<'a, T>[src]

Example

use cbpro::client::{AuthenticatedClient, SANDBOX_URL, RPT};
use chrono::{ TimeZone, Utc };

let client = AuthenticatedClient::new("key", "pass", "secret", SANDBOX_URL);
let start_date = Utc.ymd(2018, 8, 10).and_hms(0, 0, 0);
let end_date = Utc.ymd(2018, 8, 28).and_hms(0, 0, 0);

let rates = client.create_report(start_date, end_date, RPT::Fills { product_id: "BTC-USD" })
    .format("pdf")
    .email("<email>")
    .json()
    .await?;
println!("{}", serde_json::to_string_pretty(&rates).unwrap());

pub fn format(self, value: &'a str) -> Self[src]

Sets format param as part of the url query before sending it to the coinbase servers Valid inputs are "pdf" or "csv" (defualt is pdf)

pub fn email(self, value: &'a str) -> Self[src]

Sets email param as part of the url query before sending it to the coinbase servers

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for QueryBuilder<'a, T>

impl<'a, T> Send for QueryBuilder<'a, T> where
    T: Send

impl<'a, T> Sync for QueryBuilder<'a, T> where
    T: Sync

impl<'a, T> Unpin for QueryBuilder<'a, T> where
    T: Unpin

impl<'a, T> !UnwindSafe for QueryBuilder<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,