Calculus

For the preparation of Quants

1. Functions Definition

1.1 Each x has only one y

A function denoted f (x) of a single variable x is a rule that assigns each element of a set X ( written x \in X ) to exactly one element y of a set Y ( y\in Y) :
$$
y=f(x)\quad or \quad x\rightarrow f(x)
$$

1.2 Domain of f

$Dom f$ Domain of Function

$Im f$ Image of Function

For a given value of x, there should be at most one value of y.

1.3 Implicit Form f(x,y)=0

For example,
$$
4y^4-2y^2x^2-yx^2+x^2+3=0
$$

1.4 Polynomials

$$
y=f(x)=a_0+a_1x+a_2x^2+…+a_nx^n
$$

2. Implicit Differentiation

For example,
$$
y=a^x
$$
Mainly two ways to take derivatives,
$$
ln(y)=ln(a^x)=xln(a) \
\frac{1}{y}\frac{dy}{dx}=ln(a)\quad\text{by taking derivatives to x}\
\Rightarrow \frac{dy}{dx}=y\cdot ln(a) \
$$
and plug y=a^x inside
$$
\frac{dy}{dx}=a^x\cdot ln(a)
$$
Or, simply we apply the exponential transformation, and take deriviatives later.
$$
y=e^{ln(a^x)}=e^{x\cdot ln(a)}
$$
However, for a polynomial, we normally have to do the implicit differentiation.
$$
4y^4-2y^2x^2-yx^2+x^2+3=0 \\
16y^3y’-(4y’yx^2+4y^2x)-(y’x^2+2yx)+2x=0 $$
$$(16y^3-2yx^2-x^2)y’=-2x+4y^2x+2xy \\
\Rightarrow y’=\frac{-2x+4y^2x+2xy}{16y^3-2yx^2-x^2}
$$

3. L ‘Hospital’s Rule & Limitations

If there is a limitation (, which is called as the inderterminate form),
$$
\lim_{x \rightarrow a} \frac{f(x)}{g(x)}\equiv \frac{0}{0} \ or \ \frac{\infty}{\infty}
$$
then, it could be calculated as,
$$
\lim_{x \rightarrow a} \frac{f(x)}{g(x)}=\lim_{x \rightarrow a} \frac{f'(x)}{g'(x)}=\lim_{x \rightarrow a} \frac{f”(x)}{g”(x)}=…=\lim_{x \rightarrow a} \frac{f^{(n)}(x)}{g^{(n)}(x)}
$$
For example, \frac{sin(x)}{x}, at x \rightarrow 0.

4. Taylor Series

Approximate a function a certain point, by a series of terms.(detailing explaination sees Blog Section 6 )

We use the 1st, 2nd, 3rd, 4th, … n^th derivatives, etc, to approximate the function at a certain value.
$$
f(x)\approx f(x_0)+(x-x_0)f'(x)|_{x=x_0}+\frac{1}{2}(x-x_0)f”(x)|_{x=x_0}+…+\frac{1}{n!}f^{(n)}(x)|_{x=x_0}(x-x_0)^n
$$

For example, e^x at x=0.
$$
e^x=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+…+\frac{x^n}{n!}
$$

5. Integration

5.1 Intergration by Parts

$$
y=u(x)v(x) \
y’=u’\cdot v +u\cdot v’ \
u’v=y’-uv’ \
$$

and then integrate from both sides,
$$
\int u’v dx=\int y’ dx-\int uv’ dx
$$
as \int y’ dx = y+C, so we would get,
$$
\int u’v\cdot dx=\int v\cdot du=y-\int u\cdot dv +C
$$
For example,
$$
\int xe^x\cdot dx=\int x\cdot de^x \
=xe^x-\int e^x\cdot dx +(C) \
=xe^x-e^x+(C)
$$

5.2 Reduction Formula

We define a integral, (I_n is called Gamma Function)
$$
\int_0^{\infty}e^{-t}t^n\cdot dt= I_n
$$
$n$ is determined as the subscript of $I_n$, and could be treated as a constant in that integral.

We integrate that formula, and would get,
$$
n\int_0^{\infty}e^{-t}t^{n-1}dt=I_n \
n\cdot I_{n-1}=I_n
$$
If we keep doing that, we would get,
$$
I_n= n\cdot I_{n-1}=n(n-1)I_{n-2}=…=n!\cdot I_0
$$
where,
$$
I_0=\int_0^{\infty}e^{-t}\cdot dt=1
$$
so we get,
$$
I_n=n!\cdot I_0=n!
$$

5.3 Other Tips

5.3.1 ln|f(x)|

$$
\int \frac{f'(x)}{f(x)}=ln|x|+C
$$

For example,
$$
\int \frac{x}{1+x^2}dx\
=\frac{1}{2}\int\frac{1}{1+x^2}dx^2=\frac{1}{2}\int\frac{1}{1+x^2}d(1+x^2) \
=\frac{1}{2}ln|1+x^2|+C
$$

5.3.2 Decompose the Fraction – Factorisation

For example,
$$
\frac{1}{(x-2)(x+3)}=\frac{A}{x-2}+\frac{B}{x+3}\
A=\frac{1}{5},\quad B=-\frac{1}{5}
$$
The further implication is that.

Any rational expression \frac{f(x)}{g(x)}, ( with degree of f(x) < degree of g(x)), could be rewritten as.
$$
\frac{f(x)}{g(x)}\equiv F_1+F_2 +…+F_k
$$
, where each F_i Is,
$$
F_i=\frac{A}{(px+q)^m}\quad or\quad \frac{Ax+B}{(px+q)^m}
$$

6. Complex Number – i

6.1 Definition

$$
z=x+iy\
i=\sqrt{-i}\quad, i^2=-1
$$

and z could be expressed in polar co-ordinate form as,
$$
z=r(cos \theta+i\ sin\theta)
$$
, where
$$
x=r\ cos\theta \quad, y=r\ sin\theta
$$
The set of all complex numbers is denoted \mathbb{C}; and for any complex number z, we could write z \in \mathbb{C}. ( \mathbb{R} \subset \mathbb{C} ).

6.2 Modulus

The modulus of z donates |z| is defined as,
$$
|z|=r=\sqrt{x^2+y^2}
$$

Modulus
6.3 Complex Conjugate

$$
\bar{z}=x-iy
$$

For example, if z=x+iy, then \bar{z}=x-iy.

6.4 Polar Form

$$
z=r(cos\ \theta+i\ sin \ \theta)=re^{i\theta}
$$

by Euler’s Identity,
$$
e^{i\theta}=cos\ \theta+i\ \sin\ \theta \
e^{-i\theta}=cos\ \theta-i\ \sin\ \theta \
|z|=r,\quad arg\ z=\theta
$$

6.5 Euler’s Formula

The Euler’s Identity is shown as, by applying Taylor’s Expansion and by i^2=-1,
$$
e^{i\theta}=1+i\theta+\frac{(i\theta)^2}{2!}+…+\frac{(i\theta)^n}{n!}\
=(1-\frac{\theta^2}{2}+\frac{\theta^4}{4!}+…)+i\times(\theta-\frac{theta^3}{3!}+\frac{\theta^5}{5!}+…) $$
$$=cos\ \theta +i\ \sin\ \theta$$
Plug \(\theta = \pi\) into Euler’s Formula,
$$
e^{i\pi}=cos\ \pi+ sin\ \pi\
e^{i\pi}=-1
$$

7.Higher Derivatives

$$
\frac{\partial^2 f}{\partial x^2}=f_{xx}=\frac{\partial}{\partial x}(\frac{\partial f}{\partial x}) \ \
\frac{\partial^2 f}{\partial x \partial y}=f_{xy}=\frac{\partial}{\partial y}(\frac{\partial f}{\partial x}), $$
\(f_{xy}=f_{yx}\) Sequence no matters if 2nd derivatives exist and continuous.

Reference

财务造假分析 – 大坑

财务造假的动机

  1. 避免ST
  2. 有融资需求,让报表好看
  3. 完成业绩对赌协议
  4. 个人利益

造假的手段

  1. 虚增收入 by 虚构客户 供应商,循环交易
  2. 虚增收入 by 无中生有,遭假合同 流水
  3. 虚增收入 by 提前确认收入(权责发生制 提前确认)
  4. 虚减费用 by 删除账目。 导致lia和exp同减少
  5. 虚减费用 by 会计政策变更,coz 不计提坏账等
  6. 虚减费用 by 跨周期确认费用 以调整利润

识别

  • 1. Gross Profit Margin

通过虚增利润、虚减费用等方法会造成 Gross Profit Margin陡增。因为Rev 虚增时 COGS不变;同理COGS虚减时, Rev不变 ==> 导致GPM陡增。

因此GPM跨时间周期中大幅波动;GPM 显著高于同业 等情况需要引起重视。

  • 2. Inventory Turnover 与 经营情况不符。

正常企业经营,Rev COGS高是由于卖货多,所以 Inv Turnover 增加,意味着企业运营能力提高,会带来 Rev COGS提高,会带来 NI提高。

但是,若Inv Turnover 减少,同时Rev增加,需要引起重视。有可能是企业,虚增业务导致Rev增加,而实际并未有业务发生,所以Inv不变,所以Inv Turnover不变。

  • 3. CF表

CFO与NI的关系。 若NI常年未能转化成Cash,说明企业有巨多A/R,此部分A/R很可能是虚增的:Dr. A/R; Cr.Rev 为了虚增Rev。

  • 4. Others

如企业账上有巨多Cash,还要融资。等不正常行为。

Reference

Hodrick Prescott Filter / HP Filter

We decompose a time series into two parts, one is the trend, and the other is the seasonality.

$$ y_t=g_t+c_t $$

, where \(g_t\) is the trend, and \(c_t\) represents seasonality. Or, one can understand those two components as a low-frequent part, and a high-frequent part.

The filer tells that,

$$\min_{g} \sum_i^N (y_i-g_i)^2+\lambda \sum_i^{N-1} (g_i^2-2g_{i+1}+g_{i+2}^2 )^2$$

$$\min_{g} \sum_i^N (y_i-g_i)^2+\lambda \sum_i^{N-1} [(g_i-g_{i+1})-(g_{i+1}-g_{i+2}]^2$$

,which can be also written as,

$$\min_{g} || y-g||^2+\lambda||\nabla^2 g||$$

We can see the first term represents how far the trend term \(g\) is away from the original series \(y\), and the second term means to smooth the trend term \(g\).

$$ g=argmin_g || y-g||^2+\lambda||\nabla^2 g||^2$$

We replace \( \nabla^2 g \) by \(Dg\).

$$ || y-g||^2+\lambda||D g||$$

$$ (y-g)^T (y-g) +\lambda (Dg)^T(Dg)$$

We take the first gradient (f.o.c.) to solve for the trend term \(g\).

$$ -(y-g)+\lambda D^TDg =0$$

Therefore,

$$ y=(I+\lambda D^T D)g $$

and,

$$ g=(I+\lambda D^T D)^{-1}y $$

Reference

https://zhuanlan.zhihu.com/p/160243396

资产回报-宏观经济-利率利差-资本流动-汇率变化

1. 经济增长

自微观至宏观的结构。微观层面,公司的资产价值增长或公司的利润增长,而某行业内多个公司总值或均值的增长带来了行业的增长。同理,行业引申至宏观经济体。本质上是weighted average,而意识上是 多个个体增长 带来整体 增长。逻辑简单。

同时,在经济扩张阶段,企业对loanable fund的需求增加反映在财务上往往是负债增加。企业若需继续扩展则 负债增加带来的风险 需要被 企业增长的预期带来的预期收益冲抵,因为如此,理性投资者才原因承担更高的风险。

P.S. Considering the interest rate and saving, lower real interest rates motivate individuals to consume more and save less. Greater consumption enhances capital/money transferring in the whole economy. We may say that a lower interest rate can not just stimulate the economy in a positive way through increase the desire for investment and consumption, but also smooth the economy by pooling liquidity into the market.

2. 宏观经济体之间

假设两个经济体,A和C。C的经济增长快,市场中对goods, services, factors, labours等各方面的需求高,同时对money的需求高。对 money 的高需求,带来了高成本 – higher interest rate。而A增长相对少,甚至Central Bank需要主动采取措施给降低interest rate来降低loanable fund 的成本,刺激需求。

基于以上大背景。A市场中利率水平低,C市场中利率水平高。

Under Globalization, money flows across countries with low fees and less regulation. Without considering others, money would flow into the market with a higher interest rate, pursuing higher returns. However, sovereign risks, frictions, regulations, etc, would block that path.
在全球化的大背景下,如果假设低fees低监管等限制,money会流入高收益的市场。但是现实中往往并非如此,因为投资者会考虑其他因素,如地缘风险,政策变化等等。

继续之前的例子, C国利率高,money流入C国,对于C国currency的需求大,currency appreciates。C国货币升值后,A国再进口C国商品物料或投资的成本变高。对C国货币的需求又会相对减少。Overall, a Dynamic Equilibrium occurred.

当然,以上为理想情况。现实中USD起到全球主要流通外汇的左右,尤其特殊的意义。且经济情况今非昔比。市场或宏观经济体面临不同的环境:如De-globalisation;

3. 加息的传导渠道

https://mp.weixin.qq.com/s/sInT_p-p9ewRYEbt8MMtmg

Reference

https://mp.weixin.qq.com/s/fs-wMetDFe5HmCl3f8tztA

Stock Market Reactions on Taper & the Increase in Federal Rate

Factors affecting stocks valuation are liquidity of the market, Prosperity of the overall market, investors’ preference, etc.

In simply the DCF model, the impacts of those factors would be reflected in the discounted rate. As we consider separating the interest rate into a risk-free rate and the premium for a certain firm, the premium is idiosyncratic. For example, with low liquidity of the capital market, investors would expect a liquidity premium; worse economic conditions and low investors’ preferences would increase the risk premium.

Therefore, we could predict that an increase in the federal fund rate, as what the Fed is doing to face the hyper-inflation, and quantitive tightening would have the following impacts. Firstly, the quantitive tightening (QT) or TAPER means the Fed would actively decrease its balance sheet by sell-out/stoping re-issuing those MBS or Government debts. This conduction would decrease the amount of money available in the market, and thus result in higher costs of borrowing money. The liquidity premium would increase. Secondly, if there is less supply of money, then the higher cost of using money, the interest rate, would increase. Both the increase in the interest rate and the premium would increase the discount rate for a certain company. Applying the higher discounted rate to the DCF model for that firm would end up with a lower valuation.

Conclusively, an increase in the Federal Fund Rate and QT/TAPER would generally result in a lower valuation of firms.

Bond Price Approximation

The Price-Yield Curve descripts the relationship between a bond’s price and yield, and they are normally negatively correlated.

We here consider the Bond’s price as a function of the bond’s yield, \(P(Y)\), and study the approximation of the bond’s price.

We firstly apply the Taylor Expansion at \( (Y_0,P_0 \),

$$ P(Y)\approx P(Y_0)+\frac{dP}{dY}(Y-Y_0)+\frac{d^2P}{dY^2}\frac{(Y-Y_0)^2}{2!}+O((Y-Y_0)^3) $$

$$ P(Y)-P_0 \approx +\frac{dP}{dY}(Y-Y_0)+\frac{d^2P}{dY^2}\frac{(Y-Y_0)^2}{2!}+O((Y-Y_0)^3) $$

$$ \triangle P \approx \frac{dP}{dY}\triangle Y+\frac{d^2P}{dY^2}\frac{(\triangle Y)^2}{2!}+O((\triangle Y)^3) $$

Devided by P from both side, then the LHS means the percentage change of Price.

$$\frac{ \triangle P}{P} \approx \frac{dP}{dY}\triangle Y \frac{1}{P}+\frac{d^2P}{dY^2}\frac{(\triangle Y)^2}{2!}\frac{1}{P}+O((\triangle Y)^3) $$

By definition, the Modified Duration \( D=\frac{\triangle P / P}{\triangle Y} = \frac{dP}{dY}\frac{1}{P}\), and convexity \( C=\frac{d^2 P}{d Y^2}\frac{1}{P} \). We replace them into the expansion function. and drop the last term.

$$\% \triangle P \approx D\cdot \triangle Y+\frac{C}{2}\cdot (\triangle Y)^2$$

Finally, we get the approximated bond price curve. Second order Taylor Expansion is applied, and the Duration and Convexity, two important properties of bonds are included. For more accurate approximation, more terms need to be expanded.

Taylor Rule

Developed by John B. Taylor – aims to be a rule of thumb

If the Federal Reserve decides to increase the liquidity, it would then buy bonds and put more money into the market. As there is more money to lend, the interest rate would go down.

The monetary policy aims to target the inflation rate. Considering the Philips curve, there is a trade-off between unemployment and inflation. Unemployment could be replaced by its counterpart, economic growth. We consider the goal of the monetary department to balance GDP and Inflation.

The Fed normally has a target interest rate, the federal funds rate, which is the overnight rate in the interbank market for short term lending. How should the monetary policy set the target interest rate? This is the key discussion of the Taylor rule.

$$i=i^*+a (\pi – \pi^*) – b(U-U^*)$$

By the Philips curve, we replace unemployment with output. As we separate the interest rate to be the real interest rate and the inflation rate.

$$ i=r+\pi^*+a\underbrace{(\pi-\pi^*)}_{Inflation\ Gap}+b\underbrace{(Y-Y^*)}_{Output\ Gap} $$

The output gap could be considered to be by what percentage of the current GDP is below the Potential GDP.

Clearly, the Taylor rule is intuitively to be correct.

If there is an inflation gap the current inflation is greater than the target, which also means there is an extra money supply moving the CPI upward, then the Fed should conduct a contractionary monetary policy, and it should set a higher interest rate.

If the GDP growth is lower than the target (potential), or if the unemployment rate is greater than the target, then the Fed would like to stimulate the market. Thus, it would decrease the interest rate.

For the Taylor rule, John Taylor did not mean the monetary policy should follow it. It is not a law but just a rule of thumb. Normally, we also set the coefficients \(a\) and \(b\) to be 1\2. However, if we think the government would pay more attention to the inflation target, then we could certainly increase the weight of inflation gap.