Use Tensorflow to run CNN for predict stock movement. Hope to find out which pattern will follow the price rising.
Use Tensorflow to run CNN for predict stock movement. Hope to find out which pattern will follow the price rising. Different implement codes are in separate folder.
Feature include daily close price, MA, KD, RSI, yearAvgPrice..... Detail described as below. This work is just an sample to demo deep learning. The result is not well estimated.
All of the work are done by using the same stock(2330 in Taiwan stock) which are collected from yahoo.finance. Please notice that this stock perform a stable rise these years. But our result get a little better than just random guess.
For Brief tutorial slider please check (Distributed Tensorflow & Stock prediction)
For Chinese outline slider please check HERE(中文簡介)
The major work of this project. We feed data(yearline,monthline, closePrice) as image and use CNN to recognize their pattern. Some resources really help a lot while building DQN. The main difference is how to set the reward function and way to train Qnetwork. * https://zhuanlan.zhihu.com/p/21477488 * https://github.com/gliese581gg/DQNtensorflow
File: - DQNdrawyearline.py :use for making yearline img and closeprice img, and then build model. - DQNyearlinereward.py :to build model which should be train for about 24hr. //run DQNdrawyearline.py first - Test model by yearline.ipynb : There is one model exsit in savedyearr. The code create some img to test on that. - DQNimgclosePrice.py: build a model by closeprice img and do evaluation.
The model is originated from RobRomijnders 's work used for time series data (http://robromijnders.github.io/CNN_tsc/) I've change some parameter and use different indicators to find out when to buy the stock is good.
Feature MA can drop the loss compare with RSI and ClosePrice at training step.
With 10 days MA5 as an instance. * Training data (2330train15) : 2001~2014 2330.tw. Instance labeled as 1 when it rising dramatically up to 15% in 90 days. And mix with 4 times instance labeled as 0 * Testing data (2330_test) : 2015/07 ~ 2016/08 MA5.
After running CNN_Classifier.ipynb, Result will be visualized.
My implement is under close price. This could be change to other features like RSI,KD,MA....Or, use all of them. There is CNN code that could be edit to meet the requirement (size of batch).
Not work in closePrice. Better with other feature.
Use KD value picture to predict.
python DQN_kd_pic.py //this call KD_draw.py and build model.