We will build and test a simple long only trading strategy. First, obtain daily data of “SPY” from 2010- 10-01 to 2016-02-19. Compute the daily log…

We will build and test a simple long only trading strategy. First, obtain daily data of “SPY” from 2010- 10-01 to 2016-02-19. Compute the daily log return using the adjusted closing price. Divide the dataset into two parts: the first 1254 for training and the rest 100 days as holdout samples. library(quantmod) source(“backtest.r”) getSymbols(“SPY”,from=’2010-10-01′,to=’2016-02-19′,src=”yahoo”) (a) Construct the best ARMA model based on the first 1254 daily log return data using the auto.arima function in the fpp package. This function will automatically select the best orders (namely p, d, and q in the arima model) for you. We call this model 1. We will then fix the order of the arima model, and at each step, only parameter estimation changes. Use this model to predict one day ahead. Compare the predicted direction (namely if the prediction return is positive or negative) with the direction of the actual return. Were you right? For the next day re-estimate the parameters using data 2 to 1255 and predict the next day’s direction. Repeat until the test data is exhausted. Report the probability of being correct (calculated as the percentage of times the model predicts the directions correctly). (b) Now, look at the ACF plot of the training data only, propose an MA(q) model. Look at the PACF plot of the training data only, propose an AR(p) model. Please give your reasons for choosing the p and q values. Call these model 2 and 3. Compare these three models using backtest procedure to compare the models via 1-step ahead forecasts. You may use t = 1254 as the starting forecast origin. Which one has the best accuracy? 

Here is the backtest code to be pasted in r for this question’s use!

“backtest” <- function(m1,rt,orig,h=1,xre=NULL,fixed=NULL,include.mean=TRUE){

 # m1: is a time-series model object

 # orig: is the starting forecast origin

 # rt: the time series

 # xre: the independent variables

 # h: forecast horizon

 # fixed: parameter constriant

 # inc.mean: flag for constant term of the model.





 if(orig > nT)orig=nT

 if(h < 1) h=1






 if(!is.null(xre))xre <- matrix(xre)

 for (n in orig:jlast){



  if (is.null(xre))

   pretor=NULL else pretor=xre[1:n,]


  if (is.null(xre)){nx=NULL} 

  else {nx=matrix(xre[(n+1):(n+h),],h,ncol(xre))}



  # nof is the effective number of forecats at the forecast origin n.







 for (i in 1:h){






 print(“RMSE of out-of-sample forecasts”)


 print(“Mean absolute error of out-of-sample forecasts”)


 backtest <- list(origin=orig,error=err,rmse=rmse,mabso=mabso)


Calculate your essay price
(550 words)

Approximate price: $

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)
Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more