pub struct QueryBuilder<T> { /* private fields */ }Expand description
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 belonging to this struct can be chained and calling the same method more than once will overwrite the previously set value.
Implementations§
Source§impl<'a, T: Params<'a>> QueryBuilder<T>
impl<'a, T: Params<'a>> QueryBuilder<T>
Source§impl<'a, T: Params<'a> + ProductID<'a>> QueryBuilder<T>
impl<'a, T: Params<'a> + ProductID<'a>> QueryBuilder<T>
Sourcepub fn product_id(self, value: &'a str) -> Self
pub fn product_id(self, value: &'a str) -> Self
Sets product id
§Example
let response = client.cancel_all()
.product_id("BTC-USD")
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Source§impl<'a, T: Params<'a> + Book<'a>> QueryBuilder<T>
impl<'a, T: Params<'a> + Book<'a>> QueryBuilder<T>
Source§impl<'a, T: Params<'a> + Paginate<'a> + Send + Unpin + 'a> QueryBuilder<T>
impl<'a, T: Params<'a> + Paginate<'a> + Send + Unpin + 'a> QueryBuilder<T>
Sourcepub fn limit(self, value: i32) -> Self
pub fn limit(self, value: i32) -> Self
Sets limit for the ammount of pages each request will return. Max number of pages is 100.
§Example
let mut pages = client.get_trades("BTC-USD")
.limit(10)
.after(7102310) // after or before but not both
.paginate::<serde_json::Value>()?; // or .json::<serde_json::Value>().await? for a single request
while let Some(json) = pages.try_next().await? {
println!("{}", serde_json::to_string_pretty(&json).unwrap());
tokio::time::sleep(core::time::Duration::new(1, 0)).await;
}Sourcepub fn paginate<J: DeserializeOwned>(self) -> Result<Pages<'a, J>>
pub fn paginate<J: DeserializeOwned>(self) -> Result<Pages<'a, J>>
Terminal method returning a stream of json pages
Source§impl<'a, T: Params<'a> + Candle<'a>> QueryBuilder<T>
impl<'a, T: Params<'a> + Candle<'a>> QueryBuilder<T>
Sourcepub fn range<Tz: TimeZone>(self, start: DateTime<Tz>, end: DateTime<Tz>) -> Self
pub fn range<Tz: TimeZone>(self, start: DateTime<Tz>, end: DateTime<Tz>) -> Self
Sets start and end time for historic rates. If the range results in more than 300 candles, the request will be rejected.
§Example
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::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&rates).unwrap());Source§impl<'a, T: Params<'a> + ClientOID<'a>> QueryBuilder<T>
impl<'a, T: Params<'a> + ClientOID<'a>> QueryBuilder<T>
Sourcepub fn client_oid(self, value: &'a str) -> Self
pub fn client_oid(self, value: &'a str) -> Self
Sets uuid as part of this order
§Example
let response = client.place_market_order("BTC-USD", "buy", QTY::Size(10.00))
.client_oid("<client_oid>")
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Source§impl<'a, T: Params<'a> + Limit<'a>> QueryBuilder<T>
impl<'a, T: Params<'a> + Limit<'a>> QueryBuilder<T>
Sourcepub fn stp(self, value: &'a str) -> Self
pub fn stp(self, value: &'a str) -> Self
Sets Self-trade prevention flag.
§Example
let response = client
.place_limit_order("BTC-USD", "sell", 7000.00, 10.00)
.stp("dc")
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Sourcepub fn stop_price(self, value: f64) -> Self
pub fn stop_price(self, value: f64) -> Self
Turns sell limit order into a stop loss or a stop entry for a buy limit order.
§Example
let response = client
.place_limit_order("BTC-USD", "sell", 7000.00, 10.00)
.stop_price(7010.00)
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Sourcepub fn time_in_force(self, value: &'a str) -> Self
pub fn time_in_force(self, value: &'a str) -> Self
Sets time in force policy. (default is GTC) Valid inputs are: “GTC”, “GTT”, “IOC”, “FOK”.
§Example
let response = client
.place_limit_order("BTC-USD", "sell", 7000.00, 10.00)
.time_in_force("GTT")
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Sourcepub fn cancel_after(self, value: &'a str) -> Self
pub fn cancel_after(self, value: &'a str) -> Self
Sets time before order is cancelled Valid inputs are: “min”, “hour”, “day”.
§Example
let response = client
.place_limit_order("BTC-USD", "sell", 7000.00, 10.00)
.cancel_after("min")
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Sourcepub fn post_only(self, value: bool) -> Self
pub fn post_only(self, value: bool) -> Self
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
let response = client
.place_limit_order("BTC-USD", "sell", 7000.00, 10.00)
.post_only(true)
.json::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&response).unwrap());Source§impl<'a, T: Params<'a> + Report<'a>> QueryBuilder<T>
impl<'a, T: Params<'a> + Report<'a>> QueryBuilder<T>
Sourcepub fn format(self, value: &'a str) -> Self
pub fn format(self, value: &'a str) -> Self
Sets format of output report. Valid inputs are “pdf” or “csv” (defualt is pdf)
§Example
use chrono::{ TimeZone, Utc };
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::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&rates).unwrap());Sourcepub fn email(self, value: &'a str) -> Self
pub fn email(self, value: &'a str) -> Self
Sets to send report to. Valid inputs are “pdf” or “csv” (defualt is pdf)
§Example
use chrono::{ TimeZone, Utc };
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::<serde_json::Value>()
.await?;
println!("{}", serde_json::to_string_pretty(&rates).unwrap());