pub struct KrakenSpotWebSocketClient { /* private fields */ }Expand description
WebSocket client for the Kraken Spot v2 streaming API.
Implementations§
Source§impl KrakenSpotWebSocketClient
impl KrakenSpotWebSocketClient
Sourcepub fn new(
config: KrakenDataClientConfig,
cancellation_token: CancellationToken,
proxy_url: Option<String>,
) -> Self
pub fn new( config: KrakenDataClientConfig, cancellation_token: CancellationToken, proxy_url: Option<String>, ) -> Self
Creates a new client with the given configuration.
Sourcepub async fn connect(&mut self) -> Result<(), KrakenWsError>
pub async fn connect(&mut self) -> Result<(), KrakenWsError>
Connects to the WebSocket server.
Sourcepub async fn disconnect(&mut self) -> Result<(), KrakenWsError>
pub async fn disconnect(&mut self) -> Result<(), KrakenWsError>
Disconnects from the WebSocket server.
Sourcepub async fn close(&mut self) -> Result<(), KrakenWsError>
pub async fn close(&mut self) -> Result<(), KrakenWsError>
Closes the WebSocket connection.
Sourcepub async fn wait_until_active(
&self,
timeout_secs: f64,
) -> Result<(), KrakenWsError>
pub async fn wait_until_active( &self, timeout_secs: f64, ) -> Result<(), KrakenWsError>
Waits until the connection is active or timeout.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Returns true if the WebSocket is authenticated for private subscriptions.
Sourcepub async fn wait_until_authenticated(
&self,
timeout_secs: f64,
) -> Result<(), KrakenWsError>
pub async fn wait_until_authenticated( &self, timeout_secs: f64, ) -> Result<(), KrakenWsError>
Waits until the WebSocket is authenticated or the timeout elapses.
Returns an error on timeout or explicit auth failure.
Sourcepub async fn authenticate(&self) -> Result<(), KrakenWsError>
pub async fn authenticate(&self) -> Result<(), KrakenWsError>
Authenticates with the Kraken API to enable private subscriptions.
Sourcepub fn cancel_all_requests(&self)
pub fn cancel_all_requests(&self)
Cancels all pending requests.
Sourcepub fn cancellation_token(&self) -> &CancellationToken
pub fn cancellation_token(&self) -> &CancellationToken
Returns the cancellation token for this client.
Sourcepub async fn subscribe(
&self,
channel: KrakenWsChannel,
symbols: Vec<Ustr>,
depth: Option<u32>,
) -> Result<(), KrakenWsError>
pub async fn subscribe( &self, channel: KrakenWsChannel, symbols: Vec<Ustr>, depth: Option<u32>, ) -> Result<(), KrakenWsError>
Subscribes to a channel for the given symbols.
Sourcepub async fn unsubscribe(
&self,
channel: KrakenWsChannel,
symbols: Vec<Ustr>,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe( &self, channel: KrakenWsChannel, symbols: Vec<Ustr>, ) -> Result<(), KrakenWsError>
Unsubscribes from a channel for the given symbols.
Sourcepub async fn send_ping(&self) -> Result<(), KrakenWsError>
pub async fn send_ping(&self) -> Result<(), KrakenWsError>
Sends a ping message to keep the connection alive.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true if connected (not closed).
Sourcepub fn get_subscriptions(&self) -> Vec<String>
pub fn get_subscriptions(&self) -> Vec<String>
Returns all active subscriptions.
Sourcepub fn set_account_id(&self, account_id: AccountId)
pub fn set_account_id(&self, account_id: AccountId)
Sets the account ID for execution report parsing.
Sourcepub fn account_id(&self) -> Option<AccountId>
pub fn account_id(&self) -> Option<AccountId>
Returns the account ID if set.
Sourcepub fn cache_instrument(&self, instrument: InstrumentAny)
pub fn cache_instrument(&self, instrument: InstrumentAny)
Caches an instrument for execution report parsing.
Returns a shared reference to the account ID.
Sourcepub fn truncated_id_map(&self) -> &Arc<AtomicMap<String, ClientOrderId>> ⓘ
pub fn truncated_id_map(&self) -> &Arc<AtomicMap<String, ClientOrderId>> ⓘ
Returns a shared reference to the truncated ID map.
Sourcepub fn cache_client_order(
&self,
client_order_id: ClientOrderId,
_venue_order_id: Option<VenueOrderId>,
_instrument_id: InstrumentId,
_trader_id: TraderId,
_strategy_id: StrategyId,
)
pub fn cache_client_order( &self, client_order_id: ClientOrderId, _venue_order_id: Option<VenueOrderId>, _instrument_id: InstrumentId, _trader_id: TraderId, _strategy_id: StrategyId, )
Caches a client order for truncated ID resolution.
Sourcepub fn stream(
&mut self,
) -> Result<impl Stream<Item = KrakenSpotWsMessage> + use<>, KrakenWsError>
pub fn stream( &mut self, ) -> Result<impl Stream<Item = KrakenSpotWsMessage> + use<>, KrakenWsError>
Returns a stream of WebSocket messages.
§Errors
Returns an error if:
- The stream receiver has already been taken
- Other clones of this client still hold references to the receiver
Sourcepub async fn subscribe_book(
&self,
instrument_id: InstrumentId,
depth: Option<u32>,
) -> Result<(), KrakenWsError>
pub async fn subscribe_book( &self, instrument_id: InstrumentId, depth: Option<u32>, ) -> Result<(), KrakenWsError>
Subscribes to order book updates for the given instrument.
Sourcepub async fn subscribe_quotes(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn subscribe_quotes( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Subscribes to quote updates for the given instrument.
Uses the Ticker channel with event_trigger: "bbo" for updates only on
best bid/offer changes.
Sourcepub async fn subscribe_trades(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn subscribe_trades( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Subscribes to trade updates for the given instrument.
Sourcepub async fn subscribe_bars(
&self,
bar_type: BarType,
) -> Result<(), KrakenWsError>
pub async fn subscribe_bars( &self, bar_type: BarType, ) -> Result<(), KrakenWsError>
Subscribes to bar/OHLC updates for the given bar type.
§Errors
Returns an error if the bar aggregation is not supported by Kraken.
Sourcepub async fn subscribe_executions(
&self,
snap_orders: bool,
snap_trades: bool,
) -> Result<(), KrakenWsError>
pub async fn subscribe_executions( &self, snap_orders: bool, snap_trades: bool, ) -> Result<(), KrakenWsError>
Subscribes to execution updates (order and fill events).
Requires authentication - call authenticate() first.
Sourcepub async fn unsubscribe_book(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_book( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Unsubscribes from order book updates for the given instrument.
Sourcepub async fn unsubscribe_quotes(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_quotes( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Unsubscribes from quote updates for the given instrument.
Sourcepub async fn unsubscribe_trades(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_trades( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Unsubscribes from trade updates for the given instrument.
Sourcepub async fn unsubscribe_bars(
&self,
bar_type: BarType,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_bars( &self, bar_type: BarType, ) -> Result<(), KrakenWsError>
Unsubscribes from bar/OHLC updates for the given bar type.
§Errors
Returns an error if the bar aggregation is not supported by Kraken.
Trait Implementations§
Source§impl Clone for KrakenSpotWebSocketClient
impl Clone for KrakenSpotWebSocketClient
Source§impl Debug for KrakenSpotWebSocketClient
impl Debug for KrakenSpotWebSocketClient
Source§impl<'a, 'py> FromPyObject<'a, 'py> for KrakenSpotWebSocketClientwhere
Self: Clone,
impl<'a, 'py> FromPyObject<'a, 'py> for KrakenSpotWebSocketClientwhere
Self: Clone,
Source§impl<'py> IntoPyObject<'py> for KrakenSpotWebSocketClient
impl<'py> IntoPyObject<'py> for KrakenSpotWebSocketClient
Source§type Target = KrakenSpotWebSocketClient
type Target = KrakenSpotWebSocketClient
Source§type Output = Bound<'py, <KrakenSpotWebSocketClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <KrakenSpotWebSocketClient 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 KrakenSpotWebSocketClient
impl PyClass for KrakenSpotWebSocketClient
Source§impl PyClassImpl for KrakenSpotWebSocketClient
impl PyClassImpl for KrakenSpotWebSocketClient
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 the Kraken Spot v2 streaming API.
const RAW_DOC: &'static CStr = /// WebSocket client for the Kraken Spot v2 streaming API.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<KrakenSpotWebSocketClient as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<KrakenSpotWebSocketClient>
type Layout = <<KrakenSpotWebSocketClient as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<KrakenSpotWebSocketClient>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
type Inventory = Pyo3MethodsInventoryForKrakenSpotWebSocketClient
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 PyClassNewTextSignature for KrakenSpotWebSocketClient
impl PyClassNewTextSignature for KrakenSpotWebSocketClient
const TEXT_SIGNATURE: &'static str = "(environment=None, private=False, base_url=None, heartbeat_secs=None, api_key=None, api_secret=None, proxy_url=None)"
Source§impl PyStubType for KrakenSpotWebSocketClient
impl PyStubType for KrakenSpotWebSocketClient
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
§fn type_input() -> TypeInfo
fn type_input() -> TypeInfo
Source§impl PyTypeInfo for KrakenSpotWebSocketClient
impl PyTypeInfo for KrakenSpotWebSocketClient
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 KrakenSpotWebSocketClient
Auto Trait Implementations§
impl Freeze for KrakenSpotWebSocketClient
impl !RefUnwindSafe for KrakenSpotWebSocketClient
impl Send for KrakenSpotWebSocketClient
impl Sync for KrakenSpotWebSocketClient
impl Unpin for KrakenSpotWebSocketClient
impl UnsafeUnpin for KrakenSpotWebSocketClient
impl !UnwindSafe for KrakenSpotWebSocketClient
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