gepangpang 2 lat temu
rodzic
commit
fc165cf879

+ 9 - 30
standard/src/binance_spot.rs

@@ -4,12 +4,11 @@ use std::result::Result;
 use tokio::sync::mpsc::Sender;
 use async_trait::async_trait;
 use rust_decimal::Decimal;
-use crate::{Platform, ExchangeEnum, Account, binance_handle, Position, Ticker, Market, Order, OrderCommand};
+use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand};
 use exchanges::binance_spot_rest::BinanceSpotRest;
-use exchanges::response_base::ResponseData;
 
 #[allow(dead_code)]
-#[derive( Clone)]
+#[derive(Clone)]
 pub struct BinanceSpot {
     exchange: ExchangeEnum,
     symbol: String,
@@ -52,15 +51,7 @@ impl Platform for BinanceSpot {
     }
 
     // 获取账号信息
-    async fn get_account(&self) -> Result<Account, Error> {
-        let res_data = ResponseData {
-            code: "200".to_string(),
-            message: "你猜猜这是什么错误".to_string(),
-            data: "[]".to_string(),
-            channel: "".to_string(),
-        };
-        binance_handle::handle_account_info(res_data, self.symbol.clone())
-    }
+    async fn get_account(&self) -> Result<Account, Error> { todo!() }
     // 获取仓位信息
     async fn get_position(&self) -> Result<Vec<Position>, Error> {
         todo!()
@@ -79,39 +70,27 @@ impl Platform for BinanceSpot {
         todo!()
     }
 
-    async fn get_order_detail(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn get_order_detail(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
 
     async fn get_orders_list(&self, _status: &str) -> Result<Vec<Order>, Error> {
         todo!()
     }
 
-    async fn set_dual_mode(&self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> {
-        todo!()
-    }
+    async fn set_dual_mode(&self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> { todo!() }
 
     async fn set_dual_leverage(&self, _leverage: &str) -> Result<String, Error> {
         todo!()
     }
 
-    async fn wallet_transfers(&self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> {
-        todo!()
-    }
+    async fn wallet_transfers(&self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> { todo!() }
 
-    async fn take_order(&self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn take_order(&self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> { todo!() }
 
-    async fn cancel_order(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn cancel_order(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
 
     async fn cancel_orders(&self) -> Result<Vec<Order>, Error> {
         todo!()
     }
 
-    async fn command_order(&self, _order_command: OrderCommand, _order_sender: Sender<Order>, _error_sender: Sender<Error>) {
-        todo!()
-    }
+    async fn command_order(&self, _order_command: OrderCommand, _order_sender: Sender<Order>, _error_sender: Sender<Error>) { todo!() }
 }

+ 6 - 18
standard/src/binance_swap.rs

@@ -95,41 +95,29 @@ impl Platform for BinanceSwap {
         todo!()
     }
 
-    async fn get_order_detail(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn get_order_detail(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
 
     async fn get_orders_list(&self, _status: &str) -> Result<Vec<Order>, Error> {
         todo!()
     }
 
-    async fn set_dual_mode(&self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> {
-        todo!()
-    }
+    async fn set_dual_mode(&self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> { todo!() }
 
     async fn set_dual_leverage(&self, _leverage: &str) -> Result<String, Error> {
         todo!()
     }
 
-    async fn wallet_transfers(&self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> {
-        todo!()
-    }
+    async fn wallet_transfers(&self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> { todo!() }
 
-    async fn take_order(&self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn take_order(&self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> { todo!() }
 
-    async fn cancel_order(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn cancel_order(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
 
     async fn cancel_orders(&self) -> Result<Vec<Order>, Error> {
         todo!()
     }
 
-    async fn command_order(&self, _order_command: OrderCommand, _order_sender: Sender<Order>, _error_sender: Sender<Error>) {
-        todo!()
-    }
+    async fn command_order(&self, _order_command: OrderCommand, _order_sender: Sender<Order>, _error_sender: Sender<Error>) { todo!() }
 
     // 订阅深度信息
     // fn subscribe_depth(&self, symbol: &str) {

+ 1 - 1
standard/src/exchange.rs

@@ -4,7 +4,7 @@ use crate::binance_spot::BinanceSpot;
 use crate::gate_spot::GateSpot;
 use crate::gate_swap::GateSwap;
 use crate::kucoin_swap::KucoinSwap;
-use crate::{Platform};
+use crate::Platform;
 
 /// 交易所交易模式枚举
 /// - `BinanceSwap`: Binance交易所期货;

+ 6 - 18
standard/src/gate_spot.rs

@@ -71,39 +71,27 @@ impl Platform for GateSpot {
         todo!()
     }
 
-    async fn get_order_detail(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn get_order_detail(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
 
     async fn get_orders_list(&self, _status: &str) -> Result<Vec<Order>, Error> {
         todo!()
     }
 
-    async fn set_dual_mode(&self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> {
-        todo!()
-    }
+    async fn set_dual_mode(&self, _coin: &str, _is_dual_mode: bool) -> Result<String, Error> { todo!() }
 
     async fn set_dual_leverage(&self, _leverage: &str) -> Result<String, Error> {
         todo!()
     }
 
-    async fn wallet_transfers(&self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> {
-        todo!()
-    }
+    async fn wallet_transfers(&self, _coin: &str, _from: &str, _to: &str, _amount: Decimal) -> Result<String, Error> { todo!() }
 
-    async fn take_order(&self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn take_order(&self, _custom_id: &str, _origin_side: &str, _price: Decimal, _amount: Decimal) -> Result<Order, Error> { todo!() }
 
-    async fn cancel_order(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> {
-        todo!()
-    }
+    async fn cancel_order(&self, _order_id: &str, _custom_id: &str) -> Result<Order, Error> { todo!() }
 
     async fn cancel_orders(&self) -> Result<Vec<Order>, Error> {
         todo!()
     }
 
-    async fn command_order(&self, _order_command: OrderCommand, _order_sender: Sender<Order>, _error_sender: Sender<Error>) {
-        todo!()
-    }
+    async fn command_order(&self, _order_command: OrderCommand, _order_sender: Sender<Order>, _error_sender: Sender<Error>) { todo!() }
 }

+ 1 - 0
standard/src/gate_swap.rs

@@ -67,6 +67,7 @@ impl Platform for GateSwap {
         let res_data = self.request.get_account(symbol_array[1].to_string().to_lowercase()).await;
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
+            println!("{}", res_data_str);
             let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
             let balance = res_data_json["total"].as_str().unwrap().parse().unwrap_or(dec!(0.0));
             let available_balance = res_data_json["available"].as_str().unwrap().parse().unwrap_or(dec!(0.0));

+ 1 - 0
standard/src/kucoin_swap.rs

@@ -105,6 +105,7 @@ impl Platform for KucoinSwap {
         if res_data.code == "200" {
             let res_data_str = &res_data.data;
             let res_data_json: Vec<serde_json::Value> = serde_json::from_str(res_data_str).unwrap();
+            println!("{:?}", res_data_json);
             let result = res_data_json.iter().map(|item| { parse_position_item(item) }).collect();
             Ok(result)
         } else {

+ 5 - 12
standard/src/lib.rs

@@ -38,21 +38,14 @@ pub enum OrderCommandEnum {
 }
 
 /// OrderCommand结构体(下单指令)
-/// - `cancel(Vec<String>)`: 取消订单指令;
-/// - `limits(HashMap<String, Vec<String>>)`: 限价单指令;
-/// - `check(HashMap<String, Vec<String>>)`: balance挂单的冻结数量
-/// - `limits_open(HashMap<String, Vec<String>>)`: 总计交易币数量
-/// - `limits_close(HashMap<String, Vec<String>>)`: 可用交易币数量
+/// - `cancel(HashMap<String, Vec<String>)`: 取消订单指令 `{"order_name": [c_id, o_id]}`;
+/// - `check(HashMap<String, Vec<String>>)`: balance挂单的冻结数量 `{"order_name": [数量,方向,价格,c_id]}`;
+/// - `limits_open(HashMap<String, Vec<String>>)`: 总计交易币数量 `{"order_name": [c_id, o_id]}`;
+/// - `limits_close(HashMap<String, Vec<String>>)`: 可用交易币数量 `{"order_name": [c_id, o_id]}`;
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub struct OrderCommand {
     // 取消订单指令,数据结构例子:
-    //  [c_id, o_id]
     pub cancel: HashMap<String, Vec<String>>,
-    // 限价单指令,数据结构例子:
-    // {
-    //  order_name: [数量,方向,价格,c_id]
-    // }
-    // pub limits: HashMap<String, Vec<String>>,
     // 检验指令,数据结构例子:(暂没找到例子)
     pub check: HashMap<String, Vec<String>>,
     // 限开指令,数据结构例子:(暂没找到例子)
@@ -360,4 +353,4 @@ pub trait Platform {
     async fn cancel_orders(&self) -> Result<Vec<Order>, Error>;
     // 指令下单
     async fn command_order(&self, order_command: OrderCommand, order_sender: Sender<Order>, error_sender: Sender<Error>);
-}
+}