Monday 23 January 2017

FX Delta

In FX world, we have a delta similar greek to measure foreign exposure - PnL change for a shift of 1% of the spot for outstanding foreign positions. Which turn out nothing but the discounted notional, below is the derivation. $$F = S * e^{r_f - r_d}$$ $$F * N = S * e^{r_f - r_d} * N $$ $$FX-Delta = \frac{\partial F}{\partial S} = \frac{(S * 1.01 - S) * e^{r_f - r_d} * N}{S * 1.01 - S} = e^{r_f - r_d} * N$$

Thursday 20 October 2016

Syntax Highlighter & Latex Interpretor for Crazy Quant

What I have used for this blogger:

Highlight.js

You can either put into seperate files:

<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
Or you can use the CDNs:

<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/tomorrow-night-blue.min.css' rel='stylesheet'/>
<script src='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js'/>
<script>hljs.initHighlightingOnLoad();</script>

Mathjax

You can always find out more from here, to start with, you can use below:

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
    extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"] ],
        displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    },
    "HTML-CSS": { availableFonts: ["TeX"] }
});
</script> 

Wednesday 18 June 2014

Calculate mean square limit of Brownian motion - 4th moment of normal distribution

An example interpreting the mean square limit of a brownian motion.
Assumption: X(t) follows a brownian motion.

Examine the quantity:
$$E[(\sum_{j=1}^{n}(X(t_j)-X(t_{j-1}))-t)^2]$$
This can be expanded as:
$$E[\sum_{j=1}^{n}(X(t_j)-X(t_{j-1}))^4+\sum_{i=1}^{n}\sum_{i\neq j}(X(t_i)-X(t_{i-1}))^2(X(t_j)-X(t_{j-1}))^2$$ $$+\sum_{j=1}^{n}(X(t_j)-X(t_{j-1}))^2+t^2]$$ since $$ E[(X(t_j)-X(t_{j-1}))^2]=\frac{t}{n} $$ and $$ E[(X(t_j)-X(t_{j-1}))^4]=\frac{3t^2}{n^2} $$ which can be calculated as(Y~normal): $$E(Y^4)= \int_{-\infty}^{\infty}Y^4\frac{1}{\sqrt{2\pi\sigma^2}}e^{\frac{Y^2}{\sigma^2}}dY$$ $$= -\int_{-\infty}^{\infty}Y^3\frac{\sigma^2}{\sqrt{2\pi\sigma^2}}de^{\frac{Y^2}{\sigma^2}}=\int_{-\infty}^{\infty}3Y^2\frac{\sigma^2}{\sqrt{2\pi\sigma^2}}e^{\frac{Y^2}{\sigma^2}}dY=3\sigma^2\sigma^2=3\sigma^4 $$ Thus the original equation becomes: $$ n\frac{3t^2}{n^2}+n(n-1)\frac{t^2}{n^2}-2tn\frac{t}{n}+t^2=O(\frac{1}{n}) $$ As n converts to infinity, this tends to zero. We therefore have that: $$ \sum_{j=1}^{n}(X(t_j)-X(t_{j-1}))^2=t $$