Skip to content

Commit

Permalink
major documentation update. moving regression example script and readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
dysonance committed Apr 8, 2021
1 parent be648f3 commit acd1fdf
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ Indicators is a [Julia](https://julialang.org) package offering efficient implem
#### Corn futures daily data
![alt text](https://raw.githubusercontent.com/dysonance/Indicators.jl/master/examples/example3.png "Example 3")

#### Gold Futures Moving Regression
[alt text](https://raw.githubusercontent.com/dysonance/Indicators.jl/master/examples/example4.png "Example 4")

3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[deps]
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
GLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Documenter, Indicators, Plots
using Documenter, Indicators, Plots, GLMakie

makedocs(
modules = [Indicators],
Expand All @@ -10,6 +10,7 @@ makedocs(
"Volatility Indicators" => "vol.md"],
"Exotic" => ["Regressions"=>"reg.md",
"Trendlines" => "trendy.md",
"Chaos" => "chaos.md",
"Patterns" => "patterns.md"]],
format = Documenter.HTML(),
doctest=false,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/chaos.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ savefig("chaos_example.svg") # hide
## Reference

```@autodocs
modules = [Indicators]
pages = ["chaos.jl"]
Modules = [Indicators]
Pages = ["chaos.jl"]
```
2 changes: 1 addition & 1 deletion docs/src/ma.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ savefig("ma_example.svg") # hide

```@autodocs
Modules = [Indicators]
Pages = ["ma.jl"]
Pages = ["ma.jl", "run.jl"]
```
33 changes: 33 additions & 0 deletions docs/src/reg.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Regression Indicators

## Example

```@example
using Temporal, Indicators, GLMakie
N = 252
X = quandl("CHRIS/CME_GC1", rows=N)
x = rename(cl(X), :Settle => :Gold)
lookback = 20
n_sigma = 2.0
reg = mlr_bands(x, n=lookback, se=n_sigma)
coef = mlr_beta(x, n=lookback)
rsq = mlr_rsq(x, n=lookback)
fig = Figure()
fig[1,1] = Axis(fig, title="Corn Futures")
lines!(fig[1,1], x.values[:,1], label="Price (Observed)", linewidth=3, color=:black)
lines!(fig[1,1], reg[:MLR].values[:], label="Predicted", linewidth=1, color=:blue)
lines!(fig[1,1], reg[:MLRLB].values[:], label="-2 Std Err", linewidth=1, color=:red)
lines!(fig[1,1], reg[:MLRUB].values[:], label="+2 Std Err", linewidth=1, color=:green)
band!(1:N, reg.values[:,1], reg.values[:,3], color="#80800040")
axislegend(bgcolor="#00000040", framecolor="#00000040", position=:cb, orientation=:horizontal)
lines(fig[2,1], 1:N, coef[:Slope].values[:], label="Beta", linewidth=2, color=:purple)
lines!(fig[2,1], 1:N, rsq.values[:], label="R-Squared", linewidth=2, color="#FF8000")
band!(1:N, zeros(N), rsq.values[:], color="#FF800040")
hlines!(current_axis(), [0.0, 1.0], linestyle=:dash, linewidth=1)
axislegend(bgcolor="#00000040", framecolor="#00000040", position=:cb, orientation=:horizontal)
save("reg_example.png", fig) # hide
nothing # hide
```
![](reg_example.png)

## Reference

```@autodocs
Expand Down
25 changes: 25 additions & 0 deletions examples/example4.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Temporal, Indicators, GLMakie

N = 252
X = quandl("CHRIS/CME_GC1", rows=N)
x = rename(cl(X), :Settle => :Gold)

lookback = 20
n_sigma = 2.0
reg = mlr_bands(x, n=lookback, se=n_sigma)
coef = mlr_beta(x, n=lookback)
rsq = mlr_rsq(x, n=lookback)

fig = Figure()
fig[1,1] = Axis(fig, title="Corn Futures")
lines!(fig[1,1], x.values[:,1], label="Price (Observed)", linewidth=3, color=:black)
lines!(fig[1,1], reg[:MLR].values[:], label="Predicted", linewidth=1, color=:blue)
lines!(fig[1,1], reg[:MLRLB].values[:], label="-2 Std Err", linewidth=1, color=:red)
lines!(fig[1,1], reg[:MLRUB].values[:], label="+2 Std Err", linewidth=1, color=:green)
band!(1:N, reg.values[:,1], reg.values[:,3], color="#80800040")
axislegend(bgcolor="#00000040", framecolor="#00000040", position=:cb, orientation=:horizontal)
lines(fig[2,1], 1:N, coef[:Slope].values[:], label="Beta", linewidth=2, color=:purple)
lines!(fig[2,1], 1:N, rsq.values[:], label="R-Squared", linewidth=2, color="#FF8000")
band!(1:N, zeros(N), rsq.values[:], color="#FF800040")
hlines!(current_axis(), [0.0, 1.0], linestyle=:dash, linewidth=1)
axislegend(bgcolor="#00000040", framecolor="#00000040", position=:cb, orientation=:horizontal)

0 comments on commit acd1fdf

Please sign in to comment.