Improve outgoing Alpaca API types
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -108,7 +108,14 @@ async fn handle_asset_status_message(
|
||||
.await
|
||||
.send(tungstenite::Message::Text(
|
||||
to_string(&websocket::outgoing::Message::Subscribe(
|
||||
create_websocket_market_message(thread_type, symbols),
|
||||
match thread_type {
|
||||
ThreadType::Bars(_) => {
|
||||
websocket::outgoing::subscribe::Message::new_market(symbols)
|
||||
}
|
||||
ThreadType::News => {
|
||||
websocket::outgoing::subscribe::Message::new_news(symbols)
|
||||
}
|
||||
},
|
||||
))
|
||||
.unwrap(),
|
||||
))
|
||||
@@ -140,7 +147,14 @@ async fn handle_asset_status_message(
|
||||
.await
|
||||
.send(tungstenite::Message::Text(
|
||||
to_string(&websocket::outgoing::Message::Unsubscribe(
|
||||
create_websocket_market_message(thread_type, symbols),
|
||||
match thread_type {
|
||||
ThreadType::Bars(_) => {
|
||||
websocket::outgoing::subscribe::Message::new_market(symbols)
|
||||
}
|
||||
ThreadType::News => {
|
||||
websocket::outgoing::subscribe::Message::new_news(symbols)
|
||||
}
|
||||
},
|
||||
))
|
||||
.unwrap(),
|
||||
))
|
||||
@@ -154,17 +168,3 @@ async fn handle_asset_status_message(
|
||||
|
||||
message.response.send(()).unwrap();
|
||||
}
|
||||
|
||||
fn create_websocket_market_message(
|
||||
thread_type: ThreadType,
|
||||
symbols: Vec<String>,
|
||||
) -> websocket::outgoing::subscribe::Message {
|
||||
match thread_type {
|
||||
ThreadType::Bars(_) => websocket::outgoing::subscribe::Message::Market(
|
||||
websocket::outgoing::subscribe::MarketMessage::new(symbols),
|
||||
),
|
||||
ThreadType::News => websocket::outgoing::subscribe::Message::News(
|
||||
websocket::outgoing::subscribe::NewsMessage::new(symbols),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user