-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
138 additions
and
110 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,39 @@ | ||
use std::time::Duration; | ||
|
||
use tokio::time::sleep; | ||
use tracing_subscriber::fmt::init; | ||
|
||
use bothan_core::worker::AssetWorker; | ||
use bothan_okx::OkxWorkerBuilder; | ||
use bothan_core::registry::Registry; | ||
use bothan_core::store::SharedStore; | ||
use bothan_core::worker::{AssetWorker, AssetWorkerBuilder}; | ||
use bothan_okx::{OkxWorkerBuilder, OkxWorkerBuilderOpts}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
init(); | ||
let worker = OkxWorkerBuilder::default().build().await.unwrap(); | ||
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; | ||
let path = std::env::current_dir().unwrap(); | ||
let registry = Registry::default().validate().unwrap(); | ||
let store = SharedStore::new(registry, path.as_path()).await.unwrap(); | ||
|
||
let worker_store = store.create_worker_store(OkxWorkerBuilder::worker_name()); | ||
let opts = OkxWorkerBuilderOpts::default(); | ||
|
||
let worker = OkxWorkerBuilder::new(worker_store, opts) | ||
.build() | ||
.await | ||
.unwrap(); | ||
|
||
worker | ||
.add_query_ids(vec!["BTC-USDT".to_string(), "ETH-USDT".to_string()]) | ||
.set_query_ids(vec!["BTC-USDT".to_string(), "ETH-USDT".to_string()]) | ||
.await | ||
.unwrap(); | ||
|
||
sleep(Duration::from_secs(2)).await; | ||
|
||
loop { | ||
let data = worker.get_assets(&["BTC-USDT", "ETH-USDT"]).await; | ||
println!("{:?}", data); | ||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; | ||
let btc_data = worker.get_asset("BTC-USDT").await; | ||
let eth_data = worker.get_asset("ETH-USDT").await; | ||
println!("{:?}, {:?}", btc_data, eth_data); | ||
sleep(Duration::from_secs(5)).await; | ||
} | ||
} |
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.