An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20111228/1be7fbd6/attachment.pl>
Mulitple FI Sources
5 messages · Mark Harrison, Brian G. Peterson, varcovar
With a little work, you could get things working for different symbols to come from different data sources. Others have been able to make this work, though I haven't done it. We've talked about exposing functionality to make it easier to specify data source *by symbol* by looking at data source properties stored with each instrument. However, we've never contemplated having different data sources for the same symbol. Patches Welcome. Regards, - Brian
On Wed, 2011-12-28 at 14:37 -0600, Mark Harrison wrote:
I am using R and RStudio versions 2.13.1 and 0.94.106 respectively.
I am using Financial Instrument and everything is working for a single data
source. I have my Rprofile file setup to load packages, define my
instruments, and set my symbol lookup souce.
# packages to load at startup
library(quantmod)
library(fTrading)
# currencies defined
currency("USD")
currency("GBP")
# now exchange rates
# British Pound Rates
exchange_rate("GBPUSD","GBP","USD")
# Set symbol lookups
setSymbolLookup.FI("HistFX", storage_method="rda")
Once I start R or RStudio everything loads and I can run the following and
everything works:
getSymbols.FI("GBPUSD")
This all works for a single data source but I have multiple data sources or
data sets that I would like to access and would like to put everything in
my RProfile but I have yet to figure out how to make it work.
For example, I have a series of historical data files that I got from a
vendor who is not my broker. So I want to keep my historical data files
separate in one directory 'HistFX' and any data I get from my broker in a
separate folder called 'Broker' for example.
So the directories might look like:
C:\Documents\HistFX\GBPUSD
C:\Documents\Broker\GBPUSD
I tried adding multiple lines to my RProfile with for each source but it
looks like the last line read in is the 'live' one. I even tried adding
'src=' to try and distinguish one from the other
setSymbolLookup.FI("HistFX", storage_method="rda")
setSymbolLookup.FI("Broker", storage_method="rda")
setSymbolLookup.FI("HistFX", storage_method="rda", src="hist")
setSymbolLookup.FI("Broker", storage_method="rda", src='broker")
I realize the simplest solution would be to just add a setSymbolLookup.FI
command to any script I use pointing to the data I want to use - i.e.
historical or broker - but like I said I was trying to do this in the
RProfile.
Any help would be appreciated.
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- 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 http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock
Here is my 2 cents on a way to access the same symbols from multiple sources
and time frames. Instead of using the setSymbolLookup.FI() and
getSymbols.FI() functions, why not creating custom functions based on the
getSymbols() structure to access those data: getSymbols.src1(),
getSymbols.src2(), getSymbols.src3()...
Basically, data are stored in different folders, with different format and
all the formating job is done inside each function. It eventually looks like
something like that:
## Define instruments (or load instruments)
currency("USD")
future("GC", "USD", multiplier = 10, tick_size = 0.1)
future_series("GC_G00")
## get Gold Feb 2000 contract daily data from src1
getSymbols.src1("GC_G00")
## get Gold Feb 2000 contract daily data from high frequency data from src2
getSymbols.src2("GC_G00", start_time = "09:30", end_time = "15:59", period =
"days", k = 1)
--
View this message in context: http://r.789695.n4.nabble.com/Mulitple-FI-Sources-tp4240947p4241860.html
Sent from the Rmetrics mailing list archive at Nabble.com.
On Wed, 2011-12-28 at 20:54 -0800, varcovar wrote:
Here is my 2 cents on a way to access the same symbols from multiple sources
and time frames. Instead of using the setSymbolLookup.FI() and
getSymbols.FI() functions, why not creating custom functions based on the
getSymbols() structure to access those data: getSymbols.src1(),
getSymbols.src2(), getSymbols.src3()...
Basically, data are stored in different folders, with different format and
all the formating job is done inside each function. It eventually looks like
something like that:
## Define instruments (or load instruments)
currency("USD")
future("GC", "USD", multiplier = 10, tick_size = 0.1)
future_series("GC_G00")
## get Gold Feb 2000 contract daily data from src1
getSymbols.src1("GC_G00")
## get Gold Feb 2000 contract daily data from high frequency data from src2
getSymbols.src2("GC_G00", start_time = "09:30", end_time = "15:59", period =
"days", k = 1)
You can also call getSymbols.FI or getSymbols.rda or getSymbols.csv with the 'dir' argument. This may avoid writing custom functions.
Brian
Hi Brian, Thanks for the tips. I actually tried that first, but one of my data sources provides tick data and I wanted the conversion to a lower frequency to be done inside the function - I don't know how to do it without writing a custom function. -- View this message in context: http://r.789695.n4.nabble.com/Mulitple-FI-Sources-tp4240947p4242660.html Sent from the Rmetrics mailing list archive at Nabble.com.