pub struct CoinbaseWebSocketClient { /* private fields */ }Expand description
WebSocket client for Coinbase Advanced Trade market data and user streams.
Manages connection lifecycle, subscription state, and JWT authentication.
Spawns a FeedHandler task that parses raw messages into Nautilus types.
Implementations§
Source§impl CoinbaseWebSocketClient
impl CoinbaseWebSocketClient
Sourcepub fn new(
url: &str,
transport_backend: TransportBackend,
proxy_url: Option<String>,
) -> Self
pub fn new( url: &str, transport_backend: TransportBackend, proxy_url: Option<String>, ) -> Self
Creates a new CoinbaseWebSocketClient for public market data.
Sourcepub fn with_credential(
url: &str,
credential: CoinbaseCredential,
transport_backend: TransportBackend,
proxy_url: Option<String>,
) -> Self
pub fn with_credential( url: &str, credential: CoinbaseCredential, transport_backend: TransportBackend, proxy_url: Option<String>, ) -> Self
Creates a new CoinbaseWebSocketClient with credentials for authenticated channels.
Sourcepub async fn set_account_id(&mut self, account_id: AccountId)
pub async fn set_account_id(&mut self, account_id: AccountId)
Sets the account ID used when emitting user-channel execution reports.
Propagates to the feed handler when the connection is active so that subsequent user events carry the correct account identifier.
Sourcepub async fn initialize_instruments(&self, instruments: Vec<InstrumentAny>)
pub async fn initialize_instruments(&self, instruments: Vec<InstrumentAny>)
Bulk-populates the instrument cache.
Safe to call before or after Self::connect. When called before
connect, instruments are picked up by the initial InitializeInstruments
command the client sends to the handler; when called after, a fresh
InitializeInstruments command is sent to refresh the handler’s cache.
Sourcepub async fn connect(&mut self) -> Result<()>
pub async fn connect(&mut self) -> Result<()>
Establishes the WebSocket connection and spawns the feed handler.
Sourcepub async fn subscribe(
&self,
channel: CoinbaseWsChannel,
product_ids: &[Ustr],
) -> Result<()>
pub async fn subscribe( &self, channel: CoinbaseWsChannel, product_ids: &[Ustr], ) -> Result<()>
Subscribes to a channel for the given product IDs.
Sourcepub async fn unsubscribe(
&self,
channel: CoinbaseWsChannel,
product_ids: &[Ustr],
) -> Result<()>
pub async fn unsubscribe( &self, channel: CoinbaseWsChannel, product_ids: &[Ustr], ) -> Result<()>
Unsubscribes from a channel for the given product IDs.
Sourcepub async fn next_message(&mut self) -> Option<NautilusWsMessage>
pub async fn next_message(&mut self) -> Option<NautilusWsMessage>
Returns the next parsed message from the feed handler.
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Disconnects the WebSocket and stops the feed handler.
Sourcepub fn is_reconnecting(&self) -> bool
pub fn is_reconnecting(&self) -> bool
Returns true if the WebSocket is reconnecting after a transport drop.
Sourcepub fn instruments(&self) -> &Arc<AtomicMap<InstrumentId, InstrumentAny>> ⓘ
pub fn instruments(&self) -> &Arc<AtomicMap<InstrumentId, InstrumentAny>> ⓘ
Returns a reference to the instrument cache.
Sourcepub fn subscription_aliases(&self) -> &Arc<AtomicMap<Ustr, Ustr>> ⓘ
pub fn subscription_aliases(&self) -> &Arc<AtomicMap<Ustr, Ustr>> ⓘ
Returns a reference to the canonical-to-subscribed alias map.
Sourcepub fn register_subscription_alias(&self, canonical: Ustr, subscribed: Ustr)
pub fn register_subscription_alias(&self, canonical: Ustr, subscribed: Ustr)
Records that inbound messages carrying canonical should be re-keyed to
subscribed. Caller is the data/exec client at subscribe or submit time
when the local product id differs from Coinbase’s canonical alias.
Sourcepub fn unregister_subscription_alias(&self, canonical: &Ustr)
pub fn unregister_subscription_alias(&self, canonical: &Ustr)
Removes an alias registration. Safe to call if no entry exists.
Sourcepub fn subscriptions(&self) -> &SubscriptionState
pub fn subscriptions(&self) -> &SubscriptionState
Returns the subscription state.
Sourcepub async fn update_instrument(&self, instrument: InstrumentAny)
pub async fn update_instrument(&self, instrument: InstrumentAny)
Updates an instrument in the cache and notifies the handler.
Sourcepub fn take_out_rx(&mut self) -> Option<UnboundedReceiver<NautilusWsMessage>>
pub fn take_out_rx(&mut self) -> Option<UnboundedReceiver<NautilusWsMessage>>
Takes the output message receiver, leaving None in its place.
Used by the data client to move the receiver into a background consumption task.
Sourcepub fn register_bar_type(&mut self, key: String, bar_type: BarType)
pub fn register_bar_type(&mut self, key: String, bar_type: BarType)
Registers a bar type locally without notifying the handler.
Used by the data client to persist registrations on the original client before cloning for async command dispatch.
Sourcepub async fn add_bar_type(&mut self, key: String, bar_type: BarType)
pub async fn add_bar_type(&mut self, key: String, bar_type: BarType)
Registers a bar type for candle parsing.
Trait Implementations§
Source§impl Clone for CoinbaseWebSocketClient
impl Clone for CoinbaseWebSocketClient
Source§impl Debug for CoinbaseWebSocketClient
impl Debug for CoinbaseWebSocketClient
Source§impl<'a, 'py> FromPyObject<'a, 'py> for CoinbaseWebSocketClientwhere
Self: Clone,
impl<'a, 'py> FromPyObject<'a, 'py> for CoinbaseWebSocketClientwhere
Self: Clone,
Source§impl<'py> IntoPyObject<'py> for CoinbaseWebSocketClient
impl<'py> IntoPyObject<'py> for CoinbaseWebSocketClient
Source§type Target = CoinbaseWebSocketClient
type Target = CoinbaseWebSocketClient
Source§type Output = Bound<'py, <CoinbaseWebSocketClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <CoinbaseWebSocketClient as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for CoinbaseWebSocketClient
impl PyClass for CoinbaseWebSocketClient
Source§impl PyClassImpl for CoinbaseWebSocketClient
impl PyClassImpl for CoinbaseWebSocketClient
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// WebSocket client for Coinbase Advanced Trade market data and user streams.
///
/// Manages connection lifecycle, subscription state, and JWT authentication.
/// Spawns a [`FeedHandler`] task that parses raw messages into Nautilus types.
const RAW_DOC: &'static CStr = /// WebSocket client for Coinbase Advanced Trade market data and user streams. /// /// Manages connection lifecycle, subscription state, and JWT authentication. /// Spawns a [`FeedHandler`] task that parses raw messages into Nautilus types.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<CoinbaseWebSocketClient as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<CoinbaseWebSocketClient>
type Layout = <<CoinbaseWebSocketClient as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<CoinbaseWebSocketClient>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
type Inventory = Pyo3MethodsInventoryForCoinbaseWebSocketClient
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyStubType for CoinbaseWebSocketClient
impl PyStubType for CoinbaseWebSocketClient
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
§fn type_input() -> TypeInfo
fn type_input() -> TypeInfo
Source§impl PyTypeInfo for CoinbaseWebSocketClient
impl PyTypeInfo for CoinbaseWebSocketClient
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for CoinbaseWebSocketClient
Auto Trait Implementations§
impl Freeze for CoinbaseWebSocketClient
impl !RefUnwindSafe for CoinbaseWebSocketClient
impl Send for CoinbaseWebSocketClient
impl Sync for CoinbaseWebSocketClient
impl Unpin for CoinbaseWebSocketClient
impl UnsafeUnpin for CoinbaseWebSocketClient
impl !UnwindSafe for CoinbaseWebSocketClient
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more