首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R的`FinancialInstrument`包中的Instrument对象。` `ls(envir=FinancialInstrument:::.instrument)`

R的`FinancialInstrument`包中的Instrument对象。` `ls(envir=FinancialInstrument:::.instrument)`
EN

Stack Overflow用户
提问于 2018-01-11 17:47:32
回答 2查看 119关注 0票数 0

我想在我的环境中加载我的一个xts对象作为金融工具(而不是从yahoo,google等获取符号),但是我不能。

我的xts是EURUSD每日OHLC系列。

ls(envir=FinancialInstrument:::.instrument)给了我:

代码语言:javascript
复制
[1] "IWM" "QQQ" "SPY" "USD"

来自雅虎之前的getSymbols运营。

我有一个bloomberg,我正在通过xls将日内序列etc导入R,所以我想在我的环境中包括这些导入(例如EURUSD)。

EN

回答 2

Stack Overflow用户

发布于 2018-01-11 20:41:43

看起来是这样的:

exchange_rate("EURUSD") [1] "EURUSD"

自动将EURUSD对添加到环境中。

票数 0
EN

Stack Overflow用户

发布于 2018-02-08 15:12:43

您存储在FinancialInstrument中的仪器与您使用getSymbols收集的数据没有直接依赖关系。您可以根据需要在FinancialInstrument中根据需要从隐藏的.instrument环境中定义和删除仪器,最好使用下面的辅助函数。请注意,您显然可以使用getSymbols来获取数据,但您仍然希望使用如下所示的适当助手来定义仪器。

这段代码应该是不言自明的,但可以帮助您理解所发生的事情。

代码语言:javascript
复制
> ls_instruments()
NULL
> stock("AAPL", currency = "USD")
Error in instrument(primary_id = primary_id, currency = currency, multiplier = multiplier,  : 
  currency USD must be defined first
> currency("USD")
[1] "USD"
> stock("AAPL", currency = "USD")
[1] "AAPL"
> ls_instruments()
[1] "AAPL" "USD" 
> currency("JPY")
[1] "JPY"
> exchange_rate("USDJPY", currency = "JPY")
[1] "USDJPY"
> getInstrument("USDJPY")
primary_id      :"USDJPY"
currency        :"JPY"
multiplier      :1
tick_size       :0.01
identifiers     : list()
type            :"exchange_rate" "currency"
counter_currency:"USD"
> ls_instruments()
[1] "AAPL"   "JPY"    "USD"    "USDJPY"
> rm_stocks("AAPL")
> ls_instruments()
[1] "JPY"    "USD"    "USDJPY"
> rm_exchange_rates("USDJPY")
> ls_instruments()
[1] "JPY" "USD"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48203977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档