Assignment 12
Assignment 12
43.
1.Historical data analysis:
historical_data = {
"-$5.00": 1,
"-$1.00": 20,
"-$0.50": 55,
"-$0.38": 95,
"$0.00": 140,
"$0.38": 100,
"-$0.50": 73,
"$1.00": 10,
"$2.00": 6,
}
Based on above data, we create a dictionary called historical data that
shows how often daily stock price changes happen. The keys show the
possible price changes, and the numbers show how often those changes
happen.
7.Analyze results
mean_price = np.mean(final_prices)
median_price = np.median(final_prices)
std_deviation = np.std(final_prices)
NumPy methods are used in the code to find the mean, median, and
standard deviation of the end stock prices.
8. Interpret results
print(f"Mean Final Stock Price: ${mean_price:.2f}")
print(f"Median Final Stock Price: ${median_price:.2f}")
print(f"Standard Deviation of Final Stock Price: ${std_deviation:.2f}")
By this the results are printed and provide the potential range of ending
stock prices .
18.
Bring in Libraries:
Numpy is what we use to work with numbers and make random numbers.
We can make maps with matplotlib.pyplot.
Making a plan:
Make a line plot to see how the stock price changed in the simulation.
For reference, the first price of the stock is shown by a thin red line.
# Given parameters
current_price = 53
mean_daily_change = 0.003227
daily_volatility = 0.026154
num_days = 30
# Simulation loop
daily_returns = np.random.normal(loc=mean_daily_change,
scale=daily_volatility, size=num_days)
cumulative_returns = np.cumsum(daily_returns)