Not much finance here, but a lot of d3 and R.
Friday, September 27, 2013
Wednesday, September 25, 2013
Ode to Systematic Clusters
Extending the d3 remixes of the fine work at Systematic Investor, I thought it woud be fun to do some dimple.js and nvd3 scatterplots of clusters of PIMCO mutual funds. As always, I welcome thoughts, comments, and suggestions. Click here or on the screenshot below.
Thursday, September 19, 2013
Genetics to Finance - Amazed By Open Source d3 and r
Open source amazes me by the speed of distribution and the power of iteration. Take for example the very fine combination of R and d3 provided here at http://www.biostat.wisc.edu/~kbroman/D3/. The correlation matrix with scatterplot instantly struck me as a wonderful way to liven up Pretty Correlation Map of PIMCO Funds. Since it is open and MIT licensed, within an hour I was able to come up with this.
Please take it and make it even better. Thanks so much to Karl Broman for this great work.
Thursday, September 12, 2013
rCharts | PerformanceAnalytics Tables + Systematic Investor Cluster
I thought a good extension of the last post d3-ify Systematic Investor Cluster Weight would be to analyze the returns with every table that PerformanceAnalytics offers. Since d3 interactive charts are way more fun than tables, let’s plot each table with dimplejs and rCharts. Click here or on the screenshot below to see the result.
Monday, September 9, 2013
d3-ify Systematic Investor Cluster Weight
I have posted before about the brilliant R/finance work being done at Systematic Investor. I just had to see what his cluster work would look like with d3 interactivity. Click on the screenshot below or here to see an interactive recreation of his post.
Wednesday, August 28, 2013
Applications of Interactivity to Finance
Of the nearly infinite ways of using crossfilter and dc.js in finance, the 2 that immediately came to my mind are signal analysis in system building and money manager analysis in due diligence. My first very basic experiment explores a commonly known signal (RSI) on the daily S&P 500 since 1950. Interactivity adds a lot to the experience. I used R to grab and reshape the data and slidify to make it pretty. Check it out by clicking here or on the screenshot below.
For another very fine example of dc.js and crossfilter in use with AAII Stockpicking strategy data, see this fine site.
Wednesday, August 14, 2013
gridSVG Multi-line Data Bind with d3–US Treasury Yields
If you have not read the other posts on gridSVG and d3, I recommend reading those before progressing to this one.
Facets or strips are one of my favorite features of lattice and ggplot2, so of course I want to extend our d3 reverse data bind to support these small multiples. Let’s see one way of accomplishing this. For a short explanation of the process, click here or on the screenshot below. If you just like yield curve data, I think you will enjoy the graph which I have embedded below.
Tuesday, August 13, 2013
Stocks and Bonds Behavior by Decade
I struggled with whether or not I should even post this. It is raw and ugly, but it might help somebody out there. I might use this as a basis for some more gridSVG posts, but I do not think I have the motivation to finish the analysis.
Code:
require(latticeExtra)
require(quantmod)
require(PerformanceAnalytics)
getSymbols("SP500",src="FRED")
US10 <- na.omit(getSymbols("DGS10",src="FRED",auto.assign=FALSE))
stocksBonds <- na.omit(
merge(
lag(SP500,k=-100)/SP500-1, #forward 100 day sp500 perf
US10 / runMean(US10,n=250) - 1, #us10 yield - 250 day average
SP500
)
)
#get the decade
stocksBonds$decade = as.numeric(substr(index(stocksBonds),1,3)) * 10
#name columns
colnames(stocksBonds) <- c("sp500","us10","SP500","decade")
#get a color ramp for our change in us10 year yields
linecolors <- colorRamp(
c("red","green"),
interpolate="linear",
space="rgb"
)((stocksBonds[,2]+0.5))
xyplot(
stocksBonds[,1],
col=rgb(linecolors,max=255),
type="p",pch=19,cex=0.5,
main = "Stocks 100d Forward Performance"
)
xyplot(
sp500 ~ us10 | factor(decade),
groups = decade,
data = as.data.frame(stocksBonds),
pch=19,
cex = 0.5,
scales = list(
x = list(tck=c(1,0),alternating=1)
),
layout=c(6,1),
main = "S&P 500 Forward Performance vs US 10y Change in Yields",
ylab = "S&P Forward Performance (100d)",
xlab = "US 10y Yields - 250d Avg"
) +
latticeExtra::layer(panel.abline(h=0,col="gray",lty=2)) +
latticeExtra::layer(panel.abline(v=0,col="gray",lty=2)) +
xyplot(
sp500 ~ us10 | factor(decade),
col="gray",
data = as.data.frame(stocksBonds),
panel = panel.lmline)
require(ggplot2)
ggplot(data = data.frame(stocksBonds), aes(y=sp500, x= us10,colour=decade))+
geom_point()+facet_wrap(~decade,ncol=6)+geom_smooth()
charts.PerformanceSummary(
merge(
ROC(stocksBonds[,3],n=1,type="discrete"),
ROC(stocksBonds[,3],n=1,type="discrete") * (stocksBonds[,2]>0)
),
main="S&P 500 | if Bonds - Mean(250d) > 0"
)
Friday, August 9, 2013
PIMCO Rolling Correlation, d3, R, gridSVG, lattice | Gets An Axis
Where else will you hear Pimco, rolling correlation, R, gridSVG, lattice, and d3 all in one post? Let’s mix them all together to see what might happen. For those here for the geekery, we will add a d3 axis for our y and it will follow the mouse. For those who care nothing about d3 and R, you might like the chart too since it plots the 90 day rolling correlation between Pimco Total Return and Pimco All Asset Authority . Click here if or on the screenshot below. to see the live version.
At some point I will find the limits of my creativity and knowledge. Please give me some ideas.
Thursday, August 8, 2013
R/gridSVG/d3 Line Reverse Data Bind
I veer from finance to tech, so let’s use some data from FRED/OECD this time. I do not think I need to comment much on what has happened to New Car Registrations in Greece.
Reverse data binding a line plot from ggplot2 or lattice is slightly more difficult than what we saw in the last post I Want ggplot2/lattice and d3 (gridSVG–The Glue). Here is a quick tutorial on one way we can accomplish this. Click on this link or the screenshot below.
As always, this is fully reproducible. See the code on Github.