Quantmod货币(FX)数据的确切时间戳 [英] Exact time stamp on quantmod currency (FX) data

查看:142
本文介绍了Quantmod货币(FX)数据的确切时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可能会使用 quantmod 软件包从Oanda和Yahoo财务收集每日数据,例如:

we may collect daily data from Oanda and Yahoo finance with the quantmod package as such:

getFX("USD/JPY",from="2007-01-01", to = Sys.Date())
getSymbols("EUR=X",src="yahoo",from="2002-01-01",auto.assign=F)

仔细检查数据后,您可能会注意到来自这些来源的值明显不同。然后,我想知道每个来源一天的时间戳究竟花了多少时间?看来不是格林尼治标准时间午夜了。

After checking data carefully, you may notice that values from these sources are significantly different. I then wonder what exactly was the time taken the time stamp of the day for each source? It does not look to be at midnight GMT.

如果您有任何线索,我将不胜感激。谢谢。

I would appreciate if you have a clue. Thank you.

推荐答案

FX是场外交易市场,因此没有中央交易所可以随时设定汇率,但可以套利注意事项表示,所有主要参与者(银行,对冲基金,真实货币)在流动市场时段(美国东部时间周日下午5点(美国/纽约)至美国东部时间周五下午约5点)内的任何给定时间以近似相同的价格定价。因此,即使对于相同的时间戳,不同的来源也会提供略有不同的定价。考虑到这一点,以下是 EUR / USD 的Oanda和Yahoo近期汇率:

FX is an OTC market, so there is no central exchange which sets the rate at any time, but arbitrage considerations means all the major players (banks, hedge funds, real money) are pricing at approximately the same rates at any given time during liquid market hours (which is 5pm Sunday EST (America/New_York) to 5pm Friday EST approximately). Therefore different sources can offer slightly different pricing even for the same timestamps. With this in mind, here are some recent Oanda and Yahoo rates for EUR/USD:

library(quantmod)
getFX("EUR/USD",from="2007-01-01", to = Sys.Date())
ya2 <- getSymbols("EUR=X",src="yahoo",from="2002-01-01",auto.assign=F)

# Yahoo reports the unconventional pricing of USDEUR = 1 / EURUSD, so lets get in the conventional form EUR/USD:
ya2[, c(1, 4, 6)] <- 1 / coredata(ya2)[, c(1, 4, 6)]
ya2[, c(2, 3)] <- 1 / coredata(ya2)[, c(3, 2)]

tail(ya2, 5)
# > tail(ya2, 5)
# EUR=X.Open EUR=X.High EUR=X.Low EUR=X.Close EUR=X.Volume EUR=X.Adjusted
# 2016-12-20   1.040474   1.041992  1.035518    1.040583            0       1.040583
# 2016-12-21   1.039393   1.045151  1.038529    1.039047            0       1.039047
# 2016-12-22   1.042753   1.049759  1.042753    1.042862            0       1.042862
# 2016-12-23   1.043950   1.046792  1.042970    1.043765            0       1.043765
# 2016-12-26   1.045588   1.047011  1.044600    1.045478            0       1.045478
colnames(EURUSD) <- "Oanda"
compare <- merge(ya2, EURUSD)
indexFormat(compare) <- "%Y-%m-%d, %a"

tail(round(compare, 4), 15)
# EUR.X.Open EUR.X.High EUR.X.Low EUR.X.Close EUR.X.Volume EUR.X.Adjusted  Oanda
# 2016-12-13, Tue     1.0643     1.0653    1.0607      1.0642            0         1.0642 1.0629
# 2016-12-14, Wed     1.0630     1.0667    1.0615      1.0629            0         1.0629 1.0632
# 2016-12-15, Thu     1.0515     1.0525    1.0404      1.0514            0         1.0514 1.0468
# 2016-12-16, Fri     1.0418     1.0472    1.0404      1.0419            0         1.0419 1.0435
# 2016-12-17, Sat         NA         NA        NA          NA           NA             NA 1.0451
# 2016-12-18, Sun         NA         NA        NA          NA           NA             NA 1.0451
# 2016-12-19, Mon     1.0448     1.0482    1.0413      1.0450            0         1.0450 1.0446
# 2016-12-20, Tue     1.0405     1.0420    1.0355      1.0406            0         1.0406 1.0391
# 2016-12-21, Wed     1.0394     1.0452    1.0385      1.0390            0         1.0390 1.0413
# 2016-12-22, Thu     1.0428     1.0498    1.0428      1.0429            0         1.0429 1.0443
# 2016-12-23, Fri     1.0440     1.0468    1.0430      1.0438            0         1.0438 1.0445
# 2016-12-24, Sat         NA         NA        NA          NA           NA             NA 1.0455
# 2016-12-25, Sun         NA         NA        NA          NA           NA             NA 1.0455
# 2016-12-26, Mon     1.0456     1.0470    1.0446      1.0455            0         1.0455 1.0455
# 2016-12-27, Tue         NA         NA        NA          NA           NA             NA 1.0449

雅虎数据:


  • 首先,我们看到yahoo返回OHLC数据。我可以告诉您,雅虎提供的收盘价( EUR.X.Close )对应于UTC午夜左右。我已对照其他可靠的(专有)外汇报价数据定价来源进行了检查。

  • First, we see yahoo returns OHLC data. I can tell you that the close price offered by yahoo (EUR.X.Close) corresponds to around midnight UTC. I've checked this against other reliable (proprietary) FX tick data pricing sources.

此外,您可以清楚地看到开盘价( EUR.X.Open )与之前的收盘价相比还差了一个小节,因此我们可以得出结论,在任何给定的午夜UTC结束的24小时内,开盘价都设定在任意时间窗口内交易日(在此期间还将设置最高和最低)。这只是Yahoo创建条形的惯例,并不是正确或错误,而是他们选择传播数据的方式。

Also, you can clearly see that the Open price (EUR.X.Open) is different from the previous close price one bar back so we can conclude the open price is set at some arbitrary time window during the 24 hour period ending midnight UTC on any given trading day (the high and low would also be set over this period). This is just Yahoo's convention for bar creation, and is not "right" or "wrong", just how they choose to disseminate data.

Oanda数据:


  • 注意,Oanda返回每天的价格,包括周末和公共假期,并且只有一列值。 Oanda返回时间序列中每一天的加权平均价格。 (它不会在美国东部标准时间下午5点或UTC午夜返回关闭数据)。为什么这会有用呢?好吧,因为许多人想使用每日FX数据费率来评估不同货币等的业务交易,因此Oanda被认为是具有可靠定价数据的可信任名称( https://www.oanda.com/fx-for-business/

  • Notice Oanda returns prices for every day, including weekends and public holidays, and only one column of values. Oanda is returning a weighted average price for each day in the time series. (It isn't returning Close data at 5pm EST, or midnight UTC). Why would this be useful then? Well, because many people want to use daily FX data rates to value business transactions in different currencies etc, and Oanda is considered a trusted name with reliable pricing data (https://www.oanda.com/fx-for-business/)

每天的东部时间下午5点,流动性非常差,因为这是在外汇市场上支付展期利息的时间,因此,该时间通常被用作外汇交易日的结束时间。创建每日外汇数据的一种合理方法是,假设工作日第一天从美国东部时间周日下午5点开始,至美国东部时间星期一下午5点结束,工作日第二天在美国东部时间星期一下午5点开始,并在美国东部时间星期二下午5点结束,依此类推。这每周提供5个甚至24小时的交易条

Liquidity is very poor at 5pm EST each day as this is when rollover interest is paid in the FX market, therefore this time is often used as the end of an FX trading day. A reasonable way to create daily FX data is assume weekday one starts at 5pm Sunday EST and ends 5pm Monday EST, weekday two starts at 5pm Monday EST and ends at Tuesday 5pm EST, etc. This gives 5 even 24-hour trading bars each week.

在相关主题上,显然上述两种来源均不可用于回测日间外汇策略。如果您碰巧每天或每天都在寻找免费的外汇数据,则一些选项包括:

On a related topic, clearly neither of the above sources are usable for backtesting interday FX strategies. If you happen to be looking for free FX data at daily or higher frequencies, some options include:


  1. 的免费汇总外汇报价数据href = http://www.truefx.com/?page=downloads rel = nofollow noreferrer> http://www.truefx.com/?page=downloads

  2. 通过 Interactive Brokers 设置交易帐户。您最多可以累积一年的OHLC每日历史记录,并可以在5、30秒,1分钟的更短时间范围内获得数据(至少是我上次检查的时间,这是前一段时间)。

  3. DIY:在信誉良好的经纪人处开设一个帐户,然后开始自己存储流媒体滴答声

  1. Free aggregated FX tick data from http://www.truefx.com/?page=downloads
  2. Set up a paper trading account with Interactive Brokers. You can get up to a year of rolling daily OHLC history, and data at shorter time frames of 5, 30 sec, 1 min bars (at least last time I checked, which was a while ago).
  3. DIY: Open an account with a reputable broker and start storing streaming ticks yourself

这篇关于Quantmod货币(FX)数据的确切时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆