Skip to content

Instantly share code, notes, and snippets.

@milktrader
Created March 21, 2013 15:16
Show Gist options
  • Save milktrader/5213832 to your computer and use it in GitHub Desktop.
Save milktrader/5213832 to your computer and use it in GitHub Desktop.
When has the 10-year closed below 1.5% since 1962? Just a couple of compact lines of Julia will tell you.
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
2012-07-25 | 1.43
2012-07-26 | 1.45
@milktrader
Copy link
Author

For a little comparison with R ...

>library(quantmod)
> d <- getSymbols("DGS10",src="FRED",auto.assign=FALSE)
> system.time(d[which(d<1.5),])
   user  system elapsed 
  0.001   0.001   0.020 
julia> @elapsed d[v(d) .< 1.5]
0.003257884

@milktrader
Copy link
Author

Not that anyone would do this on purpose mind you ...

> d[1,1]
           DGS10
1962-01-02  4.06
> d[1,1] = 1.23
> d[1,1]
           DGS10
1962-01-02  1.23
julia> d[1]
1962-01-02  |  4.06

julia> d[1].value = 1.23
ERROR: type TimeStamp is immutable

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