Closed argcast closed 1 year ago
Hello @argcast,
Yeah that does look like an issue. Something I would have to find some time to dig into more when I get a chance.
I found these links for VP which may help as its actual source is hard to find.
If you have any ideas on how to fix it, that would be helpful. 😎
Apologies for the late reply.
Kind Regards KJ
Hey @twopirllc ,
sorry for the late reply. I have been working on it with a simple fix. Here is my approach:
Since the issue happens only when open and closing prices are equal, current vp.py
does not know wether if it is pos_Volume or neg_Volume happening. Neither do we and that means we cannot directly sum it to either of them.
That's why I modified the code a little bit adding a new neut_volume
(neutral volume) that computes those cases.
Let me explain better:
import pandas as pd
import pandas_ta as ta
import yfinance as yf
df = yf.download('RVP', start="2023-03-01")
As we can see, we have found one case where open == close
and upon calling df.ta.vp()
we can see we have data loss:
While if we consider neut_vol
(neutral volume) as what is happening in those cases we can avoid data loss:
and VP charting should consider that "neutral" volume too
PS: I'm not sure wether if "neutral" should be the correct naming for this volume
I've created a PR #670 with modified vp.py
so you can take a look at it and make any necessary adjustments.
I hope this helps 🙂 Albert.
For testing & understanding purposes I've created a
DataFrame
and runvp
on the first 10 rows which is the minimum width required by the indicator.I understand as on vp.py close series is evaluated and through the
series.diff(1)
in thesigned_series
function current close is compared to the next close and then assigned a positive or negative value, which then results in eitherpos_volume
orneg_volume
for thevp
itself.As I understand, the total volume in a given price range, should be the same as the total
vp
volume should return. Is this correct? I have checked Issues #74 and #185 looking for an already answered similar question.Here is the
df.head(10)
:And here is
df.ta.vp()
where you can see Volume data loss on 2nd and 3rd rows:As you can see, when close prices are equal on consecutive rows, issues arise as
df.ta.vp()['total_Volume'].sum() == df.Volume.sum()
evaluates toFalse
What am I missing or maybe not understangid about vp?