|
|
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
|
|
|
use std::str::FromStr;
|
|
|
use actix_web::HttpResponse;
|
|
|
use chrono::Utc;
|
|
|
-use rust_decimal::Decimal;
|
|
|
+use rust_decimal::{Decimal, MathematicalOps};
|
|
|
use rust_decimal::prelude::FromPrimitive;
|
|
|
use rust_decimal_macros::dec;
|
|
|
use serde_json::{json, Value};
|
|
|
@@ -76,7 +76,7 @@ fn calc_volatility_div_price_diff(records: Value) -> Decimal {
|
|
|
let volume = Decimal::from_str(record["volume"].as_str().unwrap().to_string().as_str()).unwrap();
|
|
|
let mid = (record_high + record_low) / Decimal::TWO;
|
|
|
|
|
|
- volatility += volume * mid * Decimal::ONE_HUNDRED * (record_high - record_low) / mid;
|
|
|
+ volatility += (volume * mid).ln() * Decimal::ONE_HUNDRED * (record_high - record_low) / mid;
|
|
|
}
|
|
|
|
|
|
let mut vdpd = volatility;
|