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> nperiodinvestors("YAHOO/INDEX_GSPC", 200) | |
0.925 | |
julia> nperiodinvestors("YAHOO/INDEX_NDX", 200) | |
0.72 | |
julia> nperiodinvestors("YAHOO/INDEX_RUT", 200) | |
0.81 |
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 Quandl, TimeSeries | |
julia> rut = quandl("YAHOO/INDEX_RUT"); | |
julia> cot_rut = quandl("OFDP/FUTURE_COT_38"); | |
julia> r = merge(rut, cot_rut, "Date"); | |
julia> simple_return!(r, "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
julia> spx | |
15914-element TimeSeries Array: | |
1950-01-03 | 16.66 16.66 16.66 16.66 | |
1950-01-04 | 16.85 16.85 16.85 16.85 | |
1950-01-05 | 16.93 16.93 16.93 16.93 | |
1950-01-06 | 16.98 16.98 16.98 16.98 | |
1950-01-09 | 17.08 17.08 17.08 17.08 | |
1950-01-10 | 17.03 17.03 17.03 17.03 | |
1950-01-11 | 17.09 17.09 17.09 17.09 | |
1950-01-12 | 16.76 16.76 16.76 16.76 |
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> fred("DGS10") | x -> byyear(x, 1977) | x -> bymonth(x, 12) | x -> nanmean(val(x)) | |
7.685238095238096 |
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> timetrial(max, vclose(ts), 100) / 0.001 # system.time(max(Cl(GSPC))) | |
0.17385107000000002 | |
# experimental type about 5x faster on 15,905 rows of data |
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 | |
julia> d = imfred("DGS10"); | |
julia> d[v(d) .< 1.5] | |
6-element TimeStamp Array: | |
2012-06-01 | 1.47 | |
2012-07-20 | 1.49 | |
2012-07-23 | 1.47 | |
2012-07-24 | 1.44 |
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
foo = [ones(1000), NaN] | |
function removeNaN_sum(x::Array) | |
newa = typeof(x[1])[] | |
for i in 1:length(x) | |
if x[i] <= max(x) | |
push!(newa, x[i]) | |
end | |
end | |
sum(newa) |
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 | |
julia> dgs = imfred("DGS10"); | |
julia> maxrows(dgs) | |
1-element TimeStamp Array: | |
1981-09-30 | 15.84 |
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
# var is an Array{TimeStamp} | |
# df is a DataFrame | |
# each is 15850 rows long | |
julia> @elapsed mean(df["Open"]) | |
0.176795466 | |
julia> @elapsed mean(var) | |
0.017835577 |
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
show(io::IO, ts::TimeStamp) = println(ts.timestamp, " ", ts.value) | |
julia> var[1] | |
1971-12-31 102.09 | |
julia> var[1:2] | |
2-element TimeStamp Array: | |
1971-12-31 102.09 | |
1971-12-30 101.78 |