Skip to content

Commit

Permalink
Merge 45e174f into 57fef4f
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed May 9, 2017
2 parents 57fef4f + 45e174f commit 209be76
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ makedocs(
"volatility.md",
"volume.md",
"candlesticks.md",
"utils.md",
]
)

Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ Pages = [
"volatility.md",
"volume.md",
"candlesticks.md",
"utils.md",
]
```
14 changes: 14 additions & 0 deletions docs/src/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Utilities

## Typical Price

```@docs
typical
```

```@repl
using MarketData
using MarketTechnicals
merge(ohlc, typical(ohlc))
```
11 changes: 10 additions & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
doc"""
typical(ohlc; h="High", l="Low", c="Close")
Typical Price
```math
\text{Typical Price} = \frac{H + L + C}{3}
```
"""
function typical{T,N}(ohlc::TimeArray{T,N}; h="High", l="Low", c="Close")
val = (ohlc[h] .+ ohlc[l] .+ ohlc[c]) ./3
val = (ohlc[h] .+ ohlc[l] .+ ohlc[c]) ./ 3
TimeArray(val.timestamp, val.values, ["typical"], ohlc.meta)
end

Expand Down

0 comments on commit 209be76

Please sign in to comment.