Open vertis opened 8 years ago
Thank you for your comment! Interesting, i thought that volumes are treated as floats, therefore i don't have a clue how to solve this. Since i don't have much time at the moment i encourage you to fork the project and find a solution.
Having the same problem here. Did you figure it out ?
Thanks !
Just run into this as well. @PierreNicolasL: did you manage to figure it out?
Decided to implement my own solution in pure Ruby instead of trying to figure out the Ruby/C interop and patch the library.
So if anyone else runs into this issue, here's a Ruby implementation of OBV. Note: data is a hash containing an array of close prices in :close and an array of volumes in :volume
def obv(data)
obvs = []
prev_closes = []
data[:volume].each_with_index do |vol, index|
current_close = data[:close][index]
prev_close = prev_closes.last
if index == 0
obvs << vol
else
if current_close > prev_close
obvs << (obvs.last + vol)
elsif current_close < prev_close
obvs << (obvs.last - vol)
elsif current_close == prev_close
obvs << obvs.last
end
end
prev_closes << current_close
end
return obvs
end
Running the following example code:
I get either:
if I use
func.in_volume
orif I try to use
in_real(1,...)
Looking at the
talib
code seems to suggest there should be anin_volume
(unless I'm misunderstanding something)