R - Shiny application to analyse blotter strategies/portfolios - Matlab, R project and Python | futures io social day trading
futures io futures trading


R - Shiny application to analyse blotter strategies/portfolios
Updated: Views / Replies:3,506 / 10
Created: by volemont Attachments:6

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 6  
 
Thread Tools Search this Thread
 

R - Shiny application to analyse blotter strategies/portfolios

  #1 (permalink)
Elite Member
Zurich, Switzerland
 
Futures Experience: Intermediate
Platform: R, C#
Favorite Futures: Futures
 
Posts: 53 since Dec 2013
Thanks: 73 given, 71 received

R - Shiny application to analyse blotter strategies/portfolios

Hi,

I'm using shiny and the R blotter project https://r-forge.r-project.org/projects/blotter/ as an analysis platform. My strategies are written in C# (RightEdge) and every night the trades are written out to csv's and picked up by R. Blotter accounts and portfolios are automatically created and loaded by the shiny app. Attached are some screen shots and the code is hosted on GitHub https://github.com/volemont/insights

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.
 
Code
# process transactions
for(i in 1 : nrow(execs))
  addTxn(ptfName, Symbol=execs$Symbol[i], TxnDate=execs$Transaction.Date[i],
         TxnQty=execs$Shares[i], TxnPrice=execs$Price[i], TxnFees=0)


tldr; git clone https://github.com/volemont/insights


Attached Thumbnails
R - Shiny application to analyse blotter strategies/portfolios-ss1.png   R - Shiny application to analyse blotter strategies/portfolios-ss2.png   R - Shiny application to analyse blotter strategies/portfolios-ss3.png   R - Shiny application to analyse blotter strategies/portfolios-ss4.png   R - Shiny application to analyse blotter strategies/portfolios-ss5.png  
Reply With Quote
The following 12 users say Thank You to volemont for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,356 given, 83,237 received


Awesome, thanks!

I will work to incorporate this into my platform soon.

Mike

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.

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Leeds, United kingdom
 
Futures Experience: Beginner
Platform: R, multicharts
Favorite Futures: Commodities
 
Posts: 2 since Dec 2014
Thanks: 2 given, 0 received

Mark trades with "buy/sell" instead of small triangles

Dear Simon,

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.

Thank you very much!

Kenny

Reply With Quote
 
  #5 (permalink)
Elite Member
Zurich, Switzerland
 
Futures Experience: Intermediate
Platform: R, C#
Favorite Futures: Futures
 
Posts: 53 since Dec 2013
Thanks: 73 given, 71 received

Hi Kenny,

The easiest way is to copy the chart.Posn function https://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/chart.Posn.R?view=markup&root=blotter and change the following two lines

 
Code
    if(!is.null(nrow(Buys)) && nrow(Buys) >=1 ) (add_TA(Buys,pch=2,type='p',col='green', on=1));
    if(!is.null(nrow(Sells)) && nrow(Sells) >= 1) (add_TA(Sells,pch=6,type='p',col='red', on=1));
You want to change the 'pch' argument to pch="B", pch="S" or any other symbol, see R Plot PCH Symbols -- EndMemo

Simon

Reply With Quote
The following user says Thank You to volemont for this post:
 
  #6 (permalink)
Trading Apprentice
Leeds, United kingdom
 
Futures Experience: Beginner
Platform: R, multicharts
Favorite Futures: Commodities
 
Posts: 2 since Dec 2014
Thanks: 2 given, 0 received

Dear Simon,

Thanks a lot!

This sounds very helpful, I will look into them.

Kenny

Reply With Quote
 
  #7 (permalink)
Trading Apprentice
Boston MA/USA
 
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: stocks
 
Posts: 4 since Feb 2015
Thanks: 0 given, 3 received

very nice system!

Hi,
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?

Thanks a lot, I'll play with this tonight!

Reply With Quote
 
  #8 (permalink)
Trading Apprentice
Boston MA/USA
 
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: stocks
 
Posts: 4 since Feb 2015
Thanks: 0 given, 3 received

Problem running demo app - error in Match.fun

Hi,
I'm trying to run the ''R - Shiny application to analyse blotter strategies/portfolios'' that you made available on github.

I have a fresh install of R with Rstudio, installed all required package (I assume so!). All I've done is set working directory to where the repository is, and click on 'run app' on the main.R file.

I'm getting the following error:
Error in match.fun(FUN) : object 'loadInstruments' not found

*Edit: here is more info on the error I get:

> setwd("C:/insights-master")
> shiny::runApp()
Loading required package: shiny
Hide Traceback

Rerun with Debug
Error in match.fun(FUN) : object 'loadInstruments' not found
10 match.fun(FUN)
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"))
2 appParts$onStart()
1 shiny::runApp()

*End Edit

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!

Thanks,
Dave


Last edited by gretzteam; February 13th, 2015 at 01:03 PM. Reason: Add error information
Reply With Quote
 
  #9 (permalink)
Trading Apprentice
Boston MA/USA
 
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: stocks
 
Posts: 4 since Feb 2015
Thanks: 0 given, 3 received

Blank ''Trade Chart'' and ''Equity Curve'' tabs

Hi,
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.

Reply With Quote
The following user says Thank You to gretzteam for this post:
 
  #10 (permalink)
Trading Apprentice
Boston MA/USA
 
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: stocks
 
Posts: 4 since Feb 2015
Thanks: 0 given, 3 received

Trade Chart and Equitiy curve Fixed!


Hi,
I dug deeper into this and found that the problem was due to the newer version of shiny.
See here:

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:
class="panel panel-default"

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'

thanks,
Dave

Reply With Quote
The following 2 users say Thank You to gretzteam for this post:

Reply



futures io > > > > R - Shiny application to analyse blotter strategies/portfolios

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Analyse CAC40 par Anas AnasParis French Traders 2244 August 9th, 2014 08:53 AM
Big Investors Redo Portfolios —Should You Do the Same? Quick Summary News and Current Events 0 November 15th, 2011 04:50 PM
Proving trade legitimacy through a blotter or other way josh Traders Hideout 43 April 4th, 2011 02:46 PM
Is there a way to analyse individual candle? Al2010 NinjaTrader Programming 3 December 4th, 2010 11:58 AM
IB: Analyse Statements Henrik Beginners and Introductions 4 March 12th, 2010 07:29 PM


All times are GMT -4. The time now is 02:55 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.13 seconds with 20 queries on phoenix via your IP 54.163.209.109