Wednesday, June 15, 2016
Friday, February 12, 2016
putty ssh X11 forwarding not working?
have you installed xorg-x11-xauth at the server? (Thanks to http://praveen.kumar.in/2006/11/15/xorg-x11-xauth-needed-for-ssh-x-forwarding-to-work/)
how to allow remote server to access my local resource via ssh tunnel?
Sunday, January 31, 2016
How to install additional kernel to ipython / jupyter?
Assuming you already have python 3 and ipython installed with anaconda,
Create python 2.7 env
$ conda create -n py27 python=2.7
Activate the env
$ source activate py27
Install ipykernel
$ conda install notebook ipykernel
Write kernel spec
$ ipython kernelspec install-self --user
which should write to ~/.local/share/jupyter/kernels/python2
Deactivate 2.7 env
$ source deactivate
link the kernel spec to the location where ipython will read
$ cd ~/.ipython/
$ ln -s ~/.local/share/jupyter/kernels/
Confirm now that we have additional kernel
$ ipython kernelspec list
Start ipython notebook and you should now have both kernels
$ ipython notebook --no-browser
Create python 2.7 env
$ conda create -n py27 python=2.7
Activate the env
$ source activate py27
Install ipykernel
$ conda install notebook ipykernel
Write kernel spec
$ ipython kernelspec install-self --user
which should write to ~/.local/share/jupyter/kernels/python2
Deactivate 2.7 env
$ source deactivate
link the kernel spec to the location where ipython will read
$ cd ~/.ipython/
$ ln -s ~/.local/share/jupyter/kernels/
Confirm now that we have additional kernel
$ ipython kernelspec list
Start ipython notebook and you should now have both kernels
$ ipython notebook --no-browser
Wednesday, December 23, 2015
How to interpret Beta?
How to interpret beta?
sensitivity of the expected excess asset returns, E(Ri) - Rf, to the expected excess market returns, E(Rm) - Rfso, beta = (E(Ri) - Rf) / (E(Rm) - Rf)
in other words, beta tells u how many times your instrument should return above rfr given the market return above rfr
say the market return = 5%, rfr = 2%, and your stock has a 1.5 beta
beta tells you that your instrument should be getting 6.5% return
if your instrument returns above 6.5%, ALPHA!! :D
if below, then why are u investing in that instrument rather than the market portfolio?
how to calculate beta?
Cov(Ri, Rm)/Var(Rm)= (corr(Ri, Rm) * sigma i * sigma m) / (sigma m)^2
= corr(Ri, Rm) * sigma i / sigma m
putting in back to capm
Ri = rfr + beta * (Rm - rfr)
Ri - rfr = corr(Ri, Rm) * sigma i * (Rm-rfr)/sigma m
(Ri -rfr) /sigma i = corr(Ri, Rm) * (Rm-rfr)/sigma m
now we can interpret the corr(Ri, Rm) as
the ratio between sharpe ratio of the instrument and the sharpe ratio of the market
what is variance?
avg squared deviation from mean
= E[(X-E[X])^2]
can also be thought of as the covariance with itself
= Cov(X,X)
= E[(X-E[X])(X-E[X])]
which brings us to the covariance of 2 diff variables
Cov(X,Y)
= E[(X-E[X])(Y-E[Y])]
Tuesday, December 8, 2015
setup linux vm in 64-bit Windows host without installation
Download binary from lassauge.free.fr/qemu and extract
Create a 40G hard disk by running
qemu-img create hd.img 40G
Install by Linux os with
qemu-system-x86_64 \
-drive file=hd.img,index=0,media=disk,format=raw \
-L Bios -m 1024 \
-cdrom fedora-install.iso
Start your vm with ssh port forwarded with
qemu-system-x86_64 \
-drive file=hd.img,index=0,media=disk,format=raw \
-L Bios -m 1024 \
-redirect tcp:2222::22
ssh -p 2222 localhost
to get to your vm
Create a 40G hard disk by running
qemu-img create hd.img 40G
Install by Linux os with
qemu-system-x86_64 \
-drive file=hd.img,index=0,media=disk,format=raw \
-L Bios -m 1024 \
-cdrom fedora-install.iso
Start your vm with ssh port forwarded with
qemu-system-x86_64 \
-drive file=hd.img,index=0,media=disk,format=raw \
-L Bios -m 1024 \
-redirect tcp:2222::22
ssh -p 2222 localhost
to get to your vm
Tuesday, November 24, 2015
Excel color scheme css
body
{
font-family:Verdana;
font-size:small;
}
table,td,th
{
border-color:#95B3D7 white;
border-collapse:collapse;
font-size:small;
}
th
{
background-color:#DBE5F1;
color:black;
padding:5px;
}
td
{
text-align:right;
padding:5px;
}
td.left
{
text-align:left;
padding:5px;
}
{
font-family:Verdana;
font-size:small;
}
table,td,th
{
border-color:#95B3D7 white;
border-collapse:collapse;
font-size:small;
}
th
{
background-color:#DBE5F1;
color:black;
padding:5px;
}
td
{
text-align:right;
padding:5px;
}
td.left
{
text-align:left;
padding:5px;
}
Tuesday, November 17, 2015
python pandas groupby agg percentiles?
use the ways as described in stackoverflow from google search
or
simply use describe:
df.groupby([col1, col2]).describe(percentiles=[.75, .95])
Optionally, you may wanna have the aggregated value display horizontally and round the numbers by appending:
df.groupby([col1, col2]).describe(percentiles=[.75, .95]).unstack().apply(lambda x:np.round(x,0))
or
simply use describe:
df.groupby([col1, col2]).describe(percentiles=[.75, .95])
Optionally, you may wanna have the aggregated value display horizontally and round the numbers by appending:
df.groupby([col1, col2]).describe(percentiles=[.75, .95]).unstack().apply(lambda x:np.round(x,0))
Subscribe to:
Posts (Atom)