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: quantmod.
Now, that there is rpy2 to interface between both these languages(i.e. Python & R). I would like to prototype some financial data analysis applications using the power of python with the quantmod package.
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 & quantmod documentations.
Therefore the question is as follows =>
- Does any one know of a suitable resource/s to get me started with python & quantmod using rpy2?
- Alternatively, can some one post simple example/s of pythonic code that calls quantmod functions using rpy2?
Here is an attempt of mine in implementing a prototype using rpy2 & quantmod:
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")
Problem with the above code(quantmodplot.py) is that it produces "RuntimeError" as follows:
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 <module>
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'
Your help will be greatly appreciated...