|
@@ -166,11 +166,12 @@ pub fn generate_msv_by_trades(mut trades: Vec<Trade>, mills_back: Decimal, simpl
|
|
|
let mut future_rate = Decimal::ONE_HUNDRED * (future_ref_price - last_price) / last_price;
|
|
let mut future_rate = Decimal::ONE_HUNDRED * (future_ref_price - last_price) / last_price;
|
|
|
future_rate.rescale(2);
|
|
future_rate.rescale(2);
|
|
|
// 根据具体向上波动还是向下波动来计算预期最大利润
|
|
// 根据具体向上波动还是向下波动来计算预期最大利润
|
|
|
- let epr = if rate > Decimal::ZERO {
|
|
|
|
|
|
|
+ let mut epr = if rate > Decimal::ZERO {
|
|
|
-future_rate
|
|
-future_rate
|
|
|
} else {
|
|
} else {
|
|
|
future_rate
|
|
future_rate
|
|
|
};
|
|
};
|
|
|
|
|
+ epr = min(epr, rate.abs());
|
|
|
|
|
|
|
|
// 去重,以及保留最大的波动率
|
|
// 去重,以及保留最大的波动率
|
|
|
if msv_data.len() > 0 {
|
|
if msv_data.len() > 0 {
|