BenjiKCF / Neural-Net-with-Financial-Time-Series-Data

This solution presents an accessible, non-trivial example of machine learning (Deep learning) with financial time series using TensorFlow
752 stars 312 forks source link

Use return in finance modeling, not price! #8

Closed xmduhan closed 6 years ago

xmduhan commented 6 years ago

I think your model is not better than just use last day price to predict. Use return in finance modeling, not price!

import datetime
import pandas as pd
import pandas_datareader.data as web
%matplotlib inline

stock_name = '^GSPC'

start = datetime.datetime(1950, 1, 1)
end = datetime.date.today()
df = web.DataReader(stock_name, "yahoo", start, end)

y = df['Adj Close']
prediction = df['Adj Close'].shift(-1)
pd.DataFrame({'y': y, 'prediction': prediction})[15476:].plot() 
ignaciovidalfranco commented 6 years ago

Well... This is hardly an issue. I'm agree on using return rather than price, since the first one is a normalized magnitude. But I'm curious... Why do people say "The best prediction of today's price is yersterday's price"? Could you elaborate?

xmduhan commented 6 years ago

I am not good as elaborating, But I try ... Today's price consist of two part, Last day's price(inventory) and increment, increment is usually far small than inventory, when your predict absolute price, last price is a safe place to bet, because you hold the big part of fact, which hiding your bad prediction of increment. In real finance world, you have to predict increment in particular accuracy to win, but not to predict inventory to "safe".

BenjiKCF commented 6 years ago

I agree that Price is not useful at all. I will use return or log relative return as my y in the next update.