Skip to content

Commit

Permalink
chore(rust): update Rust edition to 2024.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaz001 committed Feb 25, 2025
1 parent 9b21279 commit c76d8e7
Show file tree
Hide file tree
Showing 61 changed files with 291 additions and 289 deletions.
2 changes: 1 addition & 1 deletion collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "collect-data"
version = "0.1.0"
edition = "2021"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
4 changes: 2 additions & 2 deletions collector/src/binance/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::{
use anyhow::Error;
use chrono::{DateTime, Utc};
use futures_util::{SinkExt, StreamExt};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message, Utf8Bytes},
tungstenite::{Bytes, Message, Utf8Bytes, client::IntoClientRequest},
};
use tracing::{error, warn};

Expand Down
2 changes: 1 addition & 1 deletion collector/src/binance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

use chrono::{DateTime, Utc};
pub use http::{fetch_depth_snapshot, keep_connection};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::tungstenite::Utf8Bytes;
use tracing::{error, warn};

Expand Down
4 changes: 2 additions & 2 deletions collector/src/binancefuturescm/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::{
use anyhow::Error;
use chrono::{DateTime, Utc};
use futures_util::{SinkExt, StreamExt};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message, Utf8Bytes},
tungstenite::{Bytes, Message, Utf8Bytes, client::IntoClientRequest},
};
use tracing::{error, warn};

Expand Down
2 changes: 1 addition & 1 deletion collector/src/binancefuturescm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

use chrono::{DateTime, Utc};
pub use http::{fetch_depth_snapshot, keep_connection};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::tungstenite::Utf8Bytes;
use tracing::{error, warn};

Expand Down
4 changes: 2 additions & 2 deletions collector/src/binancefuturesum/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::{
use anyhow::Error;
use chrono::{DateTime, Utc};
use futures_util::{SinkExt, StreamExt};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message, Utf8Bytes},
tungstenite::{Bytes, Message, Utf8Bytes, client::IntoClientRequest},
};
use tracing::{error, warn};

Expand Down
2 changes: 1 addition & 1 deletion collector/src/binancefuturesum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

use chrono::{DateTime, Utc};
pub use http::{fetch_depth_snapshot, keep_connection};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::tungstenite::Utf8Bytes;
use tracing::{error, warn};

Expand Down
4 changes: 2 additions & 2 deletions collector/src/bybit/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use chrono::{DateTime, Utc};
use futures_util::{SinkExt, StreamExt};
use tokio::{
select,
sync::mpsc::{unbounded_channel, UnboundedSender},
sync::mpsc::{UnboundedSender, unbounded_channel},
};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message, Utf8Bytes},
tungstenite::{Bytes, Message, Utf8Bytes, client::IntoClientRequest},
};
use tracing::{error, warn};

Expand Down
2 changes: 1 addition & 1 deletion collector/src/bybit/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chrono::{DateTime, Utc};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
use tokio::sync::mpsc::{UnboundedSender, unbounded_channel};
use tokio_tungstenite::tungstenite::Utf8Bytes;
use tracing::error;

Expand Down
4 changes: 2 additions & 2 deletions collector/src/file.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{
collections::{hash_map::Entry, HashMap},
collections::{HashMap, hash_map::Entry},
fs::File,
io,
io::Write,
};

use chrono::{DateTime, NaiveDate, Utc};
use flate2::{write::GzEncoder, Compression};
use flate2::{Compression, write::GzEncoder};
use tracing::info;

pub struct RotatingFile {
Expand Down
2 changes: 1 addition & 1 deletion connector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "connector"
version = "0.1.0"
edition = "2021"
edition = "2024"

[features]
default = ["binancefutures", "bybit"]
Expand Down
8 changes: 4 additions & 4 deletions connector/src/binancefutures/market_data_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ use hftbacktest::{live::ipc::TO_ALL, prelude::*};
use tokio::{
select,
sync::{
broadcast::{error::RecvError, Receiver},
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
broadcast::{Receiver, error::RecvError},
mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel},
},
};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Message},
tungstenite::{Message, client::IntoClientRequest},
};
use tracing::{debug, error};

use crate::{
binancefutures::{
BinanceFuturesError,
msg::{
rest,
stream,
stream::{EventStream, Stream},
},
rest::BinanceFuturesClient,
BinanceFuturesError,
},
connector::PublishEvent,
utils::{generate_rand_string, parse_depth, parse_px_qty_tup},
Expand Down
2 changes: 1 addition & 1 deletion connector/src/binancefutures/msg/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use hftbacktest::types::{OrdType, Side, Status, TimeInForce};
use serde::{
de::{Error, Unexpected},
Deserialize,
Deserializer,
de::{Error, Unexpected},
};

#[allow(dead_code)]
Expand Down
8 changes: 5 additions & 3 deletions connector/src/binancefutures/ordermanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use tracing::error;

use crate::{
binancefutures::{
msg::{rest::OrderResponse, stream::OrderTradeUpdate},
BinanceFuturesError,
msg::{rest::OrderResponse, stream::OrderTradeUpdate},
},
connector::GetOrders,
utils::{generate_rand_string, RefSymbolOrderId, SymbolOrderId},
utils::{RefSymbolOrderId, SymbolOrderId, generate_rand_string},
};

#[derive(Debug)]
Expand Down Expand Up @@ -117,7 +117,9 @@ impl OrderManager {
}
BinanceFuturesError::OrderError { code: -1008, .. } => {
// Server is currently overloaded with other requests. Please try again in a few minutes.
error!("Server is currently overloaded with other requests. Please try again in a few minutes.");
error!(
"Server is currently overloaded with other requests. Please try again in a few minutes."
);
}
BinanceFuturesError::OrderError { code: -2019, .. } => {
// Margin is insufficient.
Expand Down
2 changes: 1 addition & 1 deletion connector/src/binancefutures/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use serde::Deserialize;
use super::msg::{rest, rest::PositionInformationV2};
use crate::{
binancefutures::{
BinanceFuturesError,
msg::{
rest::{OrderResponse, OrderResponseResult},
stream::ListenKey,
},
BinanceFuturesError,
},
utils::sign_hmac_sha256,
};
Expand Down
8 changes: 4 additions & 4 deletions connector/src/binancefutures/user_data_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ use hftbacktest::prelude::*;
use tokio::{
select,
sync::{
broadcast::{error::RecvError, Receiver},
broadcast::{Receiver, error::RecvError},
mpsc::UnboundedSender,
},
time,
};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Message},
tungstenite::{Message, client::IntoClientRequest},
};
use tracing::{debug, error};

use crate::{
binancefutures::{
BinanceFuturesError,
SharedSymbolSet,
msg::stream::{EventStream, Stream},
ordermanager::SharedOrderManager,
rest::BinanceFuturesClient,
BinanceFuturesError,
SharedSymbolSet,
},
connector::PublishEvent,
};
Expand Down
4 changes: 2 additions & 2 deletions connector/src/bybit/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::{collections::HashMap, fmt, fmt::Debug};

use hftbacktest::types::{OrdType, Side, Status, TimeInForce};
use serde::{
de,
de::{Error, Unexpected, Visitor},
Deserialize,
Deserializer,
Serialize,
de,
de::{Error, Unexpected, Visitor},
};

use crate::utils::{from_str_to_f64, from_str_to_f64_opt, from_str_to_i64};
Expand Down
4 changes: 2 additions & 2 deletions connector/src/bybit/ordermanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use hftbacktest::{

use crate::{
bybit::{
msg::{Execution, FastExecution, Order as BybitOrder, PrivateOrder},
BybitError,
msg::{Execution, FastExecution, Order as BybitOrder, PrivateOrder},
},
connector::GetOrders,
utils::{generate_rand_string, RefSymbolOrderId, SymbolOrderId},
utils::{RefSymbolOrderId, SymbolOrderId, generate_rand_string},
};

pub type SharedOrderManager = Arc<Mutex<OrderManager>>;
Expand Down
12 changes: 6 additions & 6 deletions connector/src/bybit/private_stream.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
use std::time::Duration;

use chrono::Utc;
use futures_util::{stream::SplitSink, SinkExt, StreamExt};
use futures_util::{SinkExt, StreamExt, stream::SplitSink};
use hftbacktest::prelude::LiveEvent;
use tokio::{
net::TcpStream,
select,
sync::{
broadcast::{error::RecvError, Receiver},
broadcast::{Receiver, error::RecvError},
mpsc::UnboundedSender,
},
time,
};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message},
MaybeTlsStream,
WebSocketStream,
connect_async,
tungstenite::{Bytes, Message, client::IntoClientRequest},
};
use tracing::{debug, error};

use crate::{
bybit::{
BybitError,
SharedSymbolSet,
msg::{Op, PrivateStreamMsg, PrivateStreamTopicMsg},
ordermanager::{OrderExt, SharedOrderManager},
rest::BybitClient,
BybitError,
SharedSymbolSet,
},
connector::PublishEvent,
utils::sign_hmac_sha256,
Expand Down
10 changes: 5 additions & 5 deletions connector/src/bybit/public_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ use chrono::Utc;
use futures_util::{SinkExt, StreamExt};
use hftbacktest::prelude::{
Event,
LiveEvent,
Side,
LOCAL_ASK_DEPTH_BBO_EVENT,
LOCAL_ASK_DEPTH_EVENT,
LOCAL_BID_DEPTH_BBO_EVENT,
LOCAL_BID_DEPTH_EVENT,
LOCAL_BUY_TRADE_EVENT,
LOCAL_SELL_TRADE_EVENT,
LiveEvent,
Side,
};
use tokio::{
select,
sync::{
broadcast::{error::RecvError, Receiver},
broadcast::{Receiver, error::RecvError},
mpsc::UnboundedSender,
},
time,
};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message},
tungstenite::{Bytes, Message, client::IntoClientRequest},
};
use tracing::{debug, error};

use crate::{
bybit::{
BybitError,
msg,
msg::{Op, OrderBook, PublicStreamMsg},
BybitError,
},
connector::PublishEvent,
utils::parse_depth,
Expand Down
2 changes: 1 addition & 1 deletion connector/src/bybit/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use serde::Deserialize;

use crate::{
bybit::{
msg::{Position, RestResponse},
BybitError,
msg::{Position, RestResponse},
},
utils::sign_hmac_sha256,
};
Expand Down
6 changes: 3 additions & 3 deletions connector/src/bybit/trade_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ use hftbacktest::types::{ErrorKind, LiveError, LiveEvent};
use tokio::{
select,
sync::{
broadcast::{error::RecvError, Receiver},
broadcast::{Receiver, error::RecvError},
mpsc::UnboundedSender,
},
time,
};
use tokio_tungstenite::{
connect_async,
tungstenite::{client::IntoClientRequest, Bytes, Message},
tungstenite::{Bytes, Message, client::IntoClientRequest},
};
use tracing::{error, info};

use crate::{
bybit::{
BybitError,
msg::{Op, Order, TradeOp, TradeStreamMsg},
ordermanager::{OrderExt, SharedOrderManager},
BybitError,
},
connector::PublishEvent,
utils::{generate_rand_string, sign_hmac_sha256},
Expand Down
8 changes: 4 additions & 4 deletions connector/src/fuse.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use hftbacktest::{
prelude::{Side, DEPTH_SNAPSHOT_EVENT, EXCH_EVENT, INVALID_MAX, INVALID_MIN, LOCAL_EVENT},
types::{Event, BUY_EVENT, SELL_EVENT},
prelude::{DEPTH_SNAPSHOT_EVENT, EXCH_EVENT, INVALID_MAX, INVALID_MIN, LOCAL_EVENT, Side},
types::{BUY_EVENT, Event, SELL_EVENT},
};

pub struct QtyTimestamp {
Expand Down Expand Up @@ -186,7 +186,7 @@ impl FusedHashMapMarketDepth {
let mut bid_depth = self
.bid_depth
.iter()
.filter(|(&px_tick, _)| px_tick <= self.best_bid_tick)
.filter(|&(&px_tick, _)| px_tick <= self.best_bid_tick)
.map(|(&px_tick, depth)| (px_tick, depth))
.collect::<Vec<_>>();
bid_depth.sort_by(|a, b| b.0.cmp(&a.0));
Expand All @@ -207,7 +207,7 @@ impl FusedHashMapMarketDepth {
let mut ask_depth = self
.ask_depth
.iter()
.filter(|(&px_tick, _)| px_tick >= self.best_ask_tick)
.filter(|&(&px_tick, _)| px_tick >= self.best_ask_tick)
.map(|(&px_tick, depth)| (px_tick, depth))
.collect::<Vec<_>>();
ask_depth.sort_by(|a, b| a.0.cmp(&b.0));
Expand Down
Loading

0 comments on commit c76d8e7

Please sign in to comment.