Posts tagged with xts

A question I’ve googled before without success. Hopefully this answer will show up for someone who needs it. I’ll also go over the better-known uses of ? just in case.

  • To get help in R about a function like subset you type ?subset . That’s like man subset from the command line.
  • If you only know roughly what you’re looking for use double question marks: so ??nonlinear will lead to the package nlme. That’s like apropos on the command line.
  • To get a package overview, type ?xts::xts. There is no ?xts help. Packages that don’t have ?twitteR::twitteR you will need to use ??twitteR to find the help pages on ?twitteR::status-class, ?twitteR::dmGet, etc.
  • Finally, the question of the title. To get R help on punctuation such as (, {, [, `, ::, ..., +, and yes, even on ? itself, use single quotes to ‘escape’ the meaningful symbol. Examples follow:
    • ?'`'
    • ?'('
    • ?'['
    • ?'...'
    • ?'+'
    • ?'%*%'
    • ?'%x%'
    • ?'%o%'
    • ?'%%'
    • ?'%/%'
    • ?'$'
    • ?'^'
    • ?'~'
    • ?'<-'
    • ?'='
    • ?'<<-'

All of the quotation marks `, ', " use the same help file so ?'"' or ?'`' will give you the help file for ?'''.




Two interesting ideas here:

  • "trading time"
  • price impact of a trade proportional to exp( √size )

Code follows:

Read More

(Source: finmath.stanford.edu)










I’m trying to do retrospectives on financial predictions as I stumble across them on the Web. Here’s one that turned out correct: @EpicureanDeal said not to buy Blackstone Group when it went public.

"A little knowledge is a dangerous thing." Like, say, a little knowledge of cool and funky rich people or private equity deals from the paper. I’d rather be financially illiterate than taken hold of this bag.

From 35, to 25, to 15, to 5. Since the market bottom $BX has quintupled which is basically in line with the S&P.

Correlation since 2008 of the S&P to $BX has been 95%, so you can rule out a “complementary growth” argument for the buy.

Reproducible analysis:

require(quantmod)
getSymbols("BX")
chartSeries(BX)
reChart(up.col='yellow', dn.col='light blue', color.vol=FALSE)
getSymbols("SPY")
chartSeries(BX/SPY)         #quantmod automatically matches subsets for you!
reChart(up.col='yellow', dn.col='light blue', color.vol=FALSE)
bx <- BX['2008:']
sp <- SPY['2008:']
cor(bx,sp)










POSIXct is the signed number of seconds since “the epoch”. For example it was

  • 1351298112 UTC (GMT)

when I wrote this. (1351298112 UTC = Sat Oct 27, 2:35 am GMT = Fri Oct 26, 8:35 pm EST = Fri Oct 26, 5:35 pm PST = 2:35 pm HST)

POSIXlt is one of many text | character | string formats such as:

  • May 17, 2017
  • 17/5/2017
  • 17-5-17 05:24:39

(Source: stat.ethz.ch)