# cfd

In the previous message I've described how colored coins can represent prediction market contracts. It works when we have only two outcomes like YES or NO, but what if want something more flexible, like making a bet on price moves?

Say, we want something like CFD: http://en.wikipedia.org/wiki/Contract_for_difference

In finance, a contract for difference (or CFD) is a contract between two parties, typically described as "buyer" and "seller", stipulating that the seller will pay to the buyer the difference between the current value of an asset and its value at contract time. (If the difference is negative, then the buyer pays instead to the seller.) In effect CFDs are financial derivatives that allow traders to take advantage of prices moving up (long positions) or prices moving down (short positions) on underlying financial instruments and are often used to speculate on those markets.

(Note that what I'm describing here might not work exactly like traditional CFDs, but is probably close enough. Although it's also quite like NDF, see below.)

This can be implemented in a way similar to prediction market I described in previous message, but it is a bit more complex as buyer of a CFD might be at loss and would need to pay the seller. Thus we need to incorporate initial margin into contract.

So we'll issue two kinds of coins with value calculated using this formula:

``````LONG-CFD price = I + Q(P_e - P_s)
SHORT-CFD price = I + Q(P_s - P_e)
``````

Where: I: initial margin Q: quantity of underlying asset P_e: price per unit (in bitcoins) in the end (at time when contract expires and settlement is made) P_s: price per unit (in bitcoins) at start, e.g. price at time contract is made

Issuer/operator shall buy back these coins at these prices when settlement is made. (It's also possible to roll it over: contract will be swapped for a new contract +/- variation margin.)

But price might fluctuate in between. Issuer can either act as a market maker to make CFD price matching current asset price. (I.e. P_e = current price in formula above.) Or he can let it float, thus making these contracts more like non-deliverable forwards (NDF). (I.e. P_e = forward price).

In any case, sum of price of LONG-CFD and SHORT-CFD is always `2 * I` (price at start and at end cancels out), so issuer can always sell pairs of such contracts and have zero-exposure himself. (But in that case there is an implied forward price, so it's like a NDF.)

Now there is a fundamental problem with decentralized markets: you cannot represent below-zero values. E.g. if somebody bought a LONG-CFD and price have tanked, he owns operator some money, but there is no way to get that money if it was anonymously purchased.

We have to deal with it and always assume that profit and loss are capped. I.e. one cannot lose more than his initial margin and variation margin at time contract is bought.

This works similar to stop-loss and take-profit, but these are not orders investor might tweak, they are inherent features of instrument itself. Issuer/operator must pick some reasonable stop-loss and take-profit conditions.

Let's get back to formula:

``````LONG-CFD price = I + Q(P_e - P_s)
``````

Price goes to zero when `P_e = P_s - I/Q`. This is an equivalent of stop-loss price (and take-profit price for SHORT-CFD). If we want an equivalent of stop-loss at 25% price fall we should set `I = Q*P_s*0.25`.

In this case settlement will be exact as long as price is within 25% range of initial price. If it goes outside of this range profit and loss are capped.

In general, if we want settlement to be exact in price range `(1-k)*P_s...(1+k)*P_s` we need `I = Q*P_s*k`.

Thus

`````` LONG-CFD price = Q*(k*P_s + P_e - P_s)
SHORT_CFD price = Q*(k*P_s + P_s - P_e)
``````

It is possible to use escrow/primary dealers construct just like with prediction market: issuer will provide a pair of CFDs for `2 * Q* k * P_s` BTC in escrow. Primary dealers then can either sell them in pairs, or act as market-makers.

Settlement becomes more complex: as both sides of CFD can have value in them both are needed to unblock deposited funds. Issuer's market intervention might be necessary to force investors to be reasonable and to sell coins to primary dealers at a reasonable price.

Suppose I sell a some product for 11 BTC, price is fixed in Bitcoin, payment is done only when it ships. But I need to pay supplier \$100 before I ship (from my own reserves). Current exchange rate is 10 USD for 1 BTC. So I should get 1 BTC profit on this trade if exchange rate does not change.

I don't want an exposure to exchange rate fluctuations on for this trade, so I buy a CFD on \$100 USD.

Once I'll receive payment from customer I will sell CFD which will cover exchange rate difference, and buy \$100 USD to replentish reserves, and my profit on this trade is exactly 1 BTC no matter what happens to exchange rate.

In numbers: CFD on \$100 USD with 25% price range and 0.1 BTC per USD initial price costs (only margin): `0.25*100*0.1 = 2.5` BTC.

Suppose at the time I received payment from customer Bitcoin exchange rate tanked to 8 USD per BTC. (20% drop.) Now USD price is 0.125 BTC and CFD price is

`2.5 + 100*(0.125-0.1) = 5` BTC.

I need 12.5 BTC to buy \$100 USD, so in the end my profit is:

`````` 11 BTC   (from customer)
+ 5  BTC  (sold CFD)
- 2.5 BTC (bought CFD)
-12.5 BTC (bought 100 USD @8)
= 1 BTC
``````

Exactly as planned.

If I didn't use a CFD I would have had 1.5 BTC loss.

Note that I'm not paying any premium for this exchange rate protection, only costs are transaction fees and spreads which should be minimal on liquid and efficient market.

You cannot do that with options, option has a price which I pay even if I don't use it. On the other hand, if exchange rate goes in opposite direction I might get some nice profit.

So options are far less suitable for this kind of thing where one doesn't look for extra profit but simply wants to eliminate his exposure.

##### Clone this wiki locally
You can’t perform that action at this time.
Press h to open a hovercard with more details.