[−][src]Struct cbpro::client::AuthenticatedClient
Private client
Methods
impl AuthenticatedClient
[src]
pub fn new<T: Into<String>>(key: T, pass: T, secret: T, url: T) -> Self
[src]
Creates new instance
Example
use cbpro::client::{AuthenticatedClient, SANDBOX_URL}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = AuthenticatedClient::new("<key>", "<pass>", "<secret>", SANDBOX_URL); Ok(()) }
pub fn public(&self) -> &PublicClient
[src]
Get public client
pub fn list_accounts<'a>(&self) -> QueryBuilder<NoOptions<'a>>
[src]
Get a list of trading accounts from the profile of the API key.
Example
let accounts = client .list_accounts() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&accounts).unwrap());
pub fn get_account<'a>(&self, account_id: &str) -> QueryBuilder<NoOptions<'a>>
[src]
Information for a single account. Use this endpoint when you know the account_id. API key must belong to the same profile as the account.
Example
let account = client .get_account("<account_id>") .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&account).unwrap());
pub fn get_account_history<'a>(
&self,
account_id: &str
) -> QueryBuilder<PageOptions<'a>>
[src]
&self,
account_id: &str
) -> QueryBuilder<PageOptions<'a>>
List account activity of the API key’s profile. Account activity either increases or decreases your account balance. Items are paginated and sorted latest first.
Example
let history = client .get_account_history("<account_id>") .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&history).unwrap());
pub fn get_holds<'a>(&self, account_id: &str) -> QueryBuilder<PageOptions<'a>>
[src]
List holds of an account that belong to the same profile as the API key. Holds are placed on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For a withdraw, once it is completed, the hold is removed.
Example
let holds = client .get_holds("<account_id>") .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&holds).unwrap());
pub fn place_limit_order<'a>(
&self,
product_id: &'a str,
side: &'a str,
price: f64,
size: f64
) -> QueryBuilder<LimitOrderOptions<'a>>
[src]
&self,
product_id: &'a str,
side: &'a str,
price: f64,
size: f64
) -> QueryBuilder<LimitOrderOptions<'a>>
Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified.
Example
let response = client .place_limit_order("BTC-USD", "buy", 7000.00, 10.00) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn place_market_order<'a>(
&self,
product_id: &'a str,
side: &'a str,
qty: QTY
) -> QueryBuilder<MarketOrderOptions<'a>>
[src]
&self,
product_id: &'a str,
side: &'a str,
qty: QTY
) -> QueryBuilder<MarketOrderOptions<'a>>
Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified.
Example
let response = client .place_market_order("BTC-USD", "buy", QTY::Size(10.00)) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn cancel_order<'a>(&self, ord: ORD<'a>) -> QueryBuilder<NoOptions<'a>>
[src]
Cancel a previously placed order. Order must belong to the profile that the API key belongs to.
If the order had no matches during its lifetime its record may be purged.
This means the order details will not be available with GET /orders/
Example
let response = client .cancel_order(ORD::OrderID("<order_id>")) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn cancel_all<'a>(&self) -> QueryBuilder<CancelOptions<'a>>
[src]
With best effort, cancel all open orders from the profile that the API key belongs to. The response is a list of ids of the canceled orders.
Example
let response = client .cancel_all() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn list_orders<'a>(
&self,
status: &[&str]
) -> QueryBuilder<ListOrderOptions<'a>>
[src]
&self,
status: &[&str]
) -> QueryBuilder<ListOrderOptions<'a>>
List your current open orders from the profile that the API key belongs to. Only open or un-settled orders are returned. As soon as an order is no longer open and settled, it will no longer appear in the default request.
Example
let orders = client .list_orders(&["open"]) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&orders).unwrap());
pub fn get_order<'a>(&self, ord: ORD<'a>) -> QueryBuilder<NoOptions<'a>>
[src]
Get a single order by order id from the profile that the API key belongs to.
Example
use cbpro::client::ORD; let order = client .get_order(ORD::OrderID("<order_id>")) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&order).unwrap());
pub fn get_fills<'a>(&self, fill: FILL<'a>) -> QueryBuilder<NoOptions<'a>>
[src]
Get a list of recent fills of the API key’s profile.
Example
use cbpro::client::FILL; let fills = client .get_fills(FILL::ProductID("BTC-USD")) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&fills).unwrap());
pub fn deposit<'a>(
&self,
amount: f64,
currency: &'a str,
dep: DEP<'a>
) -> QueryBuilder<NoOptions<'a>>
[src]
&self,
amount: f64,
currency: &'a str,
dep: DEP<'a>
) -> QueryBuilder<NoOptions<'a>>
Deposit funds from a payment method.
Example
use cbpro::client::DEP; let response = client .deposit(10.00, "BTC", DEP::CBAccountID("<account_id>")) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn withdraw<'a>(
&self,
amount: f64,
currency: &'a str,
wdl: WDL<'a>
) -> QueryBuilder<NoOptions<'a>>
[src]
&self,
amount: f64,
currency: &'a str,
wdl: WDL<'a>
) -> QueryBuilder<NoOptions<'a>>
Deposit funds from a coinbase account. You can move funds between your Coinbase accounts and your Coinbase Pro trading accounts within your daily limits. Moving funds between Coinbase and Coinbase Pro is instant and free.
Example
use cbpro::client::WDL; let response = client .withdraw(10.00, "BTC", WDL::CBAccountID("<account_id>")) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn convert<'a>(
&self,
from: &'a str,
to: &'a str,
amount: f64
) -> QueryBuilder<NoOptions<'a>>
[src]
&self,
from: &'a str,
to: &'a str,
amount: f64
) -> QueryBuilder<NoOptions<'a>>
Convert $10,000.00 to 10,000.00 USDC.
Example
let response = client .convert("USD", "USDC", 100.00) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn list_payment_methods<'a>(&self) -> QueryBuilder<NoOptions<'a>>
[src]
Get a list of your payment methods.
Example
let payment_methods = client .list_payment_methods() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&payment_methods).unwrap());
pub fn list_coinbase_accounts<'a>(&self) -> QueryBuilder<NoOptions<'a>>
[src]
Get a list of your coinbase accounts.
Example
let coinbase_accounts = client .list_coinbase_accounts() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&coinbase_accounts).unwrap());
pub fn get_current_fees<'a>(&self) -> QueryBuilder<NoOptions<'a>>
[src]
This request will return your current maker & taker fee rates, as well as your 30-day trailing volume. Quoted rates are subject to change.
Example
let current_fees = client .get_current_fees() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(¤t_fees).unwrap());
pub fn create_report<'a, Tz: TimeZone>(
&self,
start_date: DateTime<Tz>,
end_date: DateTime<Tz>,
rpt: RPT<'a>
) -> QueryBuilder<ReportOptions<'a>> where
Tz::Offset: Display,
[src]
&self,
start_date: DateTime<Tz>,
end_date: DateTime<Tz>,
rpt: RPT<'a>
) -> QueryBuilder<ReportOptions<'a>> where
Tz::Offset: Display,
Reports provide batches of historic information about your profile in various human and machine readable forms.
Example
use cbpro::client::RPT; 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" }) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&rates).unwrap());
pub fn get_report_status<'a>(
&self,
report_id: &'a str
) -> QueryBuilder<NoOptions<'a>>
[src]
&self,
report_id: &'a str
) -> QueryBuilder<NoOptions<'a>>
Once a report request has been accepted for processing, the status is available by polling the report resource endpoint.
The final report will be uploaded and available at file_url once the status indicates ready
Example
let report_status = client .get_report_status("<report_id>") .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&report_status).unwrap());
pub fn list_profiles<'a>(&self) -> QueryBuilder<NoOptions<'a>>
[src]
List your profiles.
Example
let profiles = client .list_profiles() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&profiles).unwrap());
pub fn get_profile<'a>(
&self,
profile_id: &'a str
) -> QueryBuilder<NoOptions<'a>>
[src]
&self,
profile_id: &'a str
) -> QueryBuilder<NoOptions<'a>>
Get a single profile by profile id.
Example
let profile = client .get_profile("<profile_id>") .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&profile).unwrap());
pub fn transfer_profile<'a>(
&self,
from: &'a str,
to: &'a str,
currency: &'a str,
amount: f64
) -> QueryBuilder<NoOptions<'a>>
[src]
&self,
from: &'a str,
to: &'a str,
currency: &'a str,
amount: f64
) -> QueryBuilder<NoOptions<'a>>
Transfer funds from API key’s profile to another user owned profile.
Example
let response = client .transfer_profile("<from_profile_id>", "<to_profile_id>", "BTC-USD", 10.00) .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&response).unwrap());
pub fn get_trailing_volume<'a>(&self) -> QueryBuilder<NoOptions<'a>>
[src]
This endpoint requires either the “view” or “trade” permission.
This request will return your 30-day trailing volume for all products of the API key’s profile. This is a cached value that’s calculated every day at midnight UTC.
Example
let trailing_volume = client .get_trailing_volume() .json::<serde_json::Value>() .await?; println!("{}", serde_json::to_string_pretty(&trailing_volume).unwrap());
Auto Trait Implementations
impl !RefUnwindSafe for AuthenticatedClient
impl Send for AuthenticatedClient
impl Sync for AuthenticatedClient
impl Unpin for AuthenticatedClient
impl !UnwindSafe for AuthenticatedClient
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>,