hippke / wotan

Automagically remove trends from time-series data
MIT License
147 stars 21 forks source link

Recommended trend removal #59

Closed andrewcztrack closed 3 years ago

andrewcztrack commented 3 years ago

Hi @hippke !!

I hope your well.

I was wondering if I could get some thoughts on using the package for financial time series.

I was planning on using -

window_length=15, return_trend=True, method='biweight'

Would the above be the method you recommend.

Best, Andrew

hippke commented 3 years ago

Hi @andrewcztrack As beautifully shown by Benoit Mandelbrot, stock prices are non-Gaussian. If you want to remove long-term trends, it is advisable to use a detrending method which takes this into account. A good starting point would be wotan's default biweight filter. As for the window_length, you really need to test what works for your data at hand. Can you share a data file and a few plots? Then I can have a closer look and say more about it.

andrewcztrack commented 3 years ago

Hi @hippke great to hear from you! Basically the plan was to take out the trends before converting the price series to a return series. observe some sample data below -- pricing data-

import yfinance as yf
data = yf.download("QUAL.AX, QLTY.AX, VGS.AX, VAS.AX, VAE.AX, VISM.AX", start="2019-01-01", end="2020-12-30")['Adj Close']..dropna()

return data -

import yfinance as yf
data = yf.download("QUAL.AX, QLTY.AX, VGS.AX, VAS.AX, VAE.AX, VISM.AX", start="2019-01-01", end="2020-12-30")['Adj Close'].pct_change().dropna()

Apologies im not sure how to attach plots to the github issue

hippke commented 3 years ago

With window_length=20 I get something like this: Figure_1

Which trends should be removed, which should be kept? In astrophysics, you want to remove stellar noise and keep planetary transit signals. In finance, I guess it depends on your idea?