|
|
@@ -11,6 +11,15 @@ use global::fixed_time_range_deque::FixedTimeRangeDeque;
|
|
|
use global::predictor_state::PredictorState;
|
|
|
use standard::{Depth, Ticker, Trade};
|
|
|
|
|
|
+/**
|
|
|
+1. 微价格(加权中间价)作为基价
|
|
|
+ S = (ap*bv+bp*av)/(av+bv)
|
|
|
+2. ROC 值 下单风控
|
|
|
+3. VWPIN 值 下单风控
|
|
|
+
|
|
|
+**/
|
|
|
+
|
|
|
+
|
|
|
#[derive(Debug)]
|
|
|
pub struct AvellanedaStoikov {
|
|
|
pub depth_vec: FixedTimeRangeDeque<Depth>, // 深度队列
|
|
|
@@ -151,8 +160,10 @@ impl AvellanedaStoikov {
|
|
|
self.depth_vec.push_back(depth.clone());
|
|
|
|
|
|
self.ask_price = depth.asks[0].price;
|
|
|
+ let ask_size = depth.asks[0].size;
|
|
|
self.bid_price = depth.bids[0].price;
|
|
|
- self.mid_price = (self.ask_price + self.bid_price) / Decimal::TWO;
|
|
|
+ let bid_size = depth.bids[0].size;
|
|
|
+ self.mid_price = (self.ask_price * bid_size + self.bid_price * ask_size) / (ask_size + bid_size);
|
|
|
|
|
|
self.processor().await;
|
|
|
}
|