pub struct Session { /* private fields */ }Expand description
FIX session manager
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
config: &DeribitFixConfig,
connection: Arc<Mutex<Connection>>,
) -> Result<Self>
pub fn new( config: &DeribitFixConfig, connection: Arc<Mutex<Connection>>, ) -> Result<Self>
Create a new FIX session
Sourcepub fn set_connection(&mut self, connection: Arc<Mutex<Connection>>)
pub fn set_connection(&mut self, connection: Arc<Mutex<Connection>>)
Set the connection for this session
Sourcepub fn get_state(&self) -> SessionState
pub fn get_state(&self) -> SessionState
Get the current session state
Sourcepub async fn logout_with_options(
&mut self,
text: Option<String>,
dont_cancel_on_disconnect: Option<bool>,
) -> Result<()>
pub async fn logout_with_options( &mut self, text: Option<String>, dont_cancel_on_disconnect: Option<bool>, ) -> Result<()>
Perform FIX logout with optional parameters
Sourcepub async fn send_heartbeat(
&mut self,
test_req_id: Option<String>,
) -> Result<()>
pub async fn send_heartbeat( &mut self, test_req_id: Option<String>, ) -> Result<()>
Send a heartbeat message
Sourcepub async fn send_new_order(&mut self, order: NewOrderRequest) -> Result<String>
pub async fn send_new_order(&mut self, order: NewOrderRequest) -> Result<String>
Send a new order
Sourcepub async fn cancel_order(&mut self, order_id: String) -> Result<()>
pub async fn cancel_order(&mut self, order_id: String) -> Result<()>
Cancel an order
§Arguments
order_id- The order identifier (OrigClOrdID) to cancelsymbol- Optional instrument symbol. Required when canceling by ClOrdID or DeribitLabel, but not required when using OrigClOrdID (fastest approach)currency- Optional currency to speed up search when using ClOrdID or DeribitLabel
Sourcepub async fn cancel_order_with_symbol(
&mut self,
order_id: String,
symbol: Option<String>,
) -> Result<()>
pub async fn cancel_order_with_symbol( &mut self, order_id: String, symbol: Option<String>, ) -> Result<()>
Cancel an order with optional symbol specification
According to Deribit FIX documentation:
- Canceling by OrigClOrdId is fastest and recommended when possible
- Symbol is required only when OrigClOrdId is absent (canceling by ClOrdID or DeribitLabel)
- Currency can optionally speed up searches by DeribitLabel or ClOrdID
§Arguments
order_id- The order identifier (OrigClOrdID) to cancelsymbol- Optional instrument symbol (e.g., “BTC-PERPETUAL”)currency- Optional currency to speed up search
Sourcepub async fn subscribe_market_data(&mut self, symbol: String) -> Result<()>
pub async fn subscribe_market_data(&mut self, symbol: String) -> Result<()>
Subscribe to market data
Sourcepub async fn request_positions(&mut self) -> Result<Vec<Position>>
pub async fn request_positions(&mut self) -> Result<Vec<Position>>
Request positions asynchronously
Sourcepub fn generate_auth_data(
&self,
access_secret: &str,
) -> Result<(String, String)>
pub fn generate_auth_data( &self, access_secret: &str, ) -> Result<(String, String)>
Generate authentication data according to Deribit FIX specification Returns (raw_data, base64_password_hash)
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
Get current session state
Sourcepub fn set_state(&mut self, state: SessionState)
pub fn set_state(&mut self, state: SessionState)
Set session state (for testing)
Sourcepub async fn receive_and_process_message(
&mut self,
) -> Result<Option<FixMessage>>
pub async fn receive_and_process_message( &mut self, ) -> Result<Option<FixMessage>>
Receive and process a FIX message from the connection
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
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
Mutably borrows from an owned value. Read more