Skip to content

Commit

Permalink
notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
femtotrader committed Apr 27, 2024
1 parent a27bfda commit a1dceee
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions examples/notebooks/teardown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end

# ╔═╡ accbd5bc-4976-48cf-91c1-e12b62a94edf
function random_data(rng::AbstractRNG = Random.GLOBAL_RNG;
start = Dates.Date(2020, 1, 1),
start = Dates.Date(2010, 1, 1),
step = Dates.Day(1),
stop = Dates.Date(2023, 1, 1) - Dates.Day(1),
price_init = nothing,
Expand Down Expand Up @@ -61,15 +61,31 @@ end
cum_returns = CumulativeReturn(returns)

# ╔═╡ a208fb00-cfe1-46d9-9751-e9e5f423f8fb
plot(cum_returns, title="Cumulative returns")
begin
plot(cum_returns, title="Cumulative returns", color=:green)
hline!([1.0], color=:green, linestyle=:dashdot, label="")
end

# ╔═╡ ac56bb3d-0732-4536-bb81-594643c31935
# ╔═╡ 2d92945c-1ad5-4ef6-8c6e-1d77b23698f6
begin
dd = DrawDowns(returns)
dd.coredata.STOCK1 = dd.coredata.STOCK1 .* 100.0
plot(dd, title="Drawdowns (%)")
end

# ╔═╡ ac56bb3d-0732-4536-bb81-594643c31935
begin
plot(dd, title="Drawdowns (%)", color=:red, fillcolor=:red, fillrange=0, fillalpha=0.35)
end

# ╔═╡ c61cb98d-b0ea-4bf5-a0b4-11b925b18e0d
begin
returns.coredata[!, :Year] = map(dt -> year(dt), returns.coredata[!, :Index])
returns.coredata[!, :Month] = map(dt -> Dates.Date(year(dt), month(dt), 1), returns.coredata[!, :Index])
end

# ╔═╡ 04894092-b9c4-42d8-87b2-b530de95736c
returns

# ╔═╡ Cell order:
# ╠═a1861f50-046e-11ef-348b-cb9f60ea0d1b
# ╠═accbd5bc-4976-48cf-91c1-e12b62a94edf
Expand All @@ -78,4 +94,7 @@ end
# ╠═c0fd125c-70d3-4e42-a0a5-4daff44a2c96
# ╠═b0e1d632-1b86-4259-8f28-464e0af0c3e0
# ╠═a208fb00-cfe1-46d9-9751-e9e5f423f8fb
# ╠═2d92945c-1ad5-4ef6-8c6e-1d77b23698f6
# ╠═ac56bb3d-0732-4536-bb81-594643c31935
# ╠═c61cb98d-b0ea-4bf5-a0b4-11b925b18e0d
# ╠═04894092-b9c4-42d8-87b2-b530de95736c

0 comments on commit a1dceee

Please sign in to comment.