Python プログラミング言語は、財務データ分析アプリケーションの開発に大いに役立ちました。あるいは、データ分析用の R もあります。これには、専用の財務データ分析パッケージがあります (例: quantmod )。
現在、これらの両方の言語 (つまり、Python と R) の間のインターフェースとなる rpy2があります。Python の機能を quantmod パッケージで使用して、いくつかの財務データ分析アプリケーションのプロトタイプを作成したいと考えています。
ここまでで、rpy2(python パッケージ) を使用して quantmod 関数を呼び出す Python プログラミング言語のクイック スターター コード例をインターネットで検索するのに数時間費やしました。これまでのところ、適切な資料を見つけることに成功していません... rpy2 と quantmod のドキュメントは別として。
したがって、質問は次のとおりです=>
- rpy2を使用してpythonとquantmodを始めるのに適したリソースを知っている人はいますか?
- あるいは、rpy2 を使用して quantmod 関数を呼び出す pythonic コードの簡単な例を投稿できますか?
これは、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")
上記のコード (quantmodplot.py) の問題は、次のように "RuntimeError" が生成されることです。
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'
あなたの助けは大歓迎です...