Solutions for http://quant-econ.net/jl/markov_asset.html
In [1]:
using QuantEcon, QuantEcon.Models
using PyPlot
In [2]:
# == Define primitives == #
n = 5
P = 0.0125 .* ones(n, n)
P .+= diagm(0.95 .- 0.0125 .* ones(5))
s = [1.05, 1.025, 1.0, 0.975, 0.95]
gamm = 2.0
bet = 0.94
zet = 1.0
ap = AssetPrices(bet, P, s, gamm)
v = tree_price(ap)
println("Lucas Tree Prices: $v\n")
v_consol = consol_price(ap, 1.0)
println("Consol Bond Prices: $(v_consol)\n")
P_tilde = P .* s'.^(1-gamm)
temp = bet .* (P_tilde * v) + bet * (P_tilde * ones(n))
println("Should be 0: $(temp - v)\n")
p_s = 150.0
w_bar, w_bars = call_option(ap, zet, p_s, [10, 20, 30])
Out[2]:
In [ ]:
fig, ax = subplots()
ax[:set_xlabel](L"$y$", fontsize=16)
ax[:set_ylabel]("price", fontsize=16)
for bet in (.95, 0.98)
tree = LucasTree(2.0, bet, 0.90, 0.1)
my_grid, price_vals = compute_lt_price(tree)
label = LaTeXString("\$\\beta =$(bet)\$")
ax[:plot](my_grid, price_vals, lw=2, alpha=0.7, label=label)
ax[:set_xlim](minimum(my_grid), maximum(my_grid));
end
ax[:legend](loc="upper left")
plt.show()
In [ ]: