ebook img

PORTFOLIO MANAGEMENT USING R SIMULATION AND ARMA STOCK RETURN PREDICTION ... PDF

49 Pages·2017·1.29 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview PORTFOLIO MANAGEMENT USING R SIMULATION AND ARMA STOCK RETURN PREDICTION ...

SCHOOL OF SCIENCE AND ENGINEERING PORTFOLIO MANAGEMENT USING R SIMULATION AND ARMA STOCK RETURN PREDICTION Capstone Deign March 2017 A. Salhi Supervised by N. Rhiati 1 | Pa ge _____________________________________________________ Capstone Student: Ali Salhi Approved by the Supervisor _____________________________________________________ SUPERVISOR: Nabil Rhiati 2 | Pa ge Acknowledgments page This project would not have been possible without the help and support of many individuals. First I would like to thank my supervisor who has helped me throughout this semester mainly by setting deadlines for me and helping me respect them to the best of his ability as well as by looking at my project through the eyes of a demanding customer seeking perfection. I would also like to thank Mr. Tahar Harkat who provided me with the financial expertise and guided me through a big part of this project by telling me which calculations to make and by showing me which results were relevant and which were not. I am also grateful to anybody that I have interacted with and talk to about my project and that has provided me with great feedback. A lot of times people who aren’t related to any of the areas of expertise that are included in this project gave me the best feedback and helped me see things from their perspectives. 3 | Pa ge Contents 1. Abstract 6 2. Introduction 7 3. Methodology 9 4. Financial concepts 11 4.1 Portfolio Management 11 4.2 Efficient Frontier 12 4.3 Portfolio Covariance Matrix 14 5. Mathematical Concepts 15 5.1 Mathematical Modelling 15 5.2 The Data and Model in use 16 6. Technology Enablers 21 6.1 The “R” Programing Language 21 6.2 Why “R” 21 6.3 R Studio 22 6.4 Packages 22 6.5 Packages Used 23 6.5.1 Quantmod 23 6.5.1.1 GetSymbols 23 6.5.2 Portfolio Analytics 24 6.5.2.1 Portfolio.Spec 24 6.5.2.2 Add.Constraint 24 6.5.2.3 Random_Portfolios 25 6.5.2.4 Add.Objective 25 6.5.2.5 Optimize.Portfolio 25 6.5.3 Plotly 26 6.5.4 Forecast 27 6.5.4.1 ARIMA 27 6.5.4.2 Forecast 27 6.5.5 Stats 28 6.5.5.1 NA.omit 28 6.5.5.2 Predict 28 7 The Program sequence 29 8 The output file 31 9 Conclusion 33 10 References 34 11 Appendix 1 36 12 Appendix 2 49 4 | Pa ge Table of Figures Figure 1: Example of a stationary time series 18 Figure 2: Example of a non-stationary time series 19 Figure 3: Adjusted closing price of INFOSYS over 1 year 20 Figure 4: The R Studio interface 36 Figure 5: Opening the R script on R studio 37 Figure 6: Loading the libraries to the current session 38 Figure 7: Prompt for the number of assets to invest in 38 Figure 8: Prompt for the start and end date for data retrieval 39 Figure 9: Entering 5 stocks and their index 39 Figure 10: IBM OHCL data frame 40 Figure 11: Prompt for constraints to be added to the portfolio 40 Figure 12: Suggestions and warning messages from the program 41 Figure 13: Script to visualize the portfolios plot with Risk VS Return 41 Figure 14: Random portfolios plot 42 Figure 15: Script to visualize efficient frontier 42 Figure 16: Efficient frontier data frame 43 Figure 17: Weights of assets making up the efficient frontier 43 Figure 18: Data frame showing the weights of assets within specific portfolios 43 Figure 19: Script to retrieve weights of assets making up a specific portfolio 44 Figure 20: Results from single portfolio weights retrieval 44 Figure 21: Script for retrieving manually computed values for individual stocks 45 Figure 22: Values for the IBM stock 45 Figure 23: Script for retrieving the automatically generated summary for each stock 46 Figure 24: Summary for the IBM stock 46 Figure 25: Script to plot the historical return and the predicted ones 47 Figure 26: Plot of the historical returns and predicted ones 48 Figure 27: Accuracy measures of predicted VS actual returns 49 5 | Pa ge 1. Abstract This report covers all the aspects of my capstone project. It is structured in such a way that a person can understand all of the work that was done with no prior knowledge about the fields of finance, computer science, and mathematics. The introduction talks about all the fields that are involved in the making of this project with a preview of the workings and intent behind the work performed, which is to help portfolio managers make better informed decisions using analytics tools as well as a mathematical model. After that, and since this is a software project, a methodology section introduces the software engineering methodology that was used to keep all of the stakeholders involved throughout the development phase. A well detailed description of the technology enablers used follows that. Towards the end there is a full description of the whole code from the beginning to the end followed by a demo with screenshots and snippets of code. 6 | Pa ge 2. Introduction Data science is a fast-growing field where various methods and processes are applied to raw and usually large sets of data to extract valuable information. Data science is not a discipline on its own but rather an interdisciplinary field that merges techniques from mathematics, statistics, and computer science. This large area of studies is further divided into four more detailed and specialized subfields, namely: Decision Analytics, Descriptive Analytics, Predictive Analytics, and Prescriptive Analytics. The two that will be used extensively in the project are prescriptive as well as predictive analytics. The first will be used to make a recommendation to the user on what their best option of investment is. The recommendation will be based on a simulation to which we will apply optimization techniques. The second one will be used to predict future returns of certain stocks. That will help the portfolio manager make financial projections and run different scenarios. Now following this logic and using tools and techniques from prescriptive as well as predictive analytics, the goal of this project is to provide portfolio managers with a tool they can use to get insight form structured historical data about assets, mainly stocks, to make better informed decisions when handling their client’s money. [1] To be able to perform simulations and use historical stock prices to make decent decisions on where to invest your money, you should have an extensive knowledge in the financial field as well as some training on a statistical software. The problem is that these two prerequisites are not within everybody’s reach, and they themselves require time, energy and money. The only other two alternatives are to invest your money at your own risk without any insight or prior knowledge of the market, or hire somebody to invest your money and take a cut. 7 | Pa ge Now with that being said, this program’s main purpose is to be able, through an interactive interface, to give some sort of guidance to people that want to create a portfolio of assets to invest in, maximize their returns, and make some money in the process. The user doesn’t necessarily need to be an expert in the fields of computer science or finance to be able to use it. My knowledge about the fields of data science and finance at the beginning of the project was trivial. I was exposed to some of the technologies used in analytics by pure chance while researching it online, as in for finance, I learned about it in one class I took while studying abroad. I took this project as an opportunity to learn and absorb as much knowledge as possible about these two fields because Business and Financial Services Analytics are fields that I am highly interested in for my future career. This report will contain all the information that relates to the project whether that be detailed technical information or methodologies used and organization followed to conduct the whole project and take it from the design stages to the concrete realization and testing. The report will be complemented by screenshots of its workings to better illustrate the descriptions given and provide the reader with a visual idea of the final product. 8 | Pa ge 3. Methodology The main goal behind this capstone project being the development of a computer program I relayed heavily on the methodologies I have learned in my two software engineering classes. These methodologies are there to ensure smooth execution of the project and a good flow throughout the progress towards the final and desired result. After a review of the many methodologies available I judged the best fit for the size and nature of this project to be the “Agile Scrum Methodology”. Agile methods were created due to the continuous problems caused by the huge amounts of overhead involved in the design of new software. Agile methodologies favor small steps and incremental development with the minimal necessary planning over long-term unnecessary planning that might be subject to change because of the nature of the fast-paced environment that we live in. Following these methodologies guarantees frequent delivery of new functionalities that are added with every new increment. Agile also favors face to face communication over written documents to avoid any ambiguity and misunderstandings. The main principles of Agile methodologies are best illustrated through the Agile manifesto: Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan (Agile manifesto)[2] 9 | Pa ge Agile methodologies have their limitations as well. Some of the ones that were faced during the development of this project are the difficulty to keep all the stakeholders interested in the project as well as maintaining simplicity. The first one is because most of the stakeholders don’t have a background in computer science and get bored fast when programing technicalities and difficulties are discussed. The second one is because there is a constant need to cope with change and that entails adding or deleting parts of the program which doesn’t help keep it simple and straightforward. [3] The Agile Scrum methodology is the closest to what was adopted during the development of this process. The term closest is used because this project was developed with only one programmer and not a team. The main goal of the scrum is to provide a process that favors iterative development and continuous customer involvement. The first phase of the Scrum is where the general outline and objectives of the project are determined with the participation of the programmer and the customer. This phase is what gave birth to the project specification document. The second phase is the longest since it’s the one of the development which happen in small increments. These are called sprint cycles with each sprint resulting in an increment to the program. The third and final phase of the scrum is the one that completes the required documentation, does an assessment of the project and performance of the time and completes . anything that is left other than code [3] The sprint being the main component of the Scrum process, it is divided into four distinct phases that are followed daily to make sure that everything is in order. These phases are: 10 | Pa ge

Description:
22. 6.5 Packages Used. 23. 6.5.1 Quantmod. 23. 6.5.1.1 GetSymbols. 23. 6.5.2 Portfolio Analytics. 24. 6.5.2.1 Portfolio.Spec. 24. 6.5.2.2 Add.Constraint.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.