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: Option<u64>) -> Self
pub fn new(url: String, heartbeat_secs: Option<u64>) -> Self
Creates a new client with the given URL.
Sourcepub fn with_credentials(
url: String,
heartbeat_secs: Option<u64>,
credential: Option<KrakenCredential>,
) -> Self
pub fn with_credentials( url: String, heartbeat_secs: Option<u64>, credential: Option<KrakenCredential>, ) -> 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 async fn authenticate(&self) -> Result<(), KrakenWsError>
pub async fn authenticate(&self) -> Result<(), KrakenWsError>
Authenticates the WebSocket connection for private feeds.
This sends a challenge request, waits for the response, signs it, and stores the credentials for use in private subscriptions.
Sourcepub fn cache_instruments(&self, instruments: Vec<InstrumentAny>)
pub fn cache_instruments(&self, instruments: Vec<InstrumentAny>)
Caches instruments for price precision lookup (bulk replace).
Must be called after connect() when the handler is ready to receive commands.
Sourcepub fn cache_instrument(&self, instrument: InstrumentAny)
pub fn cache_instrument(&self, instrument: InstrumentAny)
Caches a single instrument for price precision lookup (upsert).
Must be called after connect() when the handler is ready to receive commands.
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_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 fn set_account_id(&self, account_id: AccountId)
pub fn set_account_id(&self, account_id: AccountId)
Sets the account ID for execution reports.
Must be called before subscribing to execution feeds to properly generate OrderStatusReport and FillReport objects.
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 ID mapping for order tracking.
This caches the trader_id, strategy_id, and instrument_id for an order, allowing the handler to emit proper order events with correct identifiers when WebSocket messages arrive.
Sourcepub async fn request_challenge(&self) -> Result<(), KrakenWsError>
pub async fn request_challenge(&self) -> Result<(), KrakenWsError>
Requests a challenge from the WebSocket for authentication.
After calling this, listen for the challenge response message and then
call authenticate_with_challenge() to complete authentication.
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 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<'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 ThreadChecker = SendablePyClass<KrakenFuturesWebSocketClient>
type ThreadChecker = SendablePyClass<KrakenFuturesWebSocketClient>
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<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for KrakenFuturesWebSocketClient
impl PyClassNewTextSignature for KrakenFuturesWebSocketClient
const TEXT_SIGNATURE: &'static str = "(environment=None, base_url=None, heartbeat_secs=None, api_key=None, api_secret=None)"
Source§impl PyMethods<KrakenFuturesWebSocketClient> for PyClassImplCollector<KrakenFuturesWebSocketClient>
impl PyMethods<KrakenFuturesWebSocketClient> for PyClassImplCollector<KrakenFuturesWebSocketClient>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for KrakenFuturesWebSocketClient
impl PyTypeInfo for KrakenFuturesWebSocketClient
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
impl ExtractPyClassWithClone 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 !UnwindSafe for KrakenFuturesWebSocketClient
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§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 moreSource§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
Source§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
§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