JiahengHe 2 vuotta sitten
vanhempi
commit
1b5c2463e4
1 muutettua tiedostoa jossa 41 lisäystä ja 3 poistoa
  1. 41 3
      strategy/src/model.rs

+ 41 - 3
strategy/src/model.rs

@@ -1,7 +1,7 @@
-use std::collections::{BTreeMap};
+use std::collections::{BTreeMap, HashMap};
 use rust_decimal::Decimal;
 use rust_decimal_macros::dec;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
 pub struct Position{
     // 做多仓位
     pub long_pos: Decimal,
@@ -30,7 +30,7 @@ pub struct TraderMsg{
     pub cash: Decimal,
     pub coin: Decimal,
     pub orders: BTreeMap<String, BTreeMap<String, String>>,
-    pub ref_price: Decimal,
+    pub ref_price: Vec<Vec<Decimal>>,
     pub market: Vec<Decimal>,
     pub predict: Decimal
 }
@@ -52,4 +52,42 @@ impl TraderMsg {
             predict: Default::default(),
         }
     }
+}
+
+#[derive(Clone)]
+pub struct OrderInfo{
+
+    pub symbol: String,
+
+    pub amount: Decimal,
+    // 方向 kd kk
+    pub side: String,
+    // 价格
+    pub price: Decimal,
+    // 自定义订单号
+    pub client_id: String,
+    // 实际价格
+    pub filled_price: Decimal,
+    //
+    pub filled: i8,
+    // 订单号
+    pub order_id: String,
+    // 时间
+    pub local_time: i64,
+    // 时间
+    pub create_time: i64
+}
+
+#[derive(Debug)]
+pub struct OrderCommand{
+    // 取消订单指令,数据结构例子:
+    // {
+    //  order_name: [c_id, o_id]
+    // }
+    pub cancel: HashMap<String, Vec<String>>,
+    // 限价单指令,数据结构例子:
+    // {
+    //  order_name: [数量,方向,价格,c_id]
+    // }
+    pub limits: HashMap<String, Vec<String>>,
 }