pub struct TradeSession { /* private fields */ }Expand description
交易会话
Implementations§
Source§impl TradeSession
impl TradeSession
Sourcepub fn new(
broker: String,
user_id: String,
password: String,
dm: Arc<DataManager>,
ws_url: String,
ws_config: WebSocketConfig,
) -> Self
pub fn new( broker: String, user_id: String, password: String, dm: Arc<DataManager>, ws_url: String, ws_config: WebSocketConfig, ) -> Self
创建交易会话
Sourcepub async fn on_account<F>(&self, handler: F)
pub async fn on_account<F>(&self, handler: F)
注册账户更新回调
Sourcepub async fn on_position<F>(&self, handler: F)
pub async fn on_position<F>(&self, handler: F)
注册持仓更新回调
Sourcepub async fn on_notification<F>(&self, handler: F)
pub async fn on_notification<F>(&self, handler: F)
注册通知回调
Sourcepub fn account_channel(&self) -> Receiver<Account>
pub fn account_channel(&self) -> Receiver<Account>
获取账户更新 Channel(克隆接收端)
Sourcepub fn position_channel(&self) -> Receiver<PositionUpdate>
pub fn position_channel(&self) -> Receiver<PositionUpdate>
获取持仓更新 Channel(克隆接收端)
Sourcepub fn order_channel(&self) -> Receiver<Order>
pub fn order_channel(&self) -> Receiver<Order>
获取委托单更新 Channel(克隆接收端)
Sourcepub fn trade_channel(&self) -> Receiver<Trade>
pub fn trade_channel(&self) -> Receiver<Trade>
获取成交记录 Channel(克隆接收端)
Sourcepub fn notification_channel(&self) -> Receiver<Notification>
pub fn notification_channel(&self) -> Receiver<Notification>
获取通知 Channel(克隆接收端)
Source§impl TradeSession
impl TradeSession
Sourcepub async fn insert_order(&self, req: &InsertOrderRequest) -> Result<Order>
pub async fn insert_order(&self, req: &InsertOrderRequest) -> Result<Order>
下单
Sourcepub async fn cancel_order(&self, order_id: &str) -> Result<()>
pub async fn cancel_order(&self, order_id: &str) -> Result<()>
撤单
Sourcepub async fn get_account(&self) -> Result<Account>
pub async fn get_account(&self) -> Result<Account>
获取账户信息
Sourcepub async fn get_position(&self, symbol: &str) -> Result<Position>
pub async fn get_position(&self, symbol: &str) -> Result<Position>
获取指定合约的持仓
Auto Trait Implementations§
impl Freeze for TradeSession
impl !RefUnwindSafe for TradeSession
impl Send for TradeSession
impl Sync for TradeSession
impl !Unpin for TradeSession
impl !UnwindSafe for TradeSession
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