Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The way computing VR is wrong? #115

Open
GuangLightman opened this issue Mar 10, 2022 · 1 comment
Open

The way computing VR is wrong? #115

GuangLightman opened this issue Mar 10, 2022 · 1 comment

Comments

@GuangLightman
Copy link

    def _get_vr(self, windows=None):
        if windows is None:
            window = self.VR
            column_name = 'vr'
        else:
            window = self.get_int_positive(windows)
            column_name = 'vr_{}'.format(window)

        idx = self.index
        gt_zero = np.where(self['change'] > 0, self['volume'], 0)
        av = pd.Series(gt_zero, index=idx)
        avs = self._mov_sum(av, window)

        lt_zero = np.where(self['change'] < 0, self['volume'], 0)
        bv = pd.Series(lt_zero, index=idx)
        bvs = self._mov_sum(bv, window)

        eq_zero = np.where(self['change'] == 0, self['volume'], 0)
        cv = pd.Series(eq_zero, index=idx)
        cvs = self._mov_sum(cv, window)

        self[column_name] = (avs + cvs / 2) / (bvs + cvs / 2) * 100

According to https://help.eaglesmarkets.com/hc/en-us/articles/900002867026-Summary-of-volume-variation-index

CV = n-day trading volume of stock price in n days;
CVS = n-day ∑ cv

So cvs = _mov_sum(self['volume'], window) but not cvs = self._mov_sum(pd.Series(eq_zero, index=idx), window)
I don't think there is a reason to look at 'change'==0 cases as they are quite rare.

@GuangLightman
Copy link
Author

 self[column_name] = (avs + cvs / 2) / (bvs + cvs / 2) * 100

Also this returns non-stable value when bvs and cvs are 0's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant