Skip to content

Commit

Permalink
Revert "adjust klinger volume oscillator (#102)"
Browse files Browse the repository at this point in the history
This reverts commit 2fefc64.
  • Loading branch information
chungg committed Sep 12, 2024
1 parent 2fefc64 commit ba8ed4f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "traquer"
version = "0.6.1"
version = "0.7.0"
edition = "2021"
description = "technical analysis library"
license = "Apache-2.0"
Expand Down
3 changes: 1 addition & 2 deletions src/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn vforce<'a, T: ToPrimitive, U: ToPrimitive>(
state.5 + dm
};
*state = (h, l, c, trend, cm, dm);
Some(v * (1. - (dm / cm)) * trend * 200.0)
Some(v * ((dm / cm) - 1.0) * trend * 200.0)
},
)
}
Expand Down Expand Up @@ -88,7 +88,6 @@ fn vforce_alt<'a, T: ToPrimitive, U: ToPrimitive>(
/// ## Sources
///
/// [[1]](https://www.investopedia.com/terms/k/klingeroscillator.asp)
/// [[2]](https://www.daytrading.com/klinger-volume-oscillator)
///
/// # Examples
///
Expand Down
36 changes: 18 additions & 18 deletions tests/volume_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ fn test_kvo() {
assert_eq!(stats.close.len(), result.len());
assert_eq!(
vec![
47653124.52312139,
38871537.60795313,
56551756.57617685,
80719127.50187302,
91381485.15827936,
102487748.59386584,
103133145.86686252,
76544074.74621749,
76362373.25709169,
84632468.62962747,
54766782.00020293,
53496835.81130403,
60063221.578486785,
36156452.68826012,
39470196.1311378,
81568025.19964269,
163166676.59742773,
90486708.71792603
-47653124.52312139,
-38871537.60795313,
-56551756.57617685,
-80719127.50187302,
-91381485.15827936,
-102487748.59386584,
-103133145.86686252,
-76544074.74621749,
-76362373.25709169,
-84632468.62962747,
-54766782.00020293,
-53496835.81130403,
-60063221.578486785,
-36156452.68826012,
-39470196.1311378,
-81568025.19964269,
-163166676.59742773,
-90486708.71792603
],
result[16..]
);
Expand Down

0 comments on commit ba8ed4f

Please sign in to comment.