|
@@ -92,33 +92,12 @@ pub fn truncate_decimal_places(num: f64, decimal_places: usize) -> f64 {
|
|
|
// 单元测试集
|
|
// 单元测试集
|
|
|
#[cfg(test)]
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
mod tests {
|
|
|
|
|
+ use crate::exchange_middle_ware::get_binance_depth;
|
|
|
use super::*;
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
|
- fn test_direction() {
|
|
|
|
|
- // 创建一个空的 Record 列表
|
|
|
|
|
- let mut records = Vec::new();
|
|
|
|
|
-
|
|
|
|
|
- // 向列表中添加一条记录
|
|
|
|
|
- records.push(Record {
|
|
|
|
|
- time: 1,
|
|
|
|
|
- open: 100.0,
|
|
|
|
|
- high: 200.0,
|
|
|
|
|
- low: 50.0,
|
|
|
|
|
- close: 150.0,
|
|
|
|
|
- volume: 5000.0,
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // 向列表中添加另一条记录
|
|
|
|
|
- records.push(Record {
|
|
|
|
|
- time: 2,
|
|
|
|
|
- open: 150.0,
|
|
|
|
|
- high: 250.0,
|
|
|
|
|
- low: 100.0,
|
|
|
|
|
- close: 200.0,
|
|
|
|
|
- volume: 7000.0,
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- println!("{}", get_direction(&records));
|
|
|
|
|
|
|
+ fn test_get_spread() {
|
|
|
|
|
+ let depth = get_binance_depth("BTC_USDT", "100");
|
|
|
|
|
+ println!("{:?}", get_spread(&depth))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|