Comments (10)
"Individual pair returns" takes too long to render
from pairs.
the code for "individual pair returns":
backtest_ordered_pair_returns_table<-data.table(
pm=structure(hdr="{\\bf PM}",paste0("{\\bf ",the_pairs,"}")),
do.call(data.table,mapply(function(i)structure(
hdr=tbl(
c(
stri_sub(weekdays(as.Date(i)),1,3),
stri_sub(i,6,-1)
),
align="@{}c@{}"
),
mapply(function(p){
if(FALSE)cat(p,":",i,"\n")
the_day<-i
if(is.na(the_day))return(0)
ndx<-bar_intervals$date==the_day & bar_intervals$day>0
if(sum(ndx)<1){
res<-make_plot(expression({
plot(NA,type="n",xlab="",ylab="",xlim=c(0,1),ylim=c(0,1),axes=FALSE)
text(0.5,0.5,labels="No data",cex=5)
}),width="2cm",height="2cm")
return(res)
}
pnls<-mc(intraday_pair,paste0("^",p))[ndx,,drop=FALSE]
cum_pnls<-apply(pnls,2,cumsum)
xlim<-c(1,nrow(pnls))
ylim<-c(min(cum_pnls),max(cum_pnls))
rr<-colorRamp(c("white","red"))
gr<-colorRamp(c("white","green"))
x<-as.vector(row(cum_pnls))
y<-as.vector(cum_pnls)
up_col<-if(all(pmax(y,0)<1e-10)){
rep(rgb(1,1,1),length(y))
} else rgb(gr(pmax(y,0)/max(y))/255)
dn_col<-if(all(pmin(y,0)>(-1e-10))){
rep(rgb(1,1,1),length(y))
} else rgb(rr(pmin(y,0)/min(y))/255)
max_pnl<-max(cum_pnls)
min_pnl<-min(cum_pnls)
max_name<-colnames(cum_pnls)[which(cum_pnls==max_pnl,arr.ind = TRUE)[1,2]]
max_text<-paste0(max_name," : ",ifelse(max_pnl>0,"+","-"),round(10000*abs(max_pnl),digits=1))
min_name<-colnames(cum_pnls)[which(cum_pnls==min_pnl,arr.ind = TRUE)[1,2]]
min_text<-paste0(min_name," : ",ifelse(min_pnl>0,"+","-"),round(10000*abs(min_pnl),digits=1))
make_plot(expression({
par(mai=c(0,0,0,0))
plot(
x=xlim,
y=ylim,
type="n",
xlab="",
ylab="",
axes=FALSE
)
points(
x=x,
y=y,
col=ifelse(y>0,up_col,dn_col),
cex=2,
pch=19
)
abline(h=0,col=rgb(0,0,1,0.5),lwd=10)
text(
x=mean(xlim),
y=mean(ylim),
labels=paste0(max_text,"\n",min_text),
col="black",
font=2,
cex=5
)
}),width="2cm",height="2cm",envir=environment())
},p=the_pairs)
),days_in_data,SIMPLIFY=FALSE))
)
a1<-c("m{1cm}",rep("@{}|@{}m{2cm}",ncol(backtest_ordered_pair_returns_table)-1))
from pairs.
and the Latex:
\newpage
\section{Individual pair returns}
\vskip 5mm
\noindent The cross-section of daily pair returns allows us to distinguish between specific and
systematic P\&L drivers. This grid plot shows P\&L contributions from individual pairs at 10-minute
intervals. The pairs with the highest gains and losses are displayed in the center of each plot.
\vskip 10mm
\begin{center}
\Sexpr{ntable(
backtest_ordered_pair_returns_table,
add_rownames=FALSE,
title=paste0(
"Pairs contributions, ",
"color-coded by P\\&L ",
"(",dot("green"),") positive",
"(",dot("red"),") negative"
),
scale=0.75,
alternating=FALSE,
align=a1,
halign="c",
row_end="\\hline\\\\[-7mm]"
)}
\end{center}
from pairs.
removing these worked fine
from pairs.
"Short-term vs long term volatility, correlation, hedge efficiency ranks" is not really useful
from pairs.
from pairs.
from pairs.
from pairs.
from pairs.
from pairs.
Related Issues (20)
- the GMV portfolio HOT 4
- pair_risk_contribution report is out of date HOT 9
- ABC: can we add implied vols or credit spreads as measures of market risk? HOT 1
- pair_risk_contribution_new: sector gross looks wrong HOT 1
- the cross product
- custom PM report HOT 3
- loading "all results" is a really bad idea HOT 1
- intraday.csv is 25mb, too large to push to git HOT 3
- 2 year correlation looks wrong HOT 1
- CIX uploads dont work HOT 4
- AC112 has no single stock positions
- pair look-through matrix has more pairs than pair P&L matrix HOT 9
- pair ACTW7 has exposure but is not in duke_pair_look_vs_outright HOT 4
- CIX uploads do not work HOT 7
- AC's position is the sum of AC and ACTW. needs to be fixed.
- James Rodgers requests
- The fund pair risk contribution table
- The correlation of my portfolio to markets
- the correlation of my pairs to one another in an easy to read format
- the look-through exposures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pairs.