Make parallel operation of setting future

This commit is contained in:
Sik Yoon 2024-05-20 23:19:15 +09:00
parent b9621ccc72
commit 229a4c38ae

View File

@ -77,12 +77,18 @@ async fn future_setup() {
.build() .build()
.unwrap(); .unwrap();
let mut task_vec = Vec::new();
let mut future_exchange_info_map: HashMap<String, FuturesExchangeInfo> = HashMap::new(); let mut future_exchange_info_map: HashMap<String, FuturesExchangeInfo> = HashMap::new();
request_future_exchange_infomation(&client, &mut future_exchange_info_map).await; request_future_exchange_infomation(&client, &mut future_exchange_info_map).await;
for (symbol, futures_exchange_info) in future_exchange_info_map { for (symbol, futures_exchange_info) in future_exchange_info_map {
set_margin_type(&symbol, MarginType::Isolated, &client).await; // Default: Isolated let symbol_c = symbol.clone();
set_initial_leverage(&symbol, 1, &client).await; // Default: x1 let client_c = client.clone();
task_vec.push(tokio::spawn(async move {
set_margin_type(&symbol_c, MarginType::Isolated, &client_c).await; // Default: Isolated
set_initial_leverage(&symbol_c, 1, &client_c).await; // Default: x1
}));
} }
try_join_all(task_vec).await;
set_position_mode(&client).await; // Default: One-way Mode set_position_mode(&client).await; // Default: One-way Mode
set_asset_mode(&client).await; // Default: Single-Asset Mode set_asset_mode(&client).await; // Default: Single-Asset Mode