print(2, q2) ''' Question 3: Using the data in the table, what is the continuously compounded monthly return between December 2004 and January 2005? Ans: -14.39% ''' q3 = Calculator.ret(starbucks, pos=1, cc=True) print(3, q3) ''' Question 4: Assuming that the simple monthly return you computed in Question 1 is the same for 12 months, what is the annual return with monthly compounding? Ans: -82.22% ''' q4 = Calculator.ann_ret(R=q1, m=12) print(4, q4) ''' Question 5: Assuming that the continuously compounded monthly return you computed in Question 3 is the same for 12 months, what is the continuously compounded annual return? Ans: -172.72% ''' q5 = Calculator.ann_ret(R=q3, m=12, cc=True) print(5, q5) ''' Question 6: Using the data in the table, compute the actual simple annual return between December 2004 and December 2005. Ans: -2.14% '''
# Question 11 q11_amzn = Calculator.ret([38.23, 41.29]) # q11_amzn = Calculator.R(PV=38.23, FV=41.29) # Other option q11_cost = Calculator.ret([41.11, 41.74]) print(11, q11_amzn, q11_cost) # Question 12 q12_amzn = Calculator.ret([38.23, 41.29], cc=True) q12_cost = Calculator.ret([41.11, 41.74], cc=True) print(12, q12_amzn, q12_cost) # Question 13 q13_amzn = Calculator.ret([38.23, 41.29], dividends=[0, 0.1]) print(13, q13_amzn, 0.1 / 41.29) print(13, (41.29 + 0.1) / 38.23 - 1, 0.1 / 41.29) # Question 14 q14_ann_ret = Calculator.ann_ret(R=q12_amzn, m=12) q14_cc_ann_ret = Calculator.ann_ret(R=q12_amzn, cc=True) print(14, q14_ann_ret, q14_cc_ann_ret) # Question 15 q15_amzn = 8000 / 10000 q15_cost = 2000 / 10000 print(15, q15_amzn, q15_cost) # Question 16 q16 = q11_amzn * q15_amzn + q11_cost * q15_cost print(16, q16)
# q11_amzn = Calculator.R(PV=38.23, FV=41.29) # Other option q11_cost = Calculator.ret([41.11, 41.74]) print(11, q11_amzn, q11_cost) # Question 12 q12_amzn = Calculator.ret([38.23, 41.29], cc=True) q12_cost = Calculator.ret([41.11, 41.74], cc=True) print(12, q12_amzn, q12_cost) # Question 13 q13_amzn = Calculator.ret([38.23, 41.29], dividends=[0, 0.1]) print(13, q13_amzn, 0.1/41.29) print(13, (41.29 + 0.1)/38.23 - 1, 0.1/41.29) # Question 14 q14_ann_ret = Calculator.ann_ret(R=q12_amzn, m=12) q14_cc_ann_ret = Calculator.ann_ret(R=q12_amzn, cc=True) print(14, q14_ann_ret, q14_cc_ann_ret) # Question 15 q15_amzn = 8000/10000 q15_cost = 2000/10000 print(15, q15_amzn, q15_cost) # Question 16 q16 = q11_amzn * q15_amzn + q11_cost * q15_cost print(16, q16)
end_date = datetime(2008, 3, 31) fields = 'adjusted_close' data = da.get_data(symbols, start_date, end_date, fields) monthly = data.asfreq('M', method='ffill') monthly.plot() plt.title('Montly Data') plt.draw() # Question 2 and 3 total_return = Calculator.ret(data) q2 = Calculator.FV(PV=10000, R=total_return) print(2, q2) # Question 3 q3 = Calculator.ann_ret(R=total_return, m=1/15) print(3, q3) # Question 4 monthly_ln = monthly.apply(np.log) monthly_ln.plot() plt.title('Montly Natural Logarithm') plt.draw() # Question 5 monthly_returns = Calculator.returns(monthly) monthly_returns.plot() plt.title('Montly Returns') plt.draw() # Question 7
end_date = datetime(2008, 3, 31) fields = "Adj Close" data = da.get_data(symbols, start_date, end_date, fields) monthly = data.asfreq('M', method='ffill') monthly.plot() plt.title('Montly Data') plt.draw() # Question 2 and 3 total_return = Calculator.ret(data) q2 = Calculator.FV(PV=10000, R=total_return) print(2, q2) # Question 3 q3 = Calculator.ann_ret(R=total_return, m=1 / 15) print(3, q3) # Question 4 monthly_ln = monthly.apply(np.log) monthly_ln.plot() plt.title('Montly Natural Logarithm') plt.draw() # Question 5 monthly_returns = Calculator.returns(monthly) monthly_returns.plot() plt.title('Montly Returns') plt.draw() # Question 7
''' q2 = Calculator.FV(PV=10000, R=q1) print(2, q2) ''' Question 3: Using the data in the table, what is the continuously compounded monthly return between December 2004 and January 2005? Ans: -14.39% ''' q3 = Calculator.ret(starbucks, pos=1, cc=True) print(3, q3) ''' Question 4: Assuming that the simple monthly return you computed in Question 1 is the same for 12 months, what is the annual return with monthly compounding? Ans: -82.22% ''' q4 = Calculator.ann_ret(R=q1, m=12) print(4, q4) ''' Question 5: Assuming that the continuously compounded monthly return you computed in Question 3 is the same for 12 months, what is the continuously compounded annual return? Ans: -172.72% ''' q5 = Calculator.ann_ret(R=q3, m=12, cc=True) print(5, q5) ''' Question 6: Using the data in the table, compute the actual simple annual return between December 2004 and December 2005. Ans: -2.14% ''' q6 = Calculator.ret(starbucks) # pos=-1 is the default print(6, q6)