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
macro select(ex::Expr, sym1::Symbol, ex1::Expr, sym2::Symbol, ex3::Expr) | |
ex.args, sym1, ex1.args, sym2, ex3.args | |
end | |
julia> @select open, high, close in ohlcv where close > open when day=Friday | |
(Any[:open,:high,:(close in ohlcv)],:where,Any[:>,:close,:open],:when,Any[:day,:Friday]) | |
# would be nice to do this instead of a one-liner | |
@select open, high, close |
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
type Foo | |
f::Function | |
end | |
bar = Foo(x->2x) | |
bar.f(2) | |
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 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))))))) |
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) | |
NewerOlder