pub struct Coinbase { /* private fields */ }Expand description
A Coinbase Advanced Trade client over injected transports.
Implementations§
Source§impl Coinbase
impl Coinbase
Sourcepub fn sync_time(&mut self) -> Result<i64, Error>
pub fn sync_time(&mut self) -> Result<i64, Error>
Learn the offset between this machine’s clock and the venue’s, from
GET /api/v3/brokerage/time.
Explicit rather than automatic: it costs a request, and a client should not make one the caller did not ask for. Call it once after connecting, and again if the process runs long enough for drift to matter.
Returns the new offset in milliseconds (server - local).
§Errors
Returns an Error if the request fails or the response cannot be parsed.
Sourcepub fn with_http(
http: Box<dyn HttpTransport>,
options: &ExchangeOptions,
) -> Coinbase
pub fn with_http( http: Box<dyn HttpTransport>, options: &ExchangeOptions, ) -> Coinbase
Build a Coinbase client. Signed calls require credentials whose key name
is the API key id and whose private key (with_private_key) is the EC
PKCS#8 PEM.
Sourcepub fn with_credentials(
http: Box<dyn HttpTransport>,
options: &ExchangeOptions,
credentials: Credentials,
) -> Coinbase
pub fn with_credentials( http: Box<dyn HttpTransport>, options: &ExchangeOptions, credentials: Credentials, ) -> Coinbase
Build an authenticated Coinbase client.
Sourcepub fn with_clock(self, now_ms: Box<dyn Fn() -> i64 + Send + Sync>) -> Coinbase
pub fn with_clock(self, now_ms: Box<dyn Fn() -> i64 + Send + Sync>) -> Coinbase
Override the timestamp source (deterministic signing in tests).
Sourcepub fn with_ws(self, ws: Box<dyn WsTransport>) -> Coinbase
pub fn with_ws(self, ws: Box<dyn WsTransport>) -> Coinbase
Attach a WebSocket transport.
Sourcepub fn wire_symbol(symbol: &Symbol) -> String
pub fn wire_symbol(symbol: &Symbol) -> String
The Coinbase wire symbol for a canonical Symbol (BTC/USD -> BTC-USD).
Sourcepub fn klines(
&self,
symbol: &Symbol,
interval: &str,
limit: u32,
) -> Result<Vec<Candle>, Error>
pub fn klines( &self, symbol: &Symbol, interval: &str, limit: u32, ) -> Result<Vec<Candle>, Error>
Sourcepub fn order_book(
&self,
symbol: &Symbol,
depth: u32,
) -> Result<OrderBookSnapshot, Error>
pub fn order_book( &self, symbol: &Symbol, depth: u32, ) -> Result<OrderBookSnapshot, Error>
Sourcepub fn subscribe_trades(&mut self, symbol: &Symbol) -> Result<(), Error>
pub fn subscribe_trades(&mut self, symbol: &Symbol) -> Result<(), Error>
Subscribe to the public trade stream for symbol.
§Errors
Returns Error::NotConnected if no WebSocket transport is configured,
or Error::InvalidCredentials if credentials are missing.
Sourcepub fn poll_events(&mut self) -> Vec<Event>
pub fn poll_events(&mut self) -> Vec<Event>
Drain all stream events available since the last call. Non-blocking.
pub fn place_order(&self, request: &OrderRequest) -> Result<Order, Error>
Trait Implementations§
Source§impl Debug for Coinbase
Hand-written: the client holds Box<dyn HttpTransport>, Box<dyn WsTransport>
and a Box<dyn Fn() -> i64> clock, none of which a derive can reach. The
transports are shown by whether a connection is open rather than by value, and
the credentials only by whether they are set – printing them would put secret
material into every log line that formats a client.
impl Debug for Coinbase
Hand-written: the client holds Box<dyn HttpTransport>, Box<dyn WsTransport>
and a Box<dyn Fn() -> i64> clock, none of which a derive can reach. The
transports are shown by whether a connection is open rather than by value, and
the credentials only by whether they are set – printing them would put secret
material into every log line that formats a client.
Source§impl Execution for Coinbase
impl Execution for Coinbase
Source§fn place_order(&mut self, request: &OrderRequest) -> Result<Order, Error>
fn place_order(&mut self, request: &OrderRequest) -> Result<Order, Error>
Source§fn cancel_order(&mut self, symbol: &Symbol, order_id: &str) -> Result<(), Error>
fn cancel_order(&mut self, symbol: &Symbol, order_id: &str) -> Result<(), Error>
Source§fn query_order(
&mut self,
symbol: &Symbol,
order_id: &str,
) -> Result<Order, Error>
fn query_order( &mut self, symbol: &Symbol, order_id: &str, ) -> Result<Order, Error>
Source§impl MarketData for Coinbase
impl MarketData for Coinbase
Source§fn ticker(&mut self, symbol: &Symbol) -> Result<Ticker, Error>
fn ticker(&mut self, symbol: &Symbol) -> Result<Ticker, Error>
symbol. Read moreSource§fn klines(
&mut self,
symbol: &Symbol,
interval: &str,
limit: u32,
) -> Result<Vec<Candle>, Error>
fn klines( &mut self, symbol: &Symbol, interval: &str, limit: u32, ) -> Result<Vec<Candle>, Error>
limit historical candles for symbol at the given interval
(e.g. "1m", "1h"). Returns wickra_core::Candles so the result
feeds the indicator core directly. Read moreSource§fn order_book(
&mut self,
symbol: &Symbol,
depth: u32,
) -> Result<OrderBookSnapshot, Error>
fn order_book( &mut self, symbol: &Symbol, depth: u32, ) -> Result<OrderBookSnapshot, Error>
Source§fn subscribe_trades(&mut self, symbol: &Symbol) -> Result<(), Error>
fn subscribe_trades(&mut self, symbol: &Symbol) -> Result<(), Error>
symbol. Read moreSource§fn subscribe_book(&mut self, symbol: &Symbol) -> Result<(), Error>
fn subscribe_book(&mut self, symbol: &Symbol) -> Result<(), Error>
symbol. Read moreSource§fn subscribe_ticker(&mut self, symbol: &Symbol) -> Result<(), Error>
fn subscribe_ticker(&mut self, symbol: &Symbol) -> Result<(), Error>
symbol. Read moreSource§fn poll_events(&mut self) -> Vec<Event>
fn poll_events(&mut self) -> Vec<Event>
Auto Trait Implementations§
impl !Freeze for Coinbase
impl !RefUnwindSafe for Coinbase
impl !Sync for Coinbase
impl !UnwindSafe for Coinbase
impl Send for Coinbase
impl Unpin for Coinbase
impl UnsafeUnpin for Coinbase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more