This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using Series, MarketTechnicals, Jig.Quant | |
julia> fast = [5:15]; slow = [20:2:40]; | |
julia> dailyreturn = percentchange(cl, method="log"); | |
julia> for f in fast | |
for s in slow | |
sig = sma(cl,f) .> sma(cl,s) | |
when(dailyreturn, index(istrue(sig))) |> x -> sum(value(x)) |> expm1 |> x -> print(f," ",s," ",round(x,2), " -- ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using Series, MarketTechnicals, Jig.Quant | |
julia> fast = sma(cl, 10); | |
julia> slow = sma(cl, 30); | |
julia> sig = fast .> slow; | |
julia> dailyreturn = percentchange(cl, method="log"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this works but might be difficult to humanely parse | |
# can you guess what it means? | |
# answer below | |
julia> doji(op,hi,lo,cl) |> istrue |> index |> x -> when(cl, x) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> doji(op,hi,lo,cl) |> istrue |> index | |
13-element Array{Date{ISOCalendar},1}: | |
1970-03-31 | |
1970-06-02 | |
1970-06-09 | |
1970-08-05 | |
1970-09-02 | |
1971-02-02 | |
1971-02-04 | |
1971-03-25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> Pkg.checkout("MarketTechnicals", "series") | |
julia> using MarketTechnicals | |
julia> op = readseries(Pkg.dir("MarketTechnicals/test/data/spx.csv"), value=2); | |
julia> hi = readseries(Pkg.dir("MarketTechnicals/test/data/spx.csv"), value=3); | |
julia> lo = readseries(Pkg.dir("MarketTechnicals/test/data/spx.csv"), value=4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using Series | |
julia> op = readseries(Pkg.dir("Series/test/data/spx.csv"), value=2); | |
julia> hi = readseries(Pkg.dir("Series/test/data/spx.csv"), value=3); | |
julia> lo = readseries(Pkg.dir("Series/test/data/spx.csv"), value=4); | |
julia> cl = readseries(Pkg.dir("Series/test/data/spx.csv"), value=5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using Series | |
julia> high = readseries(Pkg.dir("Series/test/data/spx.csv"), value=3); | |
julia> low = readseries(Pkg.dir("Series/test/data/spx.csv"), value=4); | |
julia> percentrange = (high .- close) ./ high; | |
julia> head(ans) | |
3-element Array{SeriesPair{Date{ISOCalendar},Float64},1}: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract AbstractSeries | |
immutable SerialPair{T, V} <: AbstractSeries | |
index::T | |
value::V | |
end | |
type SerialArray{T,V} <: AbstractSeries | |
collection::Array{SerialPair{T,V},1} # this prevents arrays of mixed types | |
idxname::String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(quantmod) | |
getSymbols("^GSPC", from = '1900-01-01') | |
s = yearlyReturn(GSPC) | |
dens = density(s) | |
plot(dens) | |
redfill = "#d66661" | |
redstroke = "#c93d39" #not used | |
greenfill = "#6bab5b" | |
greenstroke = "#3b972e" #not used | |
purplefill = "#aa7dc0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> log_return(indexdow(GSPC, 5)["Close"]); | |
julia> foo = ecdf(ans); | |
julia> foo(-0.10) | |
0.0012492192379762648 |