[R-SIG-Finance] RBloomberg rounding price increments to 4 decimals
john.laing at gmail.com
Mon Mar 19 14:13:46 CET 2012
I think it is just the display that is truncating digits. The actual
data stored should contain more precision.
> conn <- blpConnect()
> rs <- bdh(conn, "USM2 Comdty", "PX_LAST", start_date = "20110922", end_date = "20120319")
> rs["2012-03-12", "PX_LAST"]
> rs["2012-03-12", "PX_LAST"] == 140.5312
> rs["2012-03-12", "PX_LAST"] == 140.53125
On Mon, Mar 19, 2012 at 8:57 AM, Brian G. Peterson <brian at braverock.com> wrote:
> The first thing to check is your options on R in general.
> or even
> and see if that shows you the data you expect.
> I'm not currently using RBloomberg, so I can't check this part of your
> - Brian
> On Mon, 2012-03-19 at 08:44 -0400, G.abe Lin wrote:
>> Hi guys,
>> I'm using RBloomberg to download OHLC data on futures into my
>> environment. I am porting my trading strategy from a custom framework
>> to blotter and quantstrat.
>> I immediately noticed that the P&L did not reconcile, and that is
>> apparently because of rounding to 4 decimal places on prices
>> downloaded using RBloomberg.
>> The instruments I am looking at trade in 1/32nds and 1/64ths (+), and
>> the 1/64ths are not 4 decimals long -- my prices are essentially
>> getting truncated.
>> Has anyone dealt with this issue successfully before? I am looking
>> for a way to preserve the integrity of the price downloaded using
>> All the code needed to reproduce this is below, thanks.
>> > sessionInfo()R version 2.14.1 (2011-12-22)
>> Platform: x86_64-pc-mingw32/x64 (64-bit)
>>  LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>> States.1252 LC_MONETARY=English_United States.1252
>>  LC_NUMERIC=C LC_TIME=English_United
>> attached base packages:
>>  stats graphics grDevices utils datasets methods base
>> other attached packages:
>>  quantstrat_0.6.1 blotter_0.8.4
>> stringr_0.6 timeDate_2131.00
>>  PerformanceAnalytics_22.214.171.124 RODBC_1.3-4
>> RBloomberg_0.4-150 rJava_0.9-3
>>  FinancialInstrument_0.11.3 quantmod_0.3-17
>> TTR_0.21-0 xts_0.8-4
>>  zoo_1.7-7 Defaults_1.1-1
>> loaded via a namespace (and not attached):
>>  grid_2.14.1 lattice_0.20-0 plyr_1.7.1 tools_2.14.1
>> > start_date "20110922"> end_date "20120319"> myInst$identifiers$BB "USM2 Comdty"
>> > FLDS <- c("PX_OPEN","PX_HIGH","PX_LOW","PX_LAST")> > rs = bdh(conn,myInst$identifiers$BB,FLDS, start_date = start_date , end_date = end_date)
>> 2012-03-15 2012-03-15 136.7812 137.0000 135.5625 136.5312
>> 2012-03-16 2012-03-16 136.4688 136.6250 135.4688 136.4375
>> 2012-03-19 2012-03-19 136.4375 137.0000 136.1250 136.8438
>> Don't quit. Suffer now and live the rest of your life as a champion.
>> - Muhammad Ali
>> [[alternative HTML version deleted]]
>> R-SIG-Finance at r-project.org mailing list
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.
> Brian G. Peterson
> Ph: 773-459-4973
> IM: bgpbraverock
> R-SIG-Finance at r-project.org mailing list
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
More information about the R-SIG-Finance