This project aims to provide you with an opportunity to analyze the historical prices of a stock. You are required to calculate the 3-month moving average prices of the stock over a given period and determine the best and worst months for the stock in terms of its 3-month moving average prices. To complete this project, you need to apply the knowledge and skills about files, lists, and functions.
You will be given a CSV data file of the historical prices of a stock. This file could be opened by WordPad and data fields in each row are delimited by comma. The data fields include:
Given the file of stock prices, you are asked to develop a Python program to process the data by designing appropriate functions. At minimum you need to implement and call the following three functions:
This function has one parameter, namely csv_file_name. When the function is called, you need to pass along a CSV file name which is used inside the function to open and read the CSV file. After reading each row, it will be split into a list. The list will then be appended into the main list (a list of lists), namely data_list. The data_list will be returned at the end of the function.
This function has one parameter, namely data_list. You need to pass the data_list generated by the get_data_list() function as the argument to this function and then calculate the monthly average prices of the stock. The average monthly prices are calculated in the following way. Suppose the volume and adjusted closing price of a trading day are V1 and C1, respectively. The total sale of that day equals V1 x C1. Now, suppose the volume and adjusted closing price of another trading day are V2 and C2, respectively. The average of these two trading days is the sum of the total sales divided by the total volume:
Average price = (V1 x C1 + V2 x C2) / (V1 + V2)
To average a whole month, you need to add up the total sales (V1 x C1 + V2 x C2 + … + Vn x Cn) for each day and divide it by the sum of all volumes (V1 + V2 + … + Vn) where n is the number of trading days in the month.
A tuple with 2 items, including the date (year and month only) and the average for that month, will be generated for each month. The tuple for each month will be appended to the main list, namely monthly_averages_list. The monthly_averages_list will be returned at the end of the function. Programming Problem Solving for Mathematics
This function has one parameter, namely monthly_averages_list. You need to pass the monthly_averages_list generated by the get_monthly_averages() function as the argument to this function and then calculate the 3-month moving average prices of the stock. In general, a 3-month moving average is the average value of the 3 most recent monthly observations taken from a time series.
For example, the following lists the monthly prices of stock between October 2012 and July 2013:
To construct a 3-month moving average, take the average of the first three observations, in this case, October 2020, November 2020, and December 2020 prices:
Then find the average of the next three observations, starting with the second observation, so you’re finding the average of the second, third, and fourth observations (or November 2020, December 2020, and January 2021):
Continue the process for the entire sample. The resulting 3-month moving averages are shown below:
|Month||Average Price||3-Month Moving Average|
The first 3-month moving average is listed next to November 2020, even though it represents the average of October 2020, November 2020, and December 2020. This shows that November 2020 is the “center” of the moving average. Similarly, the 3-month moving average constructed from November 2020, December 2020, and January 2021 prices are shown next to December 2020, indicating that it’s the center of the second average. Programming Problem Solving for Mathematics
A tuple with 2 items, including the date (year and month only) and the 3-month moving average for that month, will be generated for each month except the first and the last ones. Each tuple will be appended to the main list, namely moving_averages_list. The moving_averages_list will be returned at the end of the function.
At the outset, your program needs to ask the user for a CSV file name:
Based on the CSV file name, a corresponding output text file (e.g. “Google_output.txt” for this case) will be generated. In the output file, you are eventually required to print the best month (with the highest moving average price) and the worst month (with the lowest moving average price) for the stock. You need to first print a header line for the stock, and then print a date (MM-YYYY), a comma followed by a moving average price (in 2 decimal places) on another line. You must follow the output format as shown below:
You have to include your student name and ID in your source code and name your project solution as “XXXXXXXX_project.py” (where XXXXXXXX is your 8-digit student ID). Please remember to upload your source code solution to Moodle by the submission deadline.
The project will be graded using the following criteria:
Your project should represent your work. Do not include any code not written by you in your project. You are NOT allowed to import any Python libraries in your solution except the modules namely os (https://docs.python.org/3/library/os.html), sys (https://docs.python.org/3/library/sys.html), and CSV (https://docs.python.org/3/library/csv.html). If cheating is found or the import requirement is violated, you will receive a zero mark.
INT3075 Programming and Problem Solving for Mathematics Project Description.
Essay Writing Service Features
Our ExperienceNo matter how complex your assignment is, we can find the right professional for your specific task. Tnotchpapers- Top Notch Assignments Help Services is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.
Free revision policy$10
Free bibliography & reference$8
Free title page$8
How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.Complete the order form
Once we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.Writer’s assignment
As soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.Completing the order and download