[−][src]Struct cbpro::builder::QueryBuilder
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());
impl<'a, T: Params<'a> + ProductID<'a>> QueryBuilder<'a, T>
[src]
pub fn product_id(self, value: &'a str) -> Self
[src]
Sets product id
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());
impl<'a, T: Params<'a> + Book<'a>> QueryBuilder<'a, T>
[src]
pub fn level(self, value: i32) -> Self
[src]
Sets level for order book data. Max level is 3.
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());
impl<'a, T: Params<'a> + Paginate<'a> + Send + Unpin + 'a> QueryBuilder<'a, T>
[src]
pub fn limit(self, value: i32) -> Self
[src]
Sets limit for the ammount of pages each request will return. Max number of pages is 100.
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 before(self, value: i32) -> Self
[src]
Gets newer page from the trade id specified.
pub fn after(self, value: i32) -> Self
[src]
Gets older page from the trade id specified.
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]
pub fn range<Tz: TimeZone>(self, start: DateTime<Tz>, end: DateTime<Tz>) -> Self where
Tz::Offset: Display,
[src]
Tz::Offset: Display,
Sets start and end time for historic rates. If the range results in more than 300 candles, the request will be rejected.
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());
impl<'a, T: Params<'a> + ClientOID<'a>> QueryBuilder<'a, T>
[src]
pub fn client_oid(self, value: &'a str) -> Self
[src]
Sets uuid as part of this order
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());
impl<'a, T: Params<'a> + Limit<'a>> QueryBuilder<'a, T>
[src]
pub fn stp(self, value: &'a str) -> Self
[src]
Sets Self-trade prevention flag.
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") .json() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn stop_price(self, value: f64) -> Self
[src]
Turns sell limit order into a stop loss or a stop entry for a buy limit order.
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) .stop_price(7010.00) .json() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn time_in_force(self, value: &'a str) -> Self
[src]
Sets time in force policy. (default is GTC) Valid inputs are: "GTC", "GTT", "IOC", "FOK".
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) .time_in_force("GTT") .json() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn cancel_after(self, value: &'a str) -> Self
[src]
Sets time before order is cancelled Valid inputs are: "min", "hour", "day".
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) .cancel_after("min") .json() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn post_only(self, value: bool) -> Self
[src]
The post-only flag indicates that the order should only make liquidity. If any part of the order results in taking liquidity, the order will be rejected and no part of it will execute. Invalid when time_in_force is IOC or FOK.
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) .post_only(true) .json() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
impl<'a, T: Params<'a> + Report<'a>> QueryBuilder<'a, T>
[src]
pub fn format(self, value: &'a str) -> Self
[src]
Sets format of output report. Valid inputs are "pdf" or "csv" (defualt is pdf)
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 email(self, value: &'a str) -> Self
[src]
Sets to send report to. Valid inputs are "pdf" or "csv" (defualt is pdf)
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" }) .email("<email>") .json() .await?; println!("{}", serde_json::to_string_pretty(&rates).unwrap());
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for QueryBuilder<'a, T>
impl<'a, T> Send for QueryBuilder<'a, T> where
T: Send,
T: Send,
impl<'a, T> Sync for QueryBuilder<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for QueryBuilder<'a, T> where
T: Unpin,
T: Unpin,
impl<'a, T> !UnwindSafe for QueryBuilder<'a, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,