Created
January 15, 2014 20:01
-
-
Save milktrader/8443408 to your computer and use it in GitHub Desktop.
Simple return for first six weeks of 1999 for SPX
This file contains hidden or 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I should note that
Opis imported via theMarketDatapackage, an unregistered package that provides some constants mostly useful in testing.The cool-looking
@>is a piping operator from the registeredLazypackage. (check it out)I've made
percentchangedefault to returning log returns after much debate (with myself mostly) ... (only with myself, actually)The rest should be self-explanatory. Note that
valueis called to separate eachSeriesPair's value from its index, at which point it becomes aFloat64array. Then, it's standard boilerplate sum log returns and expm1 them to get total return in simple terms.