# Finance: Learning how to create trading strategies and backtesting with R ver. 1

Last Updated on September 4, 2022 by shibatau

## I. What shall we learn?

Let’s learn trading strategies and backtesting using R from the tutorial:

Creating Trading Strategies and Backtesting With R

## II. Getting Data and creating simple charts

We will run R codes on Google Colaboratory

%%R # put in the first line for each cell
install.packages("quantmod")
install.packages("TTR") # a collection of over 50 technical indicators
install.packages("PerformanceAnalytics")
library(quantmod)
library(TTR)
library(PerformanceAnalytics)
# getting stock prices of AAPL, TSLA and NFLX
getSymbols('AAPL', src = 'yahoo', from = '2021-01-01')
getSymbols('TSLA', src = 'yahoo', from = '2021-01-01')
getSymbols('NFLX', src = 'yahoo', from = '2021-01-01')
getSymbols('TM', src = 'yahoo', from = '2021-01-01')
# creating plots using quantmod
quantmod::barChart(AAPL, theme = chartTheme('black'))
barChart(TSLA, theme = chartTheme('black'))
barChart(NFLX, theme = chartTheme('black'))
barChart(TM, theme = chartTheme('black'))

You can see the codes on Google Colaboratory

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

This site uses Akismet to reduce spam. Learn how your comment data is processed.