skyfffire 2 жил өмнө
parent
commit
7bfc11d2f1
4 өөрчлөгдсөн 75 нэмэгдсэн , 4 устгасан
  1. 69 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 2 0
      README.md
  4. 3 4
      src/as_libs.rs

+ 69 - 0
Cargo.lock

@@ -74,6 +74,7 @@ dependencies = [
  "serde_derive",
  "serde_derive",
  "serde_json",
  "serde_json",
  "time 0.2.27",
  "time 0.2.27",
+ "tokio",
 ]
 ]
 
 
 [[package]]
 [[package]]
@@ -704,6 +705,16 @@ version = "0.4.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
 checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
 
 
+[[package]]
+name = "lock_api"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
 [[package]]
 [[package]]
 name = "log"
 name = "log"
 version = "0.4.20"
 version = "0.4.20"
@@ -880,6 +891,29 @@ dependencies = [
  "vcpkg",
  "vcpkg",
 ]
 ]
 
 
+[[package]]
+name = "parking_lot"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-targets",
+]
+
 [[package]]
 [[package]]
 name = "percent-encoding"
 name = "percent-encoding"
 version = "2.3.0"
 version = "2.3.0"
@@ -1158,6 +1192,12 @@ dependencies = [
  "windows-sys",
  "windows-sys",
 ]
 ]
 
 
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
 [[package]]
 [[package]]
 name = "seahash"
 name = "seahash"
 version = "4.1.0"
 version = "4.1.0"
@@ -1282,6 +1322,15 @@ dependencies = [
  "digest",
  "digest",
 ]
 ]
 
 
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
+dependencies = [
+ "libc",
+]
+
 [[package]]
 [[package]]
 name = "simdutf8"
 name = "simdutf8"
 version = "0.1.4"
 version = "0.1.4"
@@ -1297,6 +1346,12 @@ dependencies = [
  "autocfg",
  "autocfg",
 ]
 ]
 
 
+[[package]]
+name = "smallvec"
+version = "1.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
+
 [[package]]
 [[package]]
 name = "socket2"
 name = "socket2"
 version = "0.4.9"
 version = "0.4.9"
@@ -1517,11 +1572,25 @@ dependencies = [
  "libc",
  "libc",
  "mio",
  "mio",
  "num_cpus",
  "num_cpus",
+ "parking_lot",
  "pin-project-lite",
  "pin-project-lite",
+ "signal-hook-registry",
  "socket2 0.5.3",
  "socket2 0.5.3",
+ "tokio-macros",
  "windows-sys",
  "windows-sys",
 ]
 ]
 
 
+[[package]]
+name = "tokio-macros"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.28",
+]
+
 [[package]]
 [[package]]
 name = "tokio-native-tls"
 name = "tokio-native-tls"
 version = "0.3.1"
 version = "0.3.1"

+ 1 - 0
Cargo.toml

@@ -16,3 +16,4 @@ serde_json = "1.0.104"
 ndarray = "0.15"
 ndarray = "0.15"
 time = "0.2"
 time = "0.2"
 binance = { git = "https://github.com/wisespace-io/binance-rs.git" }
 binance = { git = "https://github.com/wisespace-io/binance-rs.git" }
+tokio = {version = "1.31.0", features = ["full"]}

+ 2 - 0
README.md

@@ -13,3 +13,5 @@
     我们的目的是维持0库存(库存目标通过公式优化)
     我们的目的是维持0库存(库存目标通过公式优化)
 ### 2. 运行方式
 ### 2. 运行方式
     clone到本地/服务器之后,直接编译即可运行(需要配置)。
     clone到本地/服务器之后,直接编译即可运行(需要配置)。
+### 3. 遇到的问题
+    各种类型不熟悉问题吧,总算是都克服了。

+ 3 - 4
src/as_libs.rs

@@ -1,4 +1,3 @@
-use std::num::FpCategory::Nan;
 use crate::exchange_middle_ware::{Depth, Record};
 use crate::exchange_middle_ware::{Depth, Record};
 
 
 // 获取买一卖一价差(spread)、中间价
 // 获取买一卖一价差(spread)、中间价
@@ -97,9 +96,9 @@ mod tests {
     use crate::exchange_middle_ware::{get_binance_depth, get_binance_klines};
     use crate::exchange_middle_ware::{get_binance_depth, get_binance_klines};
     use super::*;
     use super::*;
 
 
-    #[test]
-    fn test_get_spread() {
-        let depth = get_binance_depth("BTC_USDT", "100");
+    #[tokio::test]
+    async fn test_get_spread() {
+        let depth = get_binance_depth(&"BTC_USDT".to_string(), 100i32).await;
         let ask = depth.asks[0].price;
         let ask = depth.asks[0].price;
         let bid = depth.bids[0].price;
         let bid = depth.bids[0].price;