Building Your Own Technical Analysis Tool . . . . . . . . . It's As Easy As 123 (Well, Almost!)

Gregory Domingo
Posted on Aug 7, 2016

Introduction

Technical analysis tools are widely used by professional portfolio managers and traders to help them decide on trading strategies and tactics. They are in great demand as well by amateur traders including apparently a huge number of housewives in Taiwan who are conversant with MACD and Bollinger bands.

This blog describes my effort in building a basic technical analysis app using Shiny/R platform in a relatively short period of time.

The AppAnalyzer

The image on the right is a screenshot of the app. It is a single page app that has a sidebar which is an input area  where you can specify what technical analyses you want to see. The right part of the screen is the output and it shows two graphs one on top of each other. These graphs show the tech analysis charts for the stocks, currencies or items ("Securities")  that have been selected in the input sidebar.

The app is quite simple but provides a lot of flexibility as it was designed to handle up to two  Securities at a time.

The app allows you to look at historical daily prices of the Securities and runs technical analyses on them including candlesticks, MACD, Bollinger Bands, and RSI. There is also an option to use log prices.

Prices are retrieved online courtesy of Yahoo! Finance.

 

Building The App

Building the app requires knowledge of R and Shiny.

Starting with a working knowledge of R, it took me about 25 working hours to build the app with the bulk of it spent on learning how to use Shiny and making mistakes programming in Shiny (maybe 12 to 16 hours). Layout and formatting also took some time to get right (5 to 7 hours). The actual core of the program to get it running actually took little time (only a few hours) as R and Shiny have many features and accompany packages that simplify the process of pulling in data and displaying the output.

Someone who is accomplished in R and Shiny can produce the app in a few hours.

The three main workhorses of the Shiny app are the quantmod package, the TTR (Technical Trading Rules) package and the CSS.

Quantmod provides access to Yahoo! Finance's database which is extensive and includes indices and securities of foreign markets as well. Quantmod also provides access to other databases including Google. The Shiny code is shown below.

       data2 <- getSymbols(randomVals()[2], src = "yahoo",
       from = input$dates[1],
       to = input$dates[2],
       auto.assign = FALSE)

TTR provides the canned software to produce the technical charts given the data from Yahoo! Finance. Shiny code is shown below.

       if(input$RSI) {plot(addRSI())}
       if(input$Boll) {plot(addBBands())}
       if(input$MACD) {plot(addMACD())}

And CSS provides the canned formatting that makes your app look 5 times better! The Shiny code is shown below. A subdirectory named www has to be created containing the css file that has the theme of your choice which in this case is bootstrap.min.css from Bootswatch.com

              theme = "bootstrap.min.css"

As you can see, all three are so simple to use yet so powerful.

 

Going Forward

My experience in building this Shiny app was very positive. I was awed both by how easy it is to get free financial data and by how easy it is to analyse the data using open sourced software and packages.

I could easily have expanded the choices for technical analysis in the app with just a few minutes of additional work but decided against it due to layout constraints. This is something I intend to do in the near future.

Now, go build your own technical analysis app!

About Author

Gregory Domingo

Gregory Domingo

Built his career in the financial services industry (fixed income research and fixed income portfolio management) in New York. and moved back to the Philippines in 1995. Has been involved since then in senior management positions in both...
View all posts by Gregory Domingo >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp