Increasing Accuracy of Stock Price Pattern Prediction through Data Augmentation for Deep Learning

데이터 증강을 통한 딥러닝 기반 주가 패턴 예측 정확도 향상 방안

  • 김영준 (가톨릭대학교 법정경학부 법학과) ;
  • 김여정 (가톨릭대학교 컴퓨터정보공학부) ;
  • 이인선 (가톨릭대학교 수학과) ;
  • 이홍주 (가톨릭대학교 경영학과)
  • Received : 2019.11.21
  • Accepted : 2019.12.31
  • Published : 2019.12.30

Abstract

As Artificial Intelligence (AI) technology develops, it is applied to various fields such as image, voice, and text. AI has shown fine results in certain areas. Researchers have tried to predict the stock market by utilizing artificial intelligence as well. Predicting the stock market is known as one of the difficult problems since the stock market is affected by various factors such as economy and politics. In the field of AI, there are attempts to predict the ups and downs of stock price by studying stock price patterns using various machine learning techniques. This study suggest a way of predicting stock price patterns based on the Convolutional Neural Network(CNN) among machine learning techniques. CNN uses neural networks to classify images by extracting features from images through convolutional layers. Therefore, this study tries to classify candlestick images made by stock data in order to predict patterns. This study has two objectives. The first one referred as Case 1 is to predict the patterns with the images made by the same-day stock price data. The second one referred as Case 2 is to predict the next day stock price patterns with the images produced by the daily stock price data. In Case 1, data augmentation methods - random modification and Gaussian noise - are applied to generate more training data, and the generated images are put into the model to fit. Given that deep learning requires a large amount of data, this study suggests a method of data augmentation for candlestick images. Also, this study compares the accuracies of the images with Gaussian noise and different classification problems. All data in this study is collected through OpenAPI provided by DaiShin Securities. Case 1 has five different labels depending on patterns. The patterns are up with up closing, up with down closing, down with up closing, down with down closing, and staying. The images in Case 1 are created by removing the last candle(-1candle), the last two candles(-2candles), and the last three candles(-3candles) from 60 minutes, 30 minutes, 10 minutes, and 5 minutes candle charts. 60 minutes candle chart means one candle in the image has 60 minutes of information containing an open price, high price, low price, close price. Case 2 has two labels that are up and down. This study for Case 2 has generated for 60 minutes, 30 minutes, 10 minutes, and 5minutes candle charts without removing any candle. Considering the stock data, moving the candles in the images is suggested, instead of existing data augmentation techniques. How much the candles are moved is defined as the modified value. The average difference of closing prices between candles was 0.0029. Therefore, in this study, 0.003, 0.002, 0.001, 0.00025 are used for the modified value. The number of images was doubled after data augmentation. When it comes to Gaussian Noise, the mean value was 0, and the value of variance was 0.01. For both Case 1 and Case 2, the model is based on VGG-Net16 that has 16 layers. As a result, 10 minutes -1candle showed the best accuracy among 60 minutes, 30 minutes, 10 minutes, 5minutes candle charts. Thus, 10 minutes images were utilized for the rest of the experiment in Case 1. The three candles removed from the images were selected for data augmentation and application of Gaussian noise. 10 minutes -3candle resulted in 79.72% accuracy. The accuracy of the images with 0.00025 modified value and 100% changed candles was 79.92%. Applying Gaussian noise helped the accuracy to be 80.98%. According to the outcomes of Case 2, 60minutes candle charts could predict patterns of tomorrow by 82.60%. To sum up, this study is expected to contribute to further studies on the prediction of stock price patterns using images. This research provides a possible method for data augmentation of stock data.

인공지능 기술이 발전하면서 이미지, 음성, 텍스트 등 다양한 분야에 적용되고 있으며, 데이터가 충분한 경우 기존 기법들에 비해 좋은 결과를 보인다. 주식시장은 경제, 정치와 같은 많은 변수에 의해 영향을 받기 때문에, 주식 가격의 움직임 예측은 어려운 과제로 알려져 있다. 다양한 기계학습 기법과 인공지능 기법을 이용하여 주가 패턴을 연구하여 주가의 등락을 예측하려는 시도가 있어왔다. 본 연구는 딥러닝 기법 중 컨볼루셔널 뉴럴 네트워크(CNN)를 기반으로 주가 패턴 예측률 향상을 위한 데이터 증강 방안을 제안한다. CNN은 컨볼루셔널 계층을 통해 이미지에서 특징을 추출하여 뉴럴 네트워크를 이용하여 이미지를 분류한다. 따라서, 본 연구는 주식 데이터를 캔들스틱 차트 이미지로 만들어 CNN을 통해 패턴을 예측하고 분류하고자 한다. 딥러닝은 다량의 데이터가 필요하기에, 주식 차트 이미지에 다양한 데이터 증강(Data Augmentation) 방안을 적용하여 분류 정확도를 향상 시키는 방법을 제안한다. 데이터 증강 방안으로는 차트를 랜덤하게 변경하는 방안과 차트에 가우시안 노이즈를 적용하여 추가 데이터를 생성하였으며, 추가 생성된 데이터를 활용하여 학습하고 테스트 집합에 대한 분류 정확도를 비교하였다. 랜덤하게 차트를 변경하여 데이터를 증강시킨 경우의 분류 정확도는 79.92%였고, 가우시안 노이즈를 적용하여 생성된 데이터를 가지고 학습한 경우의 분류 정확도는 80.98%이었다. 주가의 다음날 상승/하락으로 분류하는 경우에는 60분 단위 캔들 차트가 82.60%의 정확도를 기록하였다.

Keywords

References

  1. Amilon, H., "GARCH estimation and discrete stock prices: an application to low-priced Australian stocks", Economics Letters, Vol.81, No.2, pp.215-222, 2003. https://doi.org/10.1016/S0165-1765(03)00172-1
  2. Ding, X., Zhang, Y., Liu, T., and Duan, J., "Using Structured Events to Predict Stock Price Movement: An Empirical Investigation", Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp.1415-1425, 2014.
  3. Guo, S. J., Hung, C. C., and Hsu, F. C., "Deep Candlestick Predictor: A Framework toward Forecasting the Price Movement from Candlestick Charts", 2018 9th International Symposium on Parallel Architectures, Algorithms and Programming (PAAP), pp.219-226, 2018.
  4. Hoseinzade, E. and Haratizadeh, S., "CNNpred: CNN-based stock market prediction using a diverse set of variables", Expert Systems with Applications, Vol.129, No.-, pp.273-285, 2019. https://doi.org/10.1016/j.eswa.2019.03.029
  5. Hussain, Z., Gimenez, F., Yi, D., Rubin, D., "Differential Data Augmentation Techniques for Medical Imaging Classification Tasks", Proceedings of 2018 AMIA Annual Symposium, pp.979-984, 2018.
  6. Jeantheau, T., "A link between complete models with stochastic volatility and ARCH models", Finance and Stochastics, Vol. 8, No.1, pp.111-131, 2004. https://doi.org/10.1007/s00780-003-0103-6
  7. Ko, D. G., Song, S. H., Kang, K.M., and Han, S. W., "Convolutional Neural Networks for Character-level Classification", IEIE Transactions on Smart Processing & Computing, Vol.6, No.1, pp.53-59, 2017. https://doi.org/10.5573/IEIESPC.2017.6.1.053
  8. LeCun, Y., Bottou, L., and Haffner, P., "Gradient-based learning applied to document recognition", Proceedings of the IEEE, Vol.86, pp.2278-2324, 1998. https://doi.org/10.1109/5.726791
  9. Oh, C., and Shen, O. R. L., "Investigating Predictive Power of Stock Micro Blog Sentiment in Forecasting Future Stock Price Directional Movement", Proceedings of ICIS 2011, Shanghai, China.
  10. Schumaker, R. P., and Chen, H., "Textual Analysis of Stock Market Prediction Using Breaking Financial News: The AZFinText System", ACM Transactions on Information Systems, Vol.27, No.2, Article No. 12, 2009.
  11. 고광은, 심귀보, "딥러닝을 이용한 객체 인식 및 검출 기술 동향", 제어로봇시스템학회지, 제23권 제3호, pp.17-24, 2017.
  12. 김유신, 김남규, 정승렬, "뉴스와 주가 : 빅데이터 감성분석을 통한 지능형 투자의사결정모형", 지능정보연구, 제18권 제2호, pp.143-156, 2012. https://doi.org/10.13088/JIIS.2012.18.2.143
  13. 박강희, 신현정, "시계열 네트워크에 기반한 주가예측", 經營 科學(Korean management science review), 제28권 제1호, pp.53-60, 2011.
  14. 손현정, 이석준, "딥러닝을 활용한 실시간 주식 거래에서의 매매 빈도 패턴과 예측 시점에 관한 연구: KOSDAQ 시장을 중심으로", 情報시스템硏究(Journal of information systems), 제27권 제3호, pp.123-140, 2018.
  15. 신동하, 최광호, 김창복, "RNN과 LSTM을 이용한 주가 예측율 향상을 위한 딥러닝 모델", 한국정보기술학회논문지, 제15권 제10호, pp.9-16, 2017. https://doi.org/10.14801/jkiit.2017.15.10.9
  16. 이강희, 양인실, 조근식, "캔들스틱 차트 분석을 이용한 주식 매매 타이밍 예측을 위한 전문가 시스템", 지능정보연구, 제3권 제2호, pp.57-70, 1997.
  17. 이모세, 안현철, "효과적인 입력변수 패턴 학습을 위한 시계열 그래프 기반 합성곱 신경망 모형", 지능정보연구, 제24권 제1호, pp.167-181, 2018. https://doi.org/10.13088/jiis.2018.24.1.167
  18. 이민식, 이홍주, "중립도 기반 선택적 단어 제거를 통한 유용 리뷰 분류 정확도 향상 방안", 지능정보연구, 제22권 제3호, pp.129-142, 2016. https://doi.org/10.13088/jiis.2016.22.3.129
  19. 이윤선, "시간흐름을 반영하는 캔들스틱과 거래량차트", 금융공학연구, 제5권 제1호, pp.113-127, 2006.
  20. 이형용, "한국 주가지수 등락 예측을 위한 유전자 알고리즘 기반 인공지능 예측기법 결합모형", Entrue Journal of Information Technology, 제7권 제2호, pp.33-43, 2008.
  21. 정지선, 김동성, 김종우, "온라인 언급이 기업성과에 미치는 영향 분석", 지능정보연구, 제21권 제4호, pp.37-51. 2015. https://doi.org/10.13088/jiis.2015.21.4.037