Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

keras - Tensorflow how to structure LSTM model?

for a project I am trying to just make a very simple AI that can predict trends of stocks 1 day in advance given 30 days of previous data

Here is the code I am using to get the stock data:

import numpy as np
import pandas as pd
from pandas_datareader import data as pdr
import datetime
#Data Source
import yfinance as yf
yf.pdr_override()

TICKER = "LULU"

startDate = datetime.datetime(2020,1,1)
endDate = datetime.date.today()
print(startDate.strftime("%Y-%m-%d"))
print(endDate.strftime("%Y-%m-%d"))
data = pdr.get_data_yahoo(TICKER, start=startDate.strftime("%Y-%m-%d"), end = endDate.strftime("%Y-%m-%d"), interval='1d')

As of now, the data (stored in the variable data) is structured as (in a pandas dataframe I think):

                  Open        High         Low       Close   Adj Close   Volume
Date
2020-01-02  232.899994  233.470001  231.770004  233.419998  233.419998  1449300
2020-01-03  231.240005  234.500000  230.229996  232.639999  232.639999  1315400
2020-01-06  231.490005  235.529999  230.800003  235.429993  235.429993  1460700
2020-01-07  235.500000  236.850006  233.339996  233.699997  233.699997  1367900
2020-01-08  234.880005  238.009995  234.009995  237.270004  237.270004  1883900
...                ...         ...         ...         ...         ...      ...
2021-01-04  351.670013  356.829987  346.410004  356.399994  356.399994  2015300
2021-01-05  357.890015  369.440002  357.380005  366.500000  366.500000  2122900
2021-01-06  362.109985  367.600006  357.480011  363.250000  363.250000  1170800
2021-01-07  366.869995  374.200012  364.600006  367.290009  367.290009  1103000
2021-01-08  367.359985  370.540009  362.589996  365.459991  365.459991   994300

Is there a way to model an LSTM using Tensorflow and/or Keras to make it so I can input the past 30 days of pricing data (Open, High, Low, Close, Adj Close, Volume) for each day, and get a single closing price prediction for the following day?

P.S. I am aware about the many limitations there are about predicting the stock market but I am just trying to do it as an experiment.

Thank you!

question from:https://stackoverflow.com/questions/65648097/tensorflow-how-to-structure-lstm-model

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...