The code has been tested with quantstrat's faber and bbands demo on a fresh R installation using RStudio. The demos are committed and saved in the ./data directory. To get started open main.R and run the code. Please update your packages first if something doesn't work.
To process your trades you'll have to write a script or adapt https://github.com/volemont/insights/R/RightEdgeToBlotter.R The important piece of code to process the transactions for the blotter portfolio is below. The required fields for each transaction are the symbol, date/time, quantity and the price. Export the data from your favourite platform or the broker. Make sure to use the same data source in R as you use for modelling/trading or the prices might not match and thus the resulting portfolio won't be correct.
I will work to incorporate this into my platform soon.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
Mark trades with "buy/sell" instead of small triangles
Thanks for the sharing of your codes. The way you make use of shiny and blotter in trading analysis is powerful. This is exactly what I want to do on my own. So, I am glad to find your code and I will study and learn from your codes.
At this moment, I am wondering whether you can shed some light on how to replace the green up-triangle and red down-triangle (which represent buying and selling trades by chart.Posn function, and the problem is that they are too small and not informative enough) with short texts like "B1", "B2"... "S1" .."LX"...(which are more informative)
I am looking forward to read more of your sharing on using shiny to display and automate the visualization of trades.
This is really cool! I have been poking with the idea of making my own portfolio tracker 'app', which is a very similar problem than what you solved, except the transactions come from the .csv file I export from my broker's statement.
You'll ask: why not use your broker's built in analysis? Well they typically suck. Sometimes you want to ignore a transaction you made etc...The best portfolio tracker I found was the morningstar portfolio, but still, I'd like it to show me more performance metrics.
Making my own seems like the way to go, and you pretty much just gave me working code to do so!
One question on shiny: how limited is it? Say I wanted to have a table with all the stock in the current portfolio, showing the daily % price change, the $ change for each in the portfolio etc..and have that automatically refresh every 1 min. Is this a doable task or I'm already hitting a wall?
Rerun with Debug
Error in match.fun(FUN) : object 'loadInstruments' not found
9 sapply(files, loadInstruments) at loadInstrumentsEnvs.R#15
8 loadInstrumentsEnvs("./data", pattern = "Instr") at global.R#10
7 eval(expr, envir, enclos)
6 eval(ei, envir)
5 withVisible(eval(ei, envir))
4 source(file, ..., keep.source = TRUE, encoding = checkEncoding(file))
3 sourceUTF8(file.path.ci(appDir, "global.R"))
I'm new to R so not sure if this is a stupid problem, or if I have to do something else before trying the app out. And pointers would be useful ( I assume that the without any modification the app would grab data (transactions) from one of the provided example file and just run as is, maybe I'm supposed to do something else for this to work?)
Thanks for the support, looking forward to trying this out!
Last edited by gretzteam; February 13th, 2015 at 12:03 PM.
Reason: Add error information
You can disregard my previous post - managed to get this to launch properly. It was obviously something basic - didn't know you had to manually load packages in R. After loading 'blotter', I can get the shiny GUI to launch.
However, I only see stuff on the ''Trade Stats'' and ''Per Trade Stats'' tabs. Nothing on the ''Trade Chart'' and ''Equity Curve''. Could there be a missing packages for the plotting? I do not get any more errors, just blank tabs.
Thanks for any pointers.
The following user says Thank You to gretzteam for this post:
I dug deeper into this and found that the problem was due to the newer version of shiny.
Edit: can't post link yet before # of posts under 5. The issue is documented on the github of rstudio/shiny, issue number 701. But essentially:
''Because of the change to Bootstrap 3, the class that should be used has changed to "panel panel-default".''
If you change line 8 and 133 of ui.R so that the absolutePanel class is now:
you will now be able to select a portfolio an account/portfolio/symbol and the chart will then be displayed.
I also submitted this as an issue on the github of 'insights'
The following 2 users say Thank You to gretzteam for this post: