I have a mostly general question.
I have a Bloomberg Terminal, I have different portfolios I created in it. So, I know their names.
I want to get from Bloomberg PORT information like:
Total return for different periods.
Attributions for different periods.
I'm trying to use 'Rblpapi' package for this, but I can't understand how to get the information I need through this package.
So, is it possible to get this information through 'Rblpapi' or not? If not, what package should I use for this?
Thank you.
I have a rather simple question that I can't seem to find an answer for.
I essentially want to know if there is code that provide a status for the code we are running. As an example, I am running code that usually takes time and would like to know if the job is 25%-50%-75% complete. This is the kind of features we get with Software from large companies ($$).
Does anyone use anything when working with R?
I use Rstudio if this is pertinent.
Thanks
After using Quantstrat to successfully backtest a strategy, is there any way to use the same signal/indicator/rule code to generate orders for production trading?
It seems like this might be possible by using the order book, but I haven't been able to find any examples or demos that explain how to generate orders for the future using data up to the present time.
Any pointers or advice on how to accomplish this would be appreciated.
It's theoretically possible, but why would you want to? quantstrat is designed to make it easier to test ideas quickly and accurately. That's a very different problem domain than production trading. In short, use the right tool for the job.
If you really want to go this route, you would need to:
update your mktdata object for each new piece of relevant market data you receive,
run applyIndicators, applySignals, and applyRules on the necessary subset,
write a new ruleOrderProc (and maybe ruleSignal) to send orders to your broker.
I use the market QA data base and I would like to be able to access the data directly from R or vba or even another language if needed to pursue my studies. I couldn't find any API, has anyone here already done this before?
Thanks
The 'tm' package has some worked examples. You may need to be more specific about what or of data you are targeting.
I have several custom functions that I use frequently in R. Rather than souce this file (or parts thereof) in each script, is there some way to add this to a base R file such that they are always available when I use R?
Yes, create a package. There are numerous tutorials as well as the Writing R Extensions manual that came with your copy of R.
It may seem like too much work at first, but you will probably be glad that you did this in the longer run.
PS And you can then load that package from ~/.Rprofile. For really short code, you can also define it there.
A package may be overkill for a for a few useful functions. I'd argue there's nothing wrong with explicitly source()ing them as you need them - at least it is explicit so that if you email someone your code, you won't forget to include those other scripts.
Another option is to use the .Rprofile file. You can read about the details in ?Startup. Basically, the idea is that:
...a file called ‘.Rprofile’ is searched for in the current directory or
in the user's home directory (in that order). The user profile file is
sourced into the workspace.
You can read here about how many people use this functionality.
The accepted answer is best long-term: Make a package.
Luckily, the learning curve for doing this has been dramatically reduced by the devtools package: It automates package creation (a nice assist in getting off on the right foot), encourages good practices (like documenting with roxygen2, and helps with using online version control (bitbucket, github or other), sharing your package with others. It's also very helpful for smoothing your way to CRAN submission.
Good docs at http://adv-r.had.co.nz and http://r-pkgs.had.co.nz .
to create your package, for instance you can:
install.packages("devtools")
devtools::create("path/to/package/pkgname")
You could also look at the 'mvbutils' package: it lets you set up a hierarchical set of "tasks" (folders with workspace ".RData" files in them) such that you can always see what's in the ancestral tasks (ie the ancestors are in the search() path). So you can put your custom functions in the "starting task" where you always start R; and then you change to vwhatever project-specific task you require, so you can avoid cluttered workspaces, but you'll still be able to use (and edit) your custom functions because the starting task is always ancestral. Objects (including functions) get stored in ".RData" files and are thus loaded/saved automatically, but there are separate text-backup facilities for functions.
There are lots of different ways of working in R, and no "one-size-fits-all" best solution. It's also not easy to find an overview! Speaking just for myself:
I'm not a fan of having to 'source' everything in every time; for one thing, it simply doesn't work with big data sets and/or results of model runs.
I think packages are hard to create and maintain; there is a really significant overhead. After the first 5 packages you write, it does get a bit easier provided you do it on at least a weekly basis so you don't forget how, but really...
In fact, 'mvbutils' also has a bunch of tools for facilitating the creation and (especially) maintenance of packages, designed to interface smoothly with the task-hierarchy system. I use & edit my own packages all the time (including editing mvbutils itself); but if it wasn't for the tools in 'mvbutils', I'd be grinding my teeth in frustration most days of the week.