|
@@ -113,7 +113,17 @@ pub fn generate_msv_by_trades(mut trades: Vec<Trade>, mills_back: Decimal, simpl
|
|
|
let mut fair_price_simulation_ema = Decimal::ZERO;
|
|
let mut fair_price_simulation_ema = Decimal::ZERO;
|
|
|
|
|
|
|
|
const GAMMA: Decimal = dec!(0.5);
|
|
const GAMMA: Decimal = dec!(0.5);
|
|
|
- let gamma_fair: Decimal = Decimal::ONE / Decimal::from_i64(trades.len().to_i64().unwrap() / (end_time - start_time)).unwrap();
|
|
|
|
|
|
|
+ // 多少分钟
|
|
|
|
|
+ let a = (end_time - start_time) / 1000;
|
|
|
|
|
+ // 多少笔
|
|
|
|
|
+ let b = trades.len().to_i64().unwrap();
|
|
|
|
|
+ // 一分钟多少笔
|
|
|
|
|
+ let c = if a == 0 {
|
|
|
|
|
+ b
|
|
|
|
|
+ } else {
|
|
|
|
|
+ b / a
|
|
|
|
|
+ };
|
|
|
|
|
+ let gamma_fair: Decimal = Decimal::ONE / Decimal::from_i64(c).unwrap();
|
|
|
|
|
|
|
|
// ================== 计算每个点的具体波动率以及回溯幅度 ===================
|
|
// ================== 计算每个点的具体波动率以及回溯幅度 ===================
|
|
|
trades.sort_by(|a, b| Decimal::from_str(a.id.as_str()).unwrap().cmp(&Decimal::from_str(b.id.as_str()).unwrap()));
|
|
trades.sort_by(|a, b| Decimal::from_str(a.id.as_str()).unwrap().cmp(&Decimal::from_str(b.id.as_str()).unwrap()));
|