-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for binance options (#96)
* binance: add binance european options endpoint * binance: empty content type for binance-e get req * binance: finish the adaption for options insts * binance: fix default stream * binance: allow dispatch req in svc * binance: finish the adaption for options trade * binance: finish the adaption for options depth * binance: finish the adaptation for options candles * binance: fix the stream name bugs * binance: fix the format of trade * binance: finish the adaptation of sub option order * binance: finish the adaptation for options trading * binance: allow dispatching main/sub streams * binance: add example for subscriptiong options ws * binance: add CHANNEL env
- Loading branch information
Nouzan
authored
Feb 11, 2024
1 parent
caa5463
commit c96b647
Showing
42 changed files
with
1,502 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use std::time::Duration; | ||
|
||
use exc_binance::{ | ||
websocket::{protocol::frame::Name, request::WsRequest}, | ||
Binance, Request, | ||
}; | ||
use futures::StreamExt; | ||
use tower::{Service, ServiceExt}; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
tracing_subscriber::fmt::fmt() | ||
.with_writer(std::io::stderr) | ||
.with_env_filter(tracing_subscriber::EnvFilter::new( | ||
std::env::var("RUST_LOG").unwrap_or_else(|_| "error,binance_options=debug".into()), | ||
)) | ||
.init(); | ||
let channel = std::env::var("CHANNEL").unwrap_or("index".to_string()); | ||
let inst = std::env::var("INST")?; | ||
let mut api = Binance::european_options() | ||
.ws_keep_alive_timeout(Duration::from_secs(30)) | ||
.connect(); | ||
api.ready().await?; | ||
let mut stream = api | ||
.call(Request::Ws(WsRequest::subscribe_stream( | ||
Name::new(&channel).with_inst(&inst), | ||
))) | ||
.await? | ||
.into_stream::<serde_json::Value>() | ||
.unwrap() | ||
.boxed(); | ||
while let Some(data) = stream.next().await { | ||
match data { | ||
Ok(data) => { | ||
tracing::info!("data={data:#?}"); | ||
} | ||
Err(err) => { | ||
tracing::error!("error={err}"); | ||
break; | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.