pub struct KrakenFuturesWebSocketClient { /* private fields */ }Expand description
WebSocket client for the Kraken Futures v1 streaming API.
Implementations§
Source§impl KrakenFuturesWebSocketClient
impl KrakenFuturesWebSocketClient
Sourcepub fn new(url: String, heartbeat_secs: u64, proxy_url: Option<String>) -> Self
pub fn new(url: String, heartbeat_secs: u64, proxy_url: Option<String>) -> Self
Creates a new client with the given URL.
Sourcepub fn with_credentials(
url: String,
heartbeat_secs: u64,
credential: Option<KrakenCredential>,
transport_backend: TransportBackend,
proxy_url: Option<String>,
) -> Self
pub fn with_credentials( url: String, heartbeat_secs: u64, credential: Option<KrakenCredential>, transport_backend: TransportBackend, proxy_url: Option<String>, ) -> Self
Creates a new client with API credentials for authenticated feeds.
Sourcepub fn has_credentials(&self) -> bool
pub fn has_credentials(&self) -> bool
Returns true if the client has API credentials set.
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 WebSocket 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 feeds.
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 the WebSocket connection for private feeds.
Sends a challenge request and waits for the handler to parse the response,
sign it, and mark the AuthTracker successful. Private subscriptions gate
on the stored challenge / signed-challenge pair.
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 subscribe_mark_price(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn subscribe_mark_price( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Subscribes to mark price updates for the given instrument.
Sourcepub async fn unsubscribe_mark_price(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_mark_price( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Unsubscribes from mark price updates for the given instrument.
Sourcepub async fn subscribe_index_price(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn subscribe_index_price( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Subscribes to index price updates for the given instrument.
Sourcepub async fn unsubscribe_index_price(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_index_price( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Unsubscribes from index price updates for the given instrument.
Sourcepub async fn subscribe_funding_rate(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn subscribe_funding_rate( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Subscribes to funding rate updates for the given instrument.
Sourcepub async fn unsubscribe_funding_rate(
&self,
instrument_id: InstrumentId,
) -> Result<(), KrakenWsError>
pub async fn unsubscribe_funding_rate( &self, instrument_id: InstrumentId, ) -> Result<(), KrakenWsError>
Unsubscribes from funding rate 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 order book channel for low-latency top-of-book quotes.
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 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 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 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.
Note: The depth parameter is accepted for API compatibility with spot client but is
not used by Kraken Futures (full book is always returned).
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 fn take_output_rx(
&mut self,
) -> Option<UnboundedReceiver<KrakenFuturesWsMessage>>
pub fn take_output_rx( &mut self, ) -> Option<UnboundedReceiver<KrakenFuturesWsMessage>>
Gets the output receiver for processed messages.
Sourcepub async fn set_auth_credentials(
&self,
original_challenge: String,
signed_challenge: String,
) -> Result<(), KrakenWsError>
pub async fn set_auth_credentials( &self, original_challenge: String, signed_challenge: String, ) -> Result<(), KrakenWsError>
Set authentication credentials directly (for when challenge is obtained externally).
Sourcepub fn sign_challenge(&self, challenge: &str) -> Result<String, KrakenWsError>
pub fn sign_challenge(&self, challenge: &str) -> Result<String, KrakenWsError>
Sign a challenge with the API credentials.
Returns the signed challenge on success.
Sourcepub async fn authenticate_with_challenge(
&self,
challenge: &str,
) -> Result<(), KrakenWsError>
pub async fn authenticate_with_challenge( &self, challenge: &str, ) -> Result<(), KrakenWsError>
Complete authentication with a received challenge.
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.
Returns a reference to the shared account ID.
Sourcepub fn truncated_id_map(&self) -> &Arc<AtomicMap<String, ClientOrderId>> ⓘ
pub fn truncated_id_map(&self) -> &Arc<AtomicMap<String, ClientOrderId>> ⓘ
Returns a reference to the truncated ID map.
Sourcepub fn order_instrument_map(&self) -> &Arc<AtomicMap<String, InstrumentId>> ⓘ
pub fn order_instrument_map(&self) -> &Arc<AtomicMap<String, InstrumentId>> ⓘ
Returns a reference to the order-to-instrument map.
Returns a reference to the shared instruments map.
Sourcepub fn subscriptions(&self) -> &SubscriptionState
pub fn subscriptions(&self) -> &SubscriptionState
Returns a reference to the subscription state.
Sourcepub fn cache_instrument(&self, instrument: InstrumentAny)
pub fn cache_instrument(&self, instrument: InstrumentAny)
Caches an instrument for execution report parsing.
Sourcepub fn cache_instruments(&self, instruments: &[InstrumentAny])
pub fn cache_instruments(&self, instruments: &[InstrumentAny])
Caches multiple instruments for execution report parsing.
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 and instrument lookup.
Kraken Futures limits client order IDs to 18 characters, so orders with longer IDs are truncated. This method stores the mapping from truncated to full ID, and from venue order ID to instrument ID for cancel messages.
Sourcepub async fn subscribe_open_orders(&self) -> Result<(), KrakenWsError>
pub async fn subscribe_open_orders(&self) -> Result<(), KrakenWsError>
Subscribes to open orders feed (private, requires authentication).
Sourcepub async fn subscribe_fills(&self) -> Result<(), KrakenWsError>
pub async fn subscribe_fills(&self) -> Result<(), KrakenWsError>
Subscribes to fills feed (private, requires authentication).
Sourcepub async fn subscribe_executions(&self) -> Result<(), KrakenWsError>
pub async fn subscribe_executions(&self) -> Result<(), KrakenWsError>
Subscribes to both open orders and fills (convenience method).
Trait Implementations§
Source§impl Clone for KrakenFuturesWebSocketClient
impl Clone for KrakenFuturesWebSocketClient
Source§impl Debug for KrakenFuturesWebSocketClient
impl Debug for KrakenFuturesWebSocketClient
Source§impl<'a, 'py> FromPyObject<'a, 'py> for KrakenFuturesWebSocketClientwhere
Self: Clone,
impl<'a, 'py> FromPyObject<'a, 'py> for KrakenFuturesWebSocketClientwhere
Self: Clone,
Source§impl<'py> IntoPyObject<'py> for KrakenFuturesWebSocketClient
impl<'py> IntoPyObject<'py> for KrakenFuturesWebSocketClient
Source§type Target = KrakenFuturesWebSocketClient
type Target = KrakenFuturesWebSocketClient
Source§type Output = Bound<'py, <KrakenFuturesWebSocketClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <KrakenFuturesWebSocketClient 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 KrakenFuturesWebSocketClient
impl PyClass for KrakenFuturesWebSocketClient
Source§impl PyClassImpl for KrakenFuturesWebSocketClient
impl PyClassImpl for KrakenFuturesWebSocketClient
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 Futures v1 streaming API.
const RAW_DOC: &'static CStr = /// WebSocket client for the Kraken Futures v1 streaming API.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<KrakenFuturesWebSocketClient as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<KrakenFuturesWebSocketClient>
type Layout = <<KrakenFuturesWebSocketClient as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<KrakenFuturesWebSocketClient>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
type Inventory = Pyo3MethodsInventoryForKrakenFuturesWebSocketClient
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 KrakenFuturesWebSocketClient
impl PyClassNewTextSignature for KrakenFuturesWebSocketClient
const TEXT_SIGNATURE: &'static str = "(environment=None, base_url=None, heartbeat_secs=60, api_key=None, api_secret=None, proxy_url=None)"
Source§impl PyStubType for KrakenFuturesWebSocketClient
impl PyStubType for KrakenFuturesWebSocketClient
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
§fn type_input() -> TypeInfo
fn type_input() -> TypeInfo
Source§impl PyTypeInfo for KrakenFuturesWebSocketClient
impl PyTypeInfo for KrakenFuturesWebSocketClient
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 KrakenFuturesWebSocketClient
Auto Trait Implementations§
impl Freeze for KrakenFuturesWebSocketClient
impl !RefUnwindSafe for KrakenFuturesWebSocketClient
impl Send for KrakenFuturesWebSocketClient
impl Sync for KrakenFuturesWebSocketClient
impl Unpin for KrakenFuturesWebSocketClient
impl UnsafeUnpin for KrakenFuturesWebSocketClient
impl !UnwindSafe for KrakenFuturesWebSocketClient
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