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

data leakage in oscillator? #46

Closed
quant2008 opened this issue May 24, 2023 · 2 comments
Closed

data leakage in oscillator? #46

quant2008 opened this issue May 24, 2023 · 2 comments

Comments

@quant2008
Copy link

Hello, the oscillator is as follows.
here, s = diff.std(), this std uses full data series, isn't it a leakage of future data in early days?

compute the oscillator

def osc(prices, fast=32, slow=96, scaling=True):
"""
oscillator

Args:
    prices: a dataframe of prices
    fast: fast moving average factor, e.g. 32
    slow: slow moving average factor, e.g. 96
    scaling: true/false. If true scales with the standard deviation of the signal
    Strictly speacking this step is forward looking.

Returns:
    oscillator
"""
diff = prices.ewm(com=fast - 1).mean() - prices.ewm(com=slow - 1).mean()
if scaling:
    s = diff.std()
else:
    s = 1

return diff / s
@tschm
Copy link
Owner

tschm commented May 24, 2023 via email

@tschm
Copy link
Owner

tschm commented Sep 14, 2023

I have added a comment on that.

@tschm tschm closed this as completed Sep 14, 2023
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

2 participants