Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
Final Project Specification
Your report will consider the following requirements:
- The table of contents must list at least one table and one figure.
- Libraries and scripts must only be loaded in the first code chunk.
- Hide irrelevant or unnecessary messages (e.g. messages when loading libraries).
- Add descriptions between code chunks to describe the purpose of each chunk.
- Add comments in code chunks to describe why something was done (as needed).
- Except for custom functions, code should be displayed in the submitted PDF file as evidence of your work.
- Select the specified stock from the data: PFIZER INC
- Clean the data as needed and display the head of the data, showing columns relevant to the below analysis.
- Plot the autocorrelation function of simple daily returns.
- For top marks, also perform an autocorrelation of average returns over a diMerent time interval (e.g. monthly). Can you find a moderate (magnitude greater than 0.2), statistically significant autocorrelation? You may need to look further into time than what the autocorrelation function shows by default.
- Prepare for the Moving Average Crossover Strategy.
- Create a custom function in a .R script to generate buy and sell signals.
- Create a custom function in a .R script to backtest your strategy.
- Using your functions, generate signals and backtest the strategy, plotting the performance summary. For top marks:
- Use a loop to optimise the fast and slow window sizes to find the best performing strategy. The best solutions will consider all combinations of fast window sizes 20, 30, 40, 50 and slow window sizes 60, 90, 120, 150.Do not numerically or graphically show the performance for each combination of window sizes, but do show the code used for optimising window sizes. Do plot the performance summary for the best performing strategy.
- Create a line plot to help visualise where the moving average crossovers occur in your chosen strategy.
- Using a Generative AI tool: Microsoft Copilot
- Generate a function that will compute signals for a Bollinger Bands Breakout Strategy.
Think critically about the AI response and output. You might consider:
- What approach is taken to generate Bollinger Bands?
- What approach is used to determine buy and sell signals?
- Do other sources online agree with the approach?
- The generated function should use the same input and output types as the function you wrote for moving average crossover signal generation.
- Insert the generated function in its own code chunk in the R Notebook. Do not insert this function into the .R script (this is an exception - any other functions you write should be kept in the .R script).
- Use the function to generate signals for Pfizer close prices, pass these to your backtest function, and plot a Performance Summary. Note you are not marked on the financial performance of this strategy, but rather your ability to critically evaluate and integrate the generated code into your notebook.
- Write up an analysis (200-300 words +/- 10%) of your findings, commenting on your autocorrelation analysis, the performance of your moving average crossover strategy, and the performance of the generated Bollinger Bands Breakout strategy.
NB. This is a larger data set than we have worked with previously (500MB +). Loading and manipulating the data should be done with packages that support big data.
You will create one single R Notebook (.Rmd) for this assignment.
Ensure you Knit to PDF to produce the final deliverable and submit the generated PDF file only. There is a maximum 10 page limit, but the title and table of contents pages do not count towards this. There is no need to Zip/Archive/Compress the PDF file. Please do not submit any .Rmd or .R or data files.For top marks, expand the one line description for each step, comment your code, and apply any learned best practices. Use Markdown formatting to make the final PDF rendering of this document look professional - including, but not limited to cover page, table of contents, list of figures, list of tables, headings, lists, and emphasis (bold/italics) where appropriate. Ensure your tables and plots have labels and captions and are included in the table of contents lists.Hide any system information or warning messages.