|
@@ -144,19 +144,20 @@ impl DataManager {
|
|
|
|
|
|
|
|
// 打印 asks_map
|
|
// 打印 asks_map
|
|
|
if let Some(asks) = self.asks_map.get(key) {
|
|
if let Some(asks) = self.asks_map.get(key) {
|
|
|
- println!("Asks for {}:", key);
|
|
|
|
|
- for (idx, (price, quantity)) in asks.iter().enumerate() {
|
|
|
|
|
- println!(" Entry {}: Price={}, Quantity={}", idx + 1, price, quantity);
|
|
|
|
|
|
|
+ for (idx, (price, quantity)) in asks.iter().take(10).enumerate().rev() {
|
|
|
|
|
+ // 使用.take(10)来限制最多只迭代10次
|
|
|
|
|
+ // idx 将会从 0 到 9
|
|
|
|
|
+ println!(" Sell {}: Price={}, Quantity={}", idx + 1, price, quantity);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
println!("No asks data found for {}", key);
|
|
println!("No asks data found for {}", key);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 打印 bids_map
|
|
// 打印 bids_map
|
|
|
|
|
+ println!("------------------");
|
|
|
if let Some(bids) = self.bids_map.get(key) {
|
|
if let Some(bids) = self.bids_map.get(key) {
|
|
|
- println!("Bids for {}:", key);
|
|
|
|
|
- for (idx, (r_price, quantity)) in bids.iter().enumerate() {
|
|
|
|
|
- println!(" Entry {}: Price={}, Quantity={}", idx + 1, r_price.0, quantity);
|
|
|
|
|
|
|
+ for (idx, (r_price, quantity)) in bids.iter().take(10).enumerate() {
|
|
|
|
|
+ println!(" Buy {}: Price={}, Quantity={}", idx + 1, r_price.0, quantity);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
println!("No bids data found for {}", key);
|
|
println!("No bids data found for {}", key);
|