# Position opening

## Pricing with margin

### Formulas

The formulas below present the price at which a trader could open a long position at a price $P_{O,L}$ or a short position at a price $P_{O,S}$ with an initial margin $M$ (other notations have been introduced in theoretical pricing).

Side | Price to open a position |
---|---|

Long | $P_{O,L}=S_{L}*{ \bigg( \dfrac{1+r_{Q,b}}{1+r_{B,l}} \bigg) }^T - M *[{(1+r_{Q ,b })}^T -1]$ |

Short | $P_{O,S}=S_{S}*{ \bigg( \dfrac{1+r_{Q,l}}{1+r_{B,b}} \bigg) }^T + M *[{(1+r_{Q , l})}^T -1]$ |

Contango protocol provides a price improvement compared to the theoretical formulas presented in theoretical pricing:

Since $M *[{(1+r_{Q ,b })}^T -1] > 0$, the price to open a long position is at a lower price, i.e. more favourable to the trader.

Since $M *[{(1+r_{Q , l})}^T -1] > 0$, the price to open a short position is at a higher price, i.e. more favourable to the trader.

### Example

Let's consider a contract on ETHDAI expiring in 3 months ($T=1$) and where the traders posts $50 \:DAI$ as margin:

Given one could borrow DAI at a yearly fixed rate of $r_{Q,b}=10.10\%$ā, lend ETH at a yearly fixed rate $r_{B,l}=2.90\%$and buy ETH on the spot market at $S_{L}=100.10\:DAI$ then the price at which a trader could open a long a position is:

$P_{O,L}=100.10*{ \bigg( \dfrac{1+0.1010}{1+0.0290} \bigg) }^{0.25} - 50 *[{(1+{0.1010})}^{0.25} -1] = 100.59 \: DAI$ā

Given one could borrow ETH at a yearly fixed rate of $r_{B,b}=3.10\%$ā, lend DAI at a yearly fixed rate of $r_{Q,l}=9.90\%$and sell ETH on the spot market at $S_{S}=99.90\:DAI$ then the price at which a trader could open a short position is:

$P_{O,S}=99.90*{ \bigg( \dfrac{1+0.0990}{1+0.0310} \bigg) }^{0.25} + 50 *[{(1+{0.0990})}^{0.25} -1] = 102.70\: DAI$ā

### Demonstration

#### Long

Let's consider that a trader wants to buy 1 expirable (the numerical values are taken from the above example). In this demonstration, we will present the steps to replicate the cash flows of a expirable position. Let's figure out the price of the expirable, i.e. the DAI money needed, to get 1 ETH at expiry:

1. To receive 1 ETH at expiry, the trader needs to lend $\dfrac{1}{(1+r_{B,l})^T} \: ETH$, i.e. $0.9929 \: ETH$

2. To get that ETH, the trader first swaps $\dfrac{S_{L}}{(1+r_{B,l})^T} \: DAI$, i.e. $99.39 \: DAI$.

3. Since the trader has already some margin, she only needs to borrow $\dfrac{S_{L}}{(1+r_{B,l})^T} - M \: DAI$, i.e. $49.39 \: DAI$.

4. The debt $D$ the trader owes at expiry (principal + interest) is: $D = [\dfrac{S_{L}}{(1+r_{B,l})^T} - M] * {(1+r_{Q , b})}^T \: DAI$, i.e. $D=50.59 \: DAI$.

5. Hence, the money needed to receive 1 ETH at expiry is the sum of the debt and the margin provided: $[\dfrac{S_{L}}{(1+r_{B,l})^T} - M] * {(1+r_{Q , b})}^T + M \: DAI$ or $S_{L}*{ \bigg( \dfrac{1+r_{Q,b}}{1+r_{B,l}} \bigg) }^T - M *[{(1+r_{Q ,b })}^T -1] \: DAI$, i.e. $100.59 \: DAI$.

#### Short

Let's consider a trader who wants to sell 1 expirable (the numerical values are taken from the example above). This means she would give 1 ETH at expiry, let's figure out the steps and how much money she would need to receive at expiry:

1. The trader will give 1 ETH at expiry to reimburse a debt. Hence the trader borrows $\dfrac{1}{(1+r_{B,b})^T} \: ETH$, i.e. $0.9924 \: ETH$.

2. The trader swaps the ETH to get $\dfrac{S_{S}}{(1+r_{B,b})^T} \: DAI$, i.e. $99.14 \: DAI$.

3. The trader lends the DAI from the swap and her margin. At expiry the trader receives an amount $L=[\dfrac{S_{S}}{(1+r_{B,b})^T} + M] *{(1+r_{Q , l})}^T \: DAI$, i.e. $L=152.70 \: DAI$.

4. The amount of money the trader will receive at expiry, which is also the price of the expirable, is the difference between the amount L and the margin: $[\dfrac{S_{S}}{(1+r_{B,b})^T} + M] *{(1+r_{Q , l})}^T - M \: DAI$ or $S_{S}*{ \bigg( \dfrac{1+r_{Q,l}}{1+r_{B,b}} \bigg) }^T + M *[{(1+r_{Q , l})}^T -1] \: DAI$, i.e. $102.70 \: DAI$.

## Pricing with margin ratio

### Formulas

Given the margin ratio $MR$:

the margin for a long position could be expressed as $M = MR*P_{O,L}$, e.g. if the price to open a long position is $P_{O,L}=100 \:DAI$ and if the trader wants a margin ratio of 50%, then the required margin is $M=50 \:DAI$

the margin for a short position could be expressed as $M = MR*P_{O,S}$, e.g. if the price to open a short position is $P_{O,S}=100 \:DAI$ and if the trader wants a margin ratio of 50%, then the required margin is $M=50 \:DAI$

Replacing the margin $M$ in the main pricing formula to open a position, we find new expressions depending on the collaterisation ratio $MR$ :

Side | Price to open a position |
---|---|

Long | $P_{O,L}=S_{L}*{ \bigg( \dfrac{1+r_{Q,b}}{1+r_{B,l}} \bigg) }^T * \dfrac{1}{1+MR*[{(1+r_{Q ,b })}^T -1]}$ |

Short | $P_{O,S}=S_{S}*{ \bigg( \dfrac{1+r_{Q,l}}{1+r_{B,b}} \bigg) }^T * \dfrac{1}{1-MR*[{(1+r_{Q ,l })}^T -1]}$ |

### Example

Let's consider a contract on ETHDAI expiring in 3 months ($T=1$) where the trader puts a $50\%$MR:

Given one could borrow DAI at a yearly fixed rate of $r_{Q,b}=10.10\%$, lend ETH at a yearly fixed rate $r_{B,l}=2.90\%$ and buy ETH on the spot market at $S_{L}=100.10\:DAI$then the price at which a trader could open a long a position is:

$P_{O,L}=100.10*{ \bigg( \dfrac{1.1010}{1.0290} \bigg) }^{0.25} * \dfrac{1}{1+0.5*[{(1.1010)}^{0.25} -1]}=100.68\:DAI$

Given one could borrow ETH at a yearly fixed rate of $r_{B,b}=3.10\%$, lend DAI at a yearly fixed rate of $r_{Q,l}=9.90\%$, and sell ETH on the spot market at $S_{S}=99.90\:DAI$ then the price at which a trader could open a short position is:

$P_{O,S}=99.90*{ \bigg( \dfrac{1.0990}{1.0310} \bigg) }^{0.25} * \dfrac{1}{1-0.5*[{(1.0990)}^{0.25} -1]}=100.31\:DAI$

Last updated