title: Python rpy2 and quantmod examples
body: <p>Python programming language has helped me a lot in developing financial data analysis applications. Alternatively, there is the R for data analysis too, which has dedicated financial data analysis packages, for example: <a href="http://www.quantmod.com/" rel="nofollow">quantmod</a>. </p>
  
  <p>Now, that there is <a href="http://rpy.sourceforge.net/rpy2/doc-2.3/html/overview.html" rel="nofollow">rpy2</a> to interface between both these languages(i.e. Python &amp; R). I would like to prototype some financial data analysis applications using the power of python with the quantmod package.</p>
  
  <p>By now, I have spent several hours searching the internet for some quick starter code examples in python programming language that uses rpy2(python package) and calls quantmod functions. So far, I have not been successful in finding any suitable material... apart from the rpy2 &amp; quantmod documentations.</p>
  
  <p>Therefore the question is as follows => </p>
  
  <ol>
  <li>Does any one know of a suitable resource/s to get me started with python &amp; quantmod using rpy2?</li>
  <li>Alternatively, can some one post simple example/s of pythonic code that calls quantmod functions using rpy2?</li>
  </ol>
  
  <p>Here is an attempt of mine in implementing a prototype using rpy2 &amp; quantmod:</p>
  
  <pre><code>from rpy2.robjects.packages import importr
  
  sta = {"skeleton.TA": "skeleton_dot_TA", "skeleton_TA": "skeleton_uscore_TA"}
  quantmod = importr('quantmod', robject_translations = sta)
  
  IBM = quantmod.getSymbols("IBM")
  </code></pre>
  
  <p>Problem with the above code(quantmodplot.py) is that it produces "RuntimeError" as follows:</p>
  
  <pre><code> As of 0.4-0, ‘getSymbols’ uses env=parent.frame() and
   auto.assign=TRUE by default.
  
   This  behavior  will be  phased out in 0.5-0  when the call  will
   default to use auto.assign=FALSE. getOption("getSymbols.env") and 
   getOptions("getSymbols.auto.assign") are now checked for alternate defaults
  
   This message is shown once per session and may be disabled by setting 
   options("getSymbols.warning4.0"=FALSE). See ?getSymbol for more details
  Error in as.character(sc[[1]]) : 
    cannot coerce type 'closure' to vector of type 'character'
  Traceback (most recent call last):
    File "quantmodplot.py", line 6, in &lt;module&gt;
      IBM = quantmod.getSymbols("IBM")
    File "/usr/local/lib/python2.7/dist-packages/rpy2-2.3.6-py2.7-linux-i686.egg/rpy2/robjects/functions.py", line 86, in __call__
      return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/rpy2-2.3.6-py2.7-linux-i686.egg/rpy2/robjects/functions.py", line 35, in __call__
      res = super(Function, self).__call__(*new_args, **new_kwargs)
  rpy2.rinterface.RRuntimeError: Error in as.character(sc[[1]]) : 
    cannot coerce type 'closure' to vector of type 'character'
  </code></pre>
  
  <p>Your help will be greatly appreciated...</p>