Skip to content

Instantly share code, notes, and snippets.

@milktrader
Created December 27, 2013 22:55
Show Gist options
  • Save milktrader/8153802 to your computer and use it in GitHub Desktop.
Save milktrader/8153802 to your computer and use it in GitHub Desktop.
wat a mess in the one-liner at the end ... searching for a piping method
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);
julia> cl = readseries(Pkg.dir("MarketTechnicals/test/data/spx.csv"), value=5);
julia> daysdojiregistered = index(cl[value(doji(op,hi,lo,cl))])
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
1971-05-05
1971-07-02
1971-08-10
1971-08-25
1971-11-12
@milktrader
Copy link
Author

This is a bit more elegant

doji(op,hi,lo,cl) |> x -> cl[value(x)] |> index

@milktrader
Copy link
Author

Or maybe this, a bit more readable but an extra pipe

doji(op,hi,lo,cl) |> value |> x -> cl[x] |> index

@milktrader
Copy link
Author

Or, if you want to know what dates were there dojis in the month of February,

 doji(op,hi,lo,cl) |> value |> x -> cl[x] |> x -> bymonth(x, 2) |> index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment