Search Results

Search found 3 results on 1 pages for 'xle'.

Page 1/1 | 1 

  • getSymbols and using lapply, Cl, and merge to extract close prices

    - by algotr8der
    I've been messing around with this for some time. I recently started using the quantmod package to perform analytics on stock prices. I have a ticker vector that looks like the following: > tickers [1] "SPY" "DIA" "IWM" "SMH" "OIH" "XLY" "XLP" "XLE" "XLI" "XLB" "XLK" "XLU" "XLV" [14] "QQQ" > str(tickers) chr [1:14] "SPY" "DIA" "IWM" "SMH" "OIH" "XLY" "XLP" "XLE" ... I wrote a function called myX to use in a lapply call to save prices for every stock in the vector tickers. It has the following code: myX <- function(tickers, start, end) { require(quantmod) getSymbols(tickers, from=start, to=end) } I call lapply by itself library(quantmod) lapply(tickers,myX,start="2001-03-01", end="2011-03-11") > lapply(tickers,myX,start="2001-03-01", end="2011-03-11") [[1]] [1] "SPY" [[2]] [1] "DIA" [[3]] [1] "IWM" [[4]] [1] "SMH" [[5]] [1] "OIH" [[6]] [1] "XLY" [[7]] [1] "XLP" [[8]] [1] "XLE" [[9]] [1] "XLI" [[10]] [1] "XLB" [[11]] [1] "XLK" [[12]] [1] "XLU" [[13]] [1] "XLV" [[14]] [1] "QQQ" That works fine. Now I want to merge the Close prices for every stock into an object that looks like # BCSI.Close WBSN.Close NTAP.Close FFIV.Close SU.Close # 2011-01-03 30.50 20.36 57.41 134.33 38.82 # 2011-01-04 30.24 19.82 57.38 132.07 38.03 # 2011-01-05 31.36 19.90 57.87 137.29 38.40 # 2011-01-06 32.04 19.79 57.49 138.07 37.23 # 2011-01-07 31.95 19.77 57.20 138.35 37.30 # 2011-01-10 31.55 19.76 58.22 142.69 37.04 Someone recommended I try something like the following: ClosePrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x)))) However I tried various combinations of this without any success. First I tried just calling lapply with Cl(x) >lapply(tickers,myX,start="2001-03-01", end="2011-03-11") Cl(myX))) > lapply(tickers,myX,start="2001-03-01", end="2011-03-11") Cl(x))) Error: unexpected symbol in "lapply(tickers,myX,start="2001-03-01", end="2011-03-11") Cl" > > lapply(tickers,myX(x),start="2001-03-01", end="2011-03-11") Cl(x))) Error: unexpected symbol in "lapply(tickers,myX(x),start="2001-03-01", end="2011-03-11") Cl" > > lapply(tickers,myX(start="2001-03-01", end="2011-03-11") Cl(x) Error: unexpected symbol in "lapply(tickers,myX(start="2001-03-01", end="2011-03-11") Cl" > lapply(tickers,myX(start="2001-03-01", end="2011-03-11") Cl(x)) Error: unexpected symbol in "lapply(tickers,myX(start="2001-03-01", end="2011-03-11") Cl" > Any guidance would be kindly appreciated.

    Read the article

  • How to connect computers to a network printer behind a router?

    - by kokbira
    General question: How to connect computers to an IP printer behind a router? Particular question: How to connect C-1 and C-2 to PRI? What? Where? [ISP] | | -> IPs:200.X.X.X/other configs:DC | [R-1] | | -> IPs:10.1.X.X locked by MAC,M:255.0.0.0,G:10.1.0.1 |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯| | | [PRI] IP:10.1.7.7 [R-2] IP: 10.1.0.1,MAC:A | | -> IPs:192.168.1.X,M:255.255.255.0,G:192.168.1.1 |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯| | | [C-1] IP:192.168.1.2 [C-2] IP:192.168.1.3,MAC:A Glossary and details: ------------------------------------------------------------------------------------ - IP: IP. - IPs: Some IP range. - M: Mask. - G: Gateway. - MAC:A: A MAC address that I will not inform you :) - DC: Don't care. - ISP: Internet Service Provider (not so much details about it on that case). - R-1: A real router or some concatenated so IP range bellow that block is 10.1.X.X and above is ISP. The provided IPs are provided by MAC. As all available addresses are in use, you must clone an existing one to join with a new device (and to disconnect the cloned one). - PRI: An network printer (some people here call that IP printer). - R-2: A TP-LINK TL-WR340G, mine wireless router (since my computer does not have ethernet input, it is my ethernet-wifi adapter :), admin access, MAC address cloned from C-2 (MAC:A). I've to configure 10.0.1.1 and 10.0.1.2 as DNS addresses, other wise I cannot connect C-1 and C-2 to Internet. - C-1: My computer, a CCE XLE-425 (remember: no ethernet input), with Windows 7, admin access. - C-2: another computer with better configs than mine, MAC:A, Windows XP. Requirements: I want to print, to access Internet and to do it myself (no need to call network admin men in black people). Pay attention to MAC clones and DNS info.

    Read the article

1