|
|
@@ -73,9 +73,10 @@ fn calc_volatility_div_price_diff(records: Value) -> Decimal {
|
|
|
for record in records_array {
|
|
|
let record_high = Decimal::from_str(record["high"].as_str().unwrap().to_string().as_str()).unwrap();
|
|
|
let record_low = Decimal::from_str(record["low"].as_str().unwrap().to_string().as_str()).unwrap();
|
|
|
+ let volume = Decimal::from_str(record["volume"].as_str().unwrap().to_string().as_str()).unwrap();
|
|
|
let mid = (record_high + record_low) / Decimal::TWO;
|
|
|
|
|
|
- volatility += Decimal::ONE_HUNDRED * (record_high - record_low) / mid;
|
|
|
+ volatility += volume * mid * Decimal::ONE_HUNDRED * (record_high - record_low) / mid;
|
|
|
}
|
|
|
|
|
|
let mut vdpd = volatility;
|