pub struct BinanceSpotWsTradingClient { /* private fields */ }Expand description
Binance Spot WebSocket API client for SBE trading.
This client provides order management via WebSocket with SBE-encoded responses, complementing the HTTP client with lower-latency order submission.
Implementations§
Source§impl BinanceSpotWsTradingClient
impl BinanceSpotWsTradingClient
Sourcepub fn new(
url: Option<String>,
api_key: String,
api_secret: String,
heartbeat: Option<u64>,
) -> Self
pub fn new( url: Option<String>, api_key: String, api_secret: String, heartbeat: Option<u64>, ) -> Self
Creates a new BinanceSpotWsTradingClient instance.
Sourcepub fn with_env(
url: Option<String>,
api_key: Option<String>,
api_secret: Option<String>,
heartbeat: Option<u64>,
) -> Result<Self>
pub fn with_env( url: Option<String>, api_key: Option<String>, api_secret: Option<String>, heartbeat: Option<u64>, ) -> Result<Self>
Creates a new client with credentials sourced from environment variables.
Falls back to env vars if api_key or api_secret are None:
BINANCE_API_KEYfor the API keyBINANCE_API_SECRETfor the API secret
§Errors
Returns an error if credentials are missing from environment.
Sourcepub fn from_env(url: Option<String>, heartbeat: Option<u64>) -> Result<Self>
pub fn from_env(url: Option<String>, heartbeat: Option<u64>) -> Result<Self>
Creates a new client with credentials loaded entirely from environment variables.
Reads:
BINANCE_API_KEYfor the API keyBINANCE_API_SECRETfor the API secret
§Errors
Returns an error if environment variables are missing.
Sourcepub async fn connect(&mut self) -> BinanceWsApiResult<()>
pub async fn connect(&mut self) -> BinanceWsApiResult<()>
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Disconnects from the WebSocket API server.
Sourcepub async fn place_order(
&self,
params: NewOrderParams,
) -> BinanceWsApiResult<String>
pub async fn place_order( &self, params: NewOrderParams, ) -> BinanceWsApiResult<String>
Sourcepub async fn cancel_order(
&self,
params: CancelOrderParams,
) -> BinanceWsApiResult<String>
pub async fn cancel_order( &self, params: CancelOrderParams, ) -> BinanceWsApiResult<String>
Sourcepub async fn cancel_replace_order(
&self,
params: CancelReplaceOrderParams,
) -> BinanceWsApiResult<String>
pub async fn cancel_replace_order( &self, params: CancelReplaceOrderParams, ) -> BinanceWsApiResult<String>
Cancel and replace an order atomically via WebSocket API.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn cancel_all_orders(
&self,
symbol: impl Into<String>,
) -> BinanceWsApiResult<String>
pub async fn cancel_all_orders( &self, symbol: impl Into<String>, ) -> BinanceWsApiResult<String>
Cancels all open orders for a symbol via WebSocket API.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn recv(&self) -> Option<NautilusWsApiMessage>
pub async fn recv(&self) -> Option<NautilusWsApiMessage>
Receives the next message from the handler.
Returns None if the receiver is closed or not initialized.
§Panics
Panics if the internal output receiver mutex is poisoned.
Trait Implementations§
Source§impl Clone for BinanceSpotWsTradingClient
impl Clone for BinanceSpotWsTradingClient
Source§fn clone(&self) -> BinanceSpotWsTradingClient
fn clone(&self) -> BinanceSpotWsTradingClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BinanceSpotWsTradingClient
impl Debug for BinanceSpotWsTradingClient
Source§impl<'py> IntoPyObject<'py> for BinanceSpotWsTradingClient
impl<'py> IntoPyObject<'py> for BinanceSpotWsTradingClient
Source§type Target = BinanceSpotWsTradingClient
type Target = BinanceSpotWsTradingClient
Source§type Output = Bound<'py, <BinanceSpotWsTradingClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <BinanceSpotWsTradingClient 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 BinanceSpotWsTradingClient
impl PyClass for BinanceSpotWsTradingClient
Source§impl PyClassImpl for BinanceSpotWsTradingClient
impl PyClassImpl for BinanceSpotWsTradingClient
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 = /// Binance Spot WebSocket API client for SBE trading.
///
/// This client provides order management via WebSocket with SBE-encoded responses,
/// complementing the HTTP client with lower-latency order submission.
const RAW_DOC: &'static CStr = /// Binance Spot WebSocket API client for SBE trading. /// /// This client provides order management via WebSocket with SBE-encoded responses, /// complementing the HTTP client with lower-latency order submission.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<BinanceSpotWsTradingClient>
type ThreadChecker = SendablePyClass<BinanceSpotWsTradingClient>
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 PyTypeInfo for BinanceSpotWsTradingClient
impl PyTypeInfo for BinanceSpotWsTradingClient
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 BinanceSpotWsTradingClient
impl ExtractPyClassWithClone for BinanceSpotWsTradingClient
Auto Trait Implementations§
impl Freeze for BinanceSpotWsTradingClient
impl !RefUnwindSafe for BinanceSpotWsTradingClient
impl Send for BinanceSpotWsTradingClient
impl Sync for BinanceSpotWsTradingClient
impl Unpin for BinanceSpotWsTradingClient
impl !UnwindSafe for BinanceSpotWsTradingClient
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
§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