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 is the data set that will be used | |
# note: Cl is simply OHLC["Close"] | |
julia> OHLC | |
16103x6 TimeArray{Float64,2} 1950-01-03 to 2013-12-31 | |
Open High Low Close Volume Adj Close | |
1950-01-03 | 16.66 16.66 16.66 16.66 1.26e6 16.66 | |
1950-01-04 | 16.85 16.85 16.85 16.85 1.89e6 16.85 | |
1950-01-05 | 16.93 16.93 16.93 16.93 2.55e6 16.93 |
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
505x3 MarketSignal 1980-01-03 to 1981-12-31 | |
signal supersignal sig | |
1980-01-03 | false true true | |
1980-01-04 | true false true | |
1980-01-07 | true false true | |
1980-01-08 | true false true | |
⋮ | |
1981-12-28 | false true true | |
1981-12-29 | false true true |
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> @> Cl sma(50) x->merge(x,sma(Cl,200)) x->x["sma50"] .> x["sma200"] discretesignal | |
65x1 TimeArray{Int64,1} 1950-10-18 to 2012-01-31 | |
signals | |
1950-10-18 | 1.0 | |
1953-05-11 | 0.0 | |
1953-12-21 | 1.0 | |
1956-10-26 | 0.0 | |
⋮ | |
2010-07-02 | 0.0 |
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
function macd{T}(ta::TimeArray{T,1}, fast::Int, slow::Int, signal::Int) | |
fastma = ema(ta, fast) | |
slowma = ema(ta, slow) | |
mcdval = fastma - slowma | |
sigval = ema(mcdval, signal) | |
merge(mcdval, sigval, ["macd", "signal"]) | |
end |
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 TimeSeries, MarketTechnicals, MarketData, Lazy | |
julia> @> OHLC doji findall x->OHLC[x] x->x.timestamp | |
166-element Array{Date{ISOCalendar},1}: | |
1962-03-02 | |
1962-04-13 | |
1962-07-16 | |
1962-10-08 | |
1963-02-08 | |
1963-05-22 |
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 TradeModels, MarketData | |
julia> @long cl rsi (.>) 50 nextday op | |
0.3999243140318183 |
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, MarketData, FactCheck | |
julia> @time fast = fastmoving(Cl, mean, 60); | |
elapsed time: 0.305857977 seconds (72646744 bytes allocated) | |
julia> @time slow = moving(Cl, mean, 60); | |
elapsed time: 4.925385985 seconds (2079575504 bytes allocated) | |
julia> @fact fast[end].value => roughly(slow[end].value) | |
Success :: :(fast[end].value) => :(roughly(slow[end].value)) |
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, MarketData, Lazy | |
julia> d1 = date(1999,1,1); | |
julia> d2 = date(1999,2,15); | |
julia> @> Op percentchange x->x[[d1:d2]] value sum expm1 | |
0.017947448312809502 |
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 Lazy, Series, MarketData | |
julia> head(cl) | |
1-element Array{SeriesPair{Date{ISOCalendar},Float64},1}: | |
1980-01-03 105.220 | |
julia> @> cl value log diff cumsum expm1 x -> x+1 x -> x[size(x,1)] | |
1.1647025280364955 |
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> plot(cumsum(value(when(lead(percentchange(Op, method="log"), 2), index(istrue(sma(Cl,10) .> sma(Cl,30))))))) |