204k views
3 votes
Create a variable called avg_daily_flactuation.

a. Compute the diference between the closing (Close) and opening (Open) prices.
b. Compute average of this difference and save it to the avg_daily_flactuation variable

User Anrimian
by
8.4k points

1 Answer

7 votes

Final answer:

To compute the avg_daily_fluctuation variable, subtract the Open price from the Close price to get daily fluctuations, sum these, and divide by the total number of days. Assign the result to the avg_daily_fluctuation variable.

Step-by-step explanation:

To create a variable called avg_daily_fluctuation and compute the average daily fluctuation in stock prices, you would first calculate the difference between the closing (Close) and opening (Open) prices, then compute the average of these differences. Assuming you have a dataset with Open and Close prices for each trading day, you can follow these steps:

  • Determine the daily fluctuation by subtracting the Open price from the Close price for each day.
  • Add all the daily fluctuations together.
  • Divide the sum of the fluctuations by the number of days to get the average.
  • Assign this average to the avg_daily_fluctuation variable.

For example, if the daily fluctuations over 5 days are 1, -0.5, 0.75, -0.25, and 1.5, you add them together to get 2.5, and then divide by 5 to get an average daily fluctuation of 0.5, which is saved in the avg_daily_fluctuation variable.

User Kaffiene
by
8.5k points