Browse Source

修改okx订阅订单接口
整理警告

gepangpang 2 years ago
parent
commit
b5dd1540cc
1 changed files with 22 additions and 25 deletions
  1. 22 25
      src/exchange_middle_ware.rs

+ 22 - 25
src/exchange_middle_ware.rs

@@ -1,6 +1,5 @@
 use std::env;
-use std::io::{BufRead, Error, ErrorKind};
-use std::future::Future;
+use std::io::{Error, ErrorKind};
 use std::sync::Arc;
 use serde_json::json;
 use tokio::sync::Mutex;
@@ -72,22 +71,23 @@ pub struct Order {
     pub order_type: String,
 }
 
-#[derive(Debug)]
-pub struct Market {
-    symbol: String,
-    base_asset: String,
-    quote_asset: String,
-    tick_size: f64,
-    amount_size: f64,
-    price_precision: f64,
-    amount_precision: f64,
-    min_qty: f64,
-    max_qty: f64,
-    min_notional: f64,
-    max_notional: f64,
-    ct_val: f64,
-}
-
+// #[derive(Debug)]
+// pub struct Market {
+//     symbol: String,
+//     base_asset: String,
+//     quote_asset: String,
+//     tick_size: f64,
+//     amount_size: f64,
+//     price_precision: f64,
+//     amount_precision: f64,
+//     min_qty: f64,
+//     max_qty: f64,
+//     min_notional: f64,
+//     max_notional: f64,
+//     ct_val: f64,
+// }
+
+#[allow(dead_code)]
 pub struct Exchange {
     // okx okx_access_key
     okx_access_key: String,
@@ -123,7 +123,7 @@ impl Exchange {
     // 获取币安深度信息
     // symbol: 交易币对, "BTC_USDT"
     // limit: 返回条数, 最大 5000. 可选值:[5, 10, 20, 50, 100, 500, 1000, 5000]
-    pub async fn subscribe_binance_depth(&self, symbol: &String, limit: i32, mut bot_arc: Arc<Mutex<Bot>>) {
+    pub async fn subscribe_binance_depth(&self, symbol: &String, limit: i32, bot_arc: Arc<Mutex<Bot>>) {
         let real_symbol = self.get_real_symbol(symbol, "".to_string());
 
         let get_res_data = move |res_data: ResponseData| {
@@ -245,7 +245,7 @@ impl Exchange {
 
     // OKX订阅订单
     // symbol: 交易币对, "BTC_USDT"
-    pub async fn subscribe_okx_order(&self, symbol: &String, mut bot_arc: Arc<Mutex<Bot>>) {
+    pub async fn subscribe_okx_order(&self, okx_access_key:String, okx_secret_key:String, okx_passphrase:String, symbol: &String, bot_arc: Arc<Mutex<Bot>>) {
         let real_symbol = self.get_real_symbol(symbol, "-".to_string());
 
         let get_res_data = move |res_data: ResponseData| {
@@ -266,9 +266,6 @@ impl Exchange {
             }
         };
 
-        let okx_access_key = env::var("okx_access_key").unwrap();
-        let okx_secret_key = env::var("okx_secret_key").unwrap();
-        let okx_passphrase = env::var("okx_passphrase").unwrap();
         SocketTool::okx_pr_run_orders(vec![&real_symbol], okx_access_key, okx_secret_key, okx_passphrase, get_res_data);
     }
 
@@ -292,7 +289,7 @@ impl Exchange {
     // OKX撤销订单
     // symbol: 交易币对, "BTC_USDT"
     // order_id: 订单ID, "590910403358593111"
-    pub async fn get_okx_instruments(&self, symbol: &String) {
+    // pub async fn get_okx_instruments(&self, symbol: &String) {
         // let real_symbol = self.get_real_symbol(symbol, "-".to_string());
         // let mut btree_map: BTreeMap<&str, &str> = BTreeMap::new();
         // btree_map.insert("instType", "SPOT");
@@ -338,7 +335,7 @@ impl Exchange {
         // } else {
         //     Err(Error::new(ErrorKind::Other, res_data.message))
         // }
-    }
+    // }
 }
 
 fn parse_order_info(res_data_json: serde_json::Value) -> Order {