From e40cc4efa1dc105d1ab8573de185eafa250fb488 Mon Sep 17 00:00:00 2001 From: Sanjuktha Date: Thu, 25 Apr 2024 18:07:47 +0530 Subject: [PATCH] Fix dependencies and other errors in demo_finance.md --- docs/Project.toml | 2 ++ docs/src/demo_finance.md | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 0b6c035..80f5c35 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -6,6 +6,8 @@ MarketData = "945b72a4-3b13-509d-9b46-1525bb5c06de" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +Impute = "f7bf1975-0170-51b9-8c5f-a992d46b9575" +GLM = "38e38edf-8417-5370-95a0-9cbbq8c7f171a" TSFrames = "9f90e835-9451-4aaa-bcb1-743a1b8d2f84" [compat] diff --git a/docs/src/demo_finance.md b/docs/src/demo_finance.md index 9c33c1f..285c3ce 100644 --- a/docs/src/demo_finance.md +++ b/docs/src/demo_finance.md @@ -5,7 +5,7 @@ To load the IBM historical data, we will use the `MarketData.yahoo` function from [MarketData.jl](https://github.com/JuliaQuant/MarketData.jl), which returns the data in the form of a `TimeArray`. We just simply pass this on to the `TSFrame` constructor. ```@repl e1 -using TSFrames, MarketData, Plots, Statistics, Impute +using TSFrames, MarketData, Plots, Statistics, Impute, GLM ibm_ts = TSFrame(MarketData.yahoo(:IBM)) ``` @@ -145,13 +145,14 @@ within the window. ```@repl e1 sp500 = TSFrame(MarketData.yahoo("^GSPC")); sp500_adjclose = TSFrames.subset(sp500, date_from, date_to)[:, ["AdjClose"]] +ibm_adjclose = ibm[:, [:Index, :AdjClose]] sp500_ibm = join(sp500_adjclose, ibm_adjclose, jointype=:JoinBoth) sp500_ibm_returns = diff(log.(sp500_ibm)) TSFrames.rename!(sp500_ibm_returns, ["SP500", "IBM"]); function regress(data) - ll = lm(@formula(IBM ~ SP500), data) + ll = lm(@formula(SP500 ~ IBM), data) co::Real = coef(ll)[coefnames(ll) .== "IBM"][1] sd::Real = Statistics.std(residuals(ll)) return (co, sd)