Borsa istanbul (BIST) hisse fiyat değişim yönünün ilişkisel borsa ağı kullanılarak tahmin edilmesi
Forecasting stock price change direction using relational stock market network on borsa Istanbul (BIST)
Yazar: BİRCAN ERGÜR
Danışman: DOÇ. DR. ZEHRA ÇATALTEPE
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Bilgisayar Mühendisliği Ana Bilim Dalı
Derece: Yüksek Lisans, 2014
Konu: Bilgisayar Mühendisliği Bilimleri-Bilgisayar ve Kontrol = Computer Engineering and Computer Science and Control
Dizin: Gelecek tahmini = Future guess ; Menkul kıymetler borsası = Stock exchange ; Çok katmanlı perseptronlar = Multilayer perceptrons

Özet:
Borsada bir hisse senedinin fiyatı, ulusal veya küresel etkenler ile ilişki içinde olduğu öteki firmaların durumlarından etkilenebilmektedir. Küresel veya ulusal etkenler, senet fiyatlarında aynı zamanlarda etki gösterirken; ilişkili firmaların etkisi belli zaman kaymalarıyla görülebilmektedir. Yapılan bu tez çalışmasında, Borsa İstanbul (BIST) dahilindeki hisse senetleri arasından, Bankacılık, Telekomünikasyon ve Bilgi Teknolojileri sektörlerine ait hisseler için 15 dakikalık aralık sonundaki fiyat değişim yönü tahmin edilmiştir. Fiyat değişim yönü tahmin modelinde; hem hisselerin kendi geçmiş fiyat bilgisinden, hem de ilişki içinde olduğu saptanan diğer bazı hisseler ile olan bağlantılardan yararlanılmıştır.
Fiyat değişim yönünün 15 dakika aralığıyla tahmin edilebilmesi için, hisselerin gün içi borsa işlem verisinden yararlanılmıştır. Bu veri üzerinden, her 15 dakikalık aktif borsa aralığına ait öznitelik vektörleri oluşturulmuştur. Sınıf etiketleri ise bir sonraki aralık sonunda hisse senetlerinin fiyatlarındaki anlamlı değişikliklerin yönünü gösterecek şekilde belirlenmiş ve bu etiketler öznitelik vektörüne atanmıştır. Öznitelik vektörleri tahmin modelinde kullanılmadan önce, öznitelik seçim yöntemleri ile puanlandırılmış ve sonrasında da [0-1] aralığına normalleştirilmiştir.
Yapılan tez çalışmasında iki farklı yaklaşımla hisse fiyat değişim yönü tahmini yapılmıştır. Birinci yaklaşıma göre (İçerik Yaklaşımı, İY), hisselerin yalnızca kendi geçmiş fiyat bilgisinden yararlanılmış; ikinci yaklaşımda (İçerik ve Ağ Yaklaşımı, İVAY) ise hisselerin kendi geçmiş fiyat bilgisinin yanı sıra, bu hisseyi etkileyen diğer hisse senetleri ile olan ilişkiler kullanılmıştır. 
Birinci yaklaşıma göre hisselerin geçmiş fiyat bilgilerinden literatürde kullanılmış finansal göstergeler hesaplanmış ve bu göstergeler öznitelik vektörlerini oluşturmuştur. İkinci yaklaşımda ise, finansal gösterge öznitelik vektörlerine, hisseyi etkileyen diğer hisse senetlerinin geçmiş fiyat değişim yönü etiketleri eklenmiştir. Bir hisseyi etkileyen diğer hisse senetlerinin saptanmasında, iki hisse senedinin geçmiş fiyat vektörleri arasındaki zaman kaymalı Pearson benzerliğinden yararlanılmıştır. Zaman kaymalı benzerlik hesapları sayesinde, hangi hissenin hangi hisseyi ne kadar, ne yönde ve ne tepki süresiyle etkilediği bulunmuştur. Etkileşim bilgisi sayesinde hisse senetlerinin etkileşim çizgesi oluşturulmuştur. Bu heterojen çizgede, hisselerin birbirlerini pozitif ya da negatif etkilediği ve etkileşimin en kuvvetli olarak hangi zaman aralığında olduğu bilgisi gösterilmektedir.
Her iki yaklaşım için kurulan tahmin modellerinde, en iyi model parametrelerinin belirlenmesi amacıyla eğitim verisinin bir kısmı doğrulama veri kümesi olarak kullanılmış ve test modelinde kullanılacak parametrelere bu aşamada karar verilmiştir. Her hisse senedi için ayrı eğitim modeli kurulmuş olup, her birinde başarı gösteren parametreler farklı olmuştur. İY yaklaşımı kullanılarak, hisse senetlerinin anlamlı fiyat değişim yönü, en başarılı modellerde LINK hissesi için %100, TEBNK hissesi için %95 makro-ortalama F-ölçütü ile tahmin edilmiştir. İVAY yaklaşımı kullanan en başarılı modellerde TEBNK hissesi için %83, SKBNK hissesi için %77 makro-ortalama F-ölçütü ile tahmin edilmiştir. 24 hisse senedi için en iyi tahmin yapan modellerin makro-ortalama F-ölçütü ortalaması ise İY yaklaşımı için %67, İVAY yaklaşımı için %62 bulunmuştur.
Yaklaşımlar değerlendirildiğinde, bazı hisse senetleri yalnızca kendi geçmiş fiyat bilgisini kullanan İY yaklaşımı ile daha başarılı sonuç üretirken; bazı hisse senetleri ise geçmiş fiyat bilgisi ve hisse ağı bilgisi kullanan İVAY yaklaşımı ile daha başarılı sonuç üretmiştir. İY yaklaşımında başarı elde eden hisselerin sayısı, İVAY yaklaşımında başarı elde eden hisselere oranla daha yüksek bulunmuştur.
Bu tez çalışması sonucunda; ilişkisel borsa ağının çıkarılması, çıkarılan ağ ile içerik bilgisinin birlikte kullanılarak sınıflandırma yapılması, öznitelik seçme ve en iyi model parametresi belirleme süreçlerinin birlikte yapılması bu alanda yapılan çalışmalara katkı sağlamıştır.

Abstract:
A stock market is a financial place that buyers and sellers agree on a price for stocks of a company, where the stocks are the most common instances of the both real and digital money, representing the specified percentage of that company. Stock market brings investors together to agiotage on company shares. Those shares have flexible prices depending on supply and demand. A stock price will possibly increase in case of high demand, whereas the price will decrease when supply is higher than demand. 
By supporting mobile investigation for traders, helping to raise capital for companies, supplying an environment for profit sharing; stock exchanges actually have a crucial role in the economy. Traders as buyers, who chase for daily or long term opportunities, try to get profit from the market, while the businesses as sellers also struggle to get benefit from the investment of those traders. This exchange is mostly balanced between the supply and demand expectations.
Especially for recent years, prediction and analysis models for stock markets, which are financial profit opportunity sources, draw much attention of the researchers. However, forecasting the direction of stock prices is a challenging issue since the financial market traces static and dynamic, linear and nonlinear, multifaceted parameters. Two main opposite ideas related with stock market prediction are argued for years: Efficient Market Hypothesis (EMH), and Prediction Methods.
Efficient Market Hypothesis claims that stock prices follow a random walk; therefore the price trends are completely unpredictable. Especially for long time periods, theory ignores the prediction methods to outperform a buy and hold strategy. Globally, there have been many supporters of this theory.
In fact the situation is not desperate at all with the help of four main prediction methods: Traditional time series predictions, machine learning, technical and fundamental analysis. Time series prediction basically represents a linear combination of past values with a noise factor. This approach is combined with the Moving Average model and constructs a linear and stable relation. Machine learning techniques like linear regression, ANN models, SVMs are commonly used to forecast the stock market.
Technical analysis investigates the financial indicators related with the stock market, and tries to predict future values of time series data belonging specific stocks. This approach assumes that stock market – news relation effects on real time prices, therefore technical analysis does not evaluate news. Fundamental analysis tries to understand the relation between stock prices and supply – demand factors.
Artificial neural networks have been performed successfully in common on financial problems in the recent literature as a technical analysis methodology. One of the main reasons is that the ANNs are able to find out the complicated relations, since they are general function approximations. As there are chaotic relationships among the parameters affecting the stock market, artificial neural networks seem suitable for such a large complex feature and data set. Secondly, artificial neural networks are so adaptive that they are able to recognize patterns also other than in the training set. So for such extended data sets ANNs would be helpful.
Forecasting the direction of stock prices is a challenging issue since the financial market traces static and dynamic, linear and nonlinear parameters. In a stock market, the direction of a stock price depends on many parameters like financial indicators, company relations, and local or global factors. 
However, the exact nature of these dependencies is not fully known, and varies from market to market. While global or local factors affect the stock prices at the same time, the effect of related companies could be seen within a time delay. In this thesis, we construct a prediction model for the next 15 minutes price change direction of each stock among the Banking, Telecommunication and Information Technologies areas of Borsa Istanbul (BIST).  For that purpose, we use both the past price vectors of a stock itself, and links representing the effectiveness on a stock network.
In order to predict the future price direction of a stock within 15 minutes, we use day-in stock market activity records between July and November 2013, which BIST shared for academic purposes. Using these records, we construct stock price vectors for each 15 minute active period of stock market. We label these vectors to determine the direction of stock price, considering significant price changes on those prices. In order to eliminate the unimportant price changes for a stock, we use volume information and standard deviation of price vectors. If the price change is over that standard deviation, we label the corresponding period of vector as {+1}. If the price change is under the standard deviation, we label as {-1}, and otherwise, in case of no significant changes, we use label {0}. After labeling the price vectors, we generate feature vectors for each training or test dataset. Generated feature vectors are first ordered by the feature selection/elimination techniques, and then normalized into [0-1] scale.
For the purpose of stock price change prediction, we use two different approaches called Content Only (CO), and Content and Link (CL) while constructing prediction models. In the CO approach, model uses only past prices of a stock itself; while the CL approach uses both past prices and links from the other stocks in the same network.
The first approach (CO) uses the financial indicators, which are statistical metrics representing the trend of the specific stock. There are many kinds of financial indicators, in this study, we use the financial indicators which have been used in previous studies on stock price prediction. The features used by the CO approach for classification are the only the indicators. We use 11 different types of financial indicators in this study. Since every indicator has parameters on its own, we determine three different parameters for each financial indicator. Eventually, after the addition of volume as an indicator, 34 features are used in the CO model.
The second approach (CL) uses both the financial indicators of a period of the specific stock, and the cross-correlations between the other stocks in the network. While constructing the network among other stocks, we analyze the similarities between two stock price change vectors using Pearson correlation coefficient with different time delays. Thus, with the help of sliding comparison of stock price change vectors, we observed that which stock affects the other, with how much weight, and with how much delay. 
With the relational information among stocks, we build an interaction graph of the stock market. In such a heterogeneous graph, we are able to observe the stock relationships. CL uses those relations as features. While extracting link based features, we first determine the most correlated stocks affecting the specific stock. Then, we also determine the most correlated time delay for the specific relationship. According to that information, we choose three labels for each linked stock. Since five most correlated stocks are chosen for each stock, CL uses 15 features from stock market network. Therefore, a total of 34 + 15 = 49 features are used in CL model.
As mentioned above, stock market is a complicated environment where many linear, nonlinear, dynamic parameters influence the prices. Therefore it is important to determine significant features for the specific stock market, or each specific stock. Besides, the cost and running time of the prediction model can be optimized by selecting features, and high performance results might be obtained with a sufficient feature subset.
After generating features for each approach, we score those features using two different feature elimination techniques called mRMR (minimum Relevance Maximum Redundancy) by Peng et. al. (2005), and RFESVM (Recursive Feature Elimination SVM) by Guyon et. al. (2002). Feature selection techniques helps to use much more significant features, and to increase performance of classification model eliminating useless features. For the first approach CO, features are scored 1-to-34; while for the second approach CL, features are scored 1-to-49.
In this thesis, we use a validation dataset to determine the best model parameters. Those parameters are consisting of feature elimination technique, top feature count, classification algorithm, and classification parameters. Thus, we decide the features to be used after testing them on a validation set, like the model parameters. At least 14544 models with different parameters are examined, and then the best 20 of them are chosen for the real tests for each approach of CO, and CL.
At the end of the study, since each kind of stock has its own best model parameter, 40 different models are examined for each stock. Using first approach CO, the future price change direction is predicted with %100 macro-average F-measure for the stock LINK, and %95 macro-average F-measure for the stock TEBNK. Then, using second approach CL, the best results are seen on stock TEBNK with %83 macro-average F-measure, and on stock SKBNK with %77 macro-average F-measure. Considering average results among all stocks, CO approach reaches %67 macro-average F-measure, while CL approach reaches only %62.
Analyzing the results, CO approach that uses only past stock price change data of its own predicts better than CL approach that uses both stock past price changes, and stock market network relations as features, for most of the stocks. Considering the feature elimination methods, and classification techniques, mostly RFESVM and Multilayer Perceptron combination gives much useful information among all the prediction models.
In conclusion, within this thesis, we construct a relational stock market network, we use the relations based on this network while predicting the future stock price change direction with also the content information carrying past stock prices. We also determine the features and model parameters at the same time by testing thousands of combinations on validation dataset.