Project Part2 AbhishekSrivastava
Project Part2 AbhishekSrivastava
Abhishek Srivastava
2024-08-04
R Markdown
Introduction
In the stock market, identifying optimal buying opportunities is crucial for making
profitable investment decisions. This project aims to design a Buy Signal Filter using data
science techniques in R, leveraging key technical indicators to help investors pinpoint
potential buy signals.
library(quantmod)
quantmod is a popular R package used for quantitative financial modeling and trading. It
provides a range of functions and tools for quantitative analysis of financial data,
particularly in the context of stock market analysis and trading strategies.
library(TTR)
The TTR (Technical Trading Rules) library is a package in R that provides a collection of
technical analysis functions for financial time series data. TTR is often used in conjunction
with other packages like quantmod for analyzing and visualizing financial data.
# Load necessary libraries
library(quantmod)
library(TTR)
library(dplyr)
##
## ######################### Warning from 'xts' package
##########################
## #
#
## # The dplyr lag() function breaks how base R's lag() function is supposed
to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or
#
## # source() into this session won't work correctly.
#
## #
#
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can
add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop
#
## # dplyr from breaking base R's lag() function.
#
## #
#
## # Code in packages is not affected. It's protected by R's namespace
mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this
warning. #
## #
#
##
#############################################################################
##
##
## Attaching package: 'dplyr'
str(MSFT)
str(AMZN)
str(MSFT_modified)
str(AMZN_modified)
head(MSFT_modified)
head(AMZN_modified)
What types of plots and tables will help you to illustrate the findings to your questions?
• Line Plots: Show the time series of stock prices and indicators.
• Crossover Points: Highlight buy signals on the plots.
• Summary Tables: Provide a concise view of signal counts and performance metrics.
library(ggplot2)
library(dplyr)
## Don't know how to automatically pick scale for object of type <xts/zoo>.
## Defaulting to continuous.
library(xts)