Skip to content

Commit

Permalink
Fix dependencies and other errors in demo_finance.md
Browse files Browse the repository at this point in the history
  • Loading branch information
san-ath committed Apr 25, 2024
1 parent 23a3c66 commit e40cc4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions docs/src/demo_finance.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
```

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e40cc4e

Please sign in to comment.