Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/ib_tws_core/src/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,29 @@ impl AsyncClient {
.unwrap()
}

pub async fn request_contract_details_many(
&self,
message: ReqContractDetails,
) -> Result<impl Stream<Item = Result<ContractDetails, Error>> + '_, Error> {
let request_id = self.send(Request::ReqContractDetails(message)).await?;

Ok(self.response_stream_by_id(Some(request_id))
.take_while(|response| {
let is_end = matches!(response, Response::ContractDataEndMsg(_));
async move { !is_end }
})
.filter_map(|response| async move {
match response {
Response::ErrMsgMsg(err) => Some(Err(Error::ApiError(err))),
Response::ContractDataMsg(msg) => Some(Ok(msg.contract_details)),
_ => {
warn!(?response, "unexpected response for request id");
None
}
}
}))
}

#[instrument(skip(self))]
pub async fn request_account_summary(
&self,
Expand Down