Skip to content

Instantly share code, notes, and snippets.

@drwasho
Last active August 29, 2015 14:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drwasho/04dbaf19da4f4a8ae512 to your computer and use it in GitHub Desktop.
Save drwasho/04dbaf19da4f4a8ae512 to your computer and use it in GitHub Desktop.
Forwards and futures contracts in *OpenBazaar*

by Dr Joseph Clark and Dr Washington Sanchez

Bounded Futures Contracts

Here we propose the use of bounded futures contracts as a solution to trade price risk on a decentralized financial exchange.

1.0 Bounded Futures

A forward contract is an agreement to buy an item for an agreed price in future. For example it might be possible to agree to purchase a barrel of crude oil a month from now for $100. If in a month the market price of crude is higher than $100, then the contract has positive value. If the price is lower, the contract has negative value.

Value of bought futures contract in one month = item price in one month - futures price

Symmetrically, it is possible to enter a contract to sell crude in a month for $100. This gives the negative value of a bought future.

Value of sold futures contract in one month = futures price - item price in one month

The contract allows both sides to have an exposure to the market price of crude without owning the asset. For a fungible asset like oil it is not even necessary for to exchange the physical asset at the agreed sale time; buyer and seller can simply settle for the economic value of the contract (difference between the agreed futures price and the market price).

Futures contracts are widely used for currencies, equity indices (like the S&P 500), interest rates, bonds, commodities, and recently for more exotic risks like temperature and rainfall. These markets allow a far greater flexibility in speculation and hedging for market participants than would be available in the ordinary cash markets for the underlying assets. In many cases the futures market volume exceeds the cash market, and the price is first determined by trades in the futures market and later reflected in changes in the cash (or spot) price.

A difficulty with futures contracts is that it requires trust between contracted parties to pay the agreed contract value. If the price of crude increases to $150 in one month the buyer of the contract must have a mechanism to receive $50 from the seller (or equivalently a physical barrel for $100). This obligation must be backed by enforceable contract.

Futures traded on financial exchanges have a smart mechanism to solve this problem. Each side provides some amount of money to the exchange as collateral for their side of the agreement. If the market price of the contract changes (observed through other trades on the same item) one side has to provide additional money to the exchange. If they are unable to meet this call for extra collateral the exchange finds a new counterparty to the trade (buyer or seller). If the exchange is careful to always have sufficient collateral to absorb market price movements the contract will require no trust between buyers and sellers. Both sides do not even need to know about each other; the exchange is the legal counterparty to both sides.

This very elegant solution has a problem: the exchange must monitor the markets and make a guess at the probable size of price changes to determine how much collateral to require from each side. If the price movements are large or the contract is not traded often the exchange might not be able to find a suitable counterparty and be forced to take a financial loss on the contract. For a properly decentralized market a different solution is required that does not need monitoring of an exchange and also does not expose the parties to credit risk.

One solution is to have contracts that have limited losses or gains. Taking the example of the crude oil contract from the example earlier, a contract might only be exposed to the price risk if the price of crude was between $80 and $120. Each side of the contract would put up $20 in collateral and the value of the contract would be determined without any credit risk or need for margining.

The payoff of this new contract is a bounded version of a usual futures contract payoff:

(This assumes that the futures price is $100. A slightly more general contract payoff includes an offsetting amount if the price is different.*)

This bounded contract is more flexible than an ordinary future (an ordinary futures contract is a bounded contract with bounds at 0 and ∞). A series of contracts can be "chained" together, where the lower bound of one contract is matched to the upper bound of another. It is also possible to mimic the operation of a traditional futures exchange. As the asset price approaches the upper bound the exchange asks for additional collateral from the seller to buy the next bounded contract. In this way the operation of bounded contracts can be hidden from market participants who find trade in the bounded contracts too daunting.

A more subtle advantage of bounded contracts comes from their non-linear structure. A bounded contract is equivalent to buying a European call option with a strike at the lower bound and selling a call at the upper bound. Hence any market trading bounded contracts is also indirectly pricing and trading options. Usually it is relatively difficult to establish an options market in an asset because it requires sophisticated sellers to price the risk and a high volume in the underlying market for hedging. This makes options markets expensive and The existence of options in a market provides a much richer set of trading possibilities than with a simple cash or futures market. Options implicitly price expected volatility in the market (this is the essence of the Black Scholes formula – that hedging costs for options are dependent almost completely on the price volatility and not on the price direction). Options also implicitly provide a market estimate of the probability of the price entering a certain range. Imagine a bounded contract with a very small bound (say 99.5 to 100.5). This contract would be worth $0if the price is less than 99.5 and $1 if the price is more than $100.5. The market price of this contract is implicitly an estimate of the probability of the price exceeding $100.5. If the price of the contract is $0.5 the market believes the probability is 50%; if the price is $0.1 the market believes the probability is 10%.**

This allows traders to express more sophisticated views on the future price behavior than the crude up/down bet available through a future. The trader can speculate or hedge on the price achieving a certain range, or construct a trade to bet that the market priced probabilities are too wide (variance), or not reflecting sufficient asymmetry in price behavior (skewness). All these additional possibilities enhance the capability of the market to provide effective risk transfer.

However good things do not come for free, and there is a reason why spread contracts are not traded as frequently as futures on exchanges. The existence of multiple contracts divides the market volume between the contracts and makes trading in large size more difficult and costly. This is a serious drawback but there are mechanisms to moderate the problem. When a contract is offered for sale or purchase some traders might be willing to “convert” the contract into a nearby bound, simultaneously buying the one contract and selling the other. In this case a contract bid or offered at one bound would immediately and automatically provide volume to nearby bounds. This conversion service could be provided by the exchange itself, or by dedicated specialized market makers who would propagate liquidity amongst contracts in the hope of receiving up a small profit on average.

Bounded futures contracts are natural structures for decentralized markets where trading volumes are likely to be patchy and trust difficult to establish. Parties to the contract can determine how much risk they want to be exposed to and for how long. This removes the usual problems of margining (collateral) from the exchange in exchange for creating a problem by dividing liquidity between multiple contracts. But on net this trade is worthwhile: it allows a completely decentralized and autonomously operating futures market and an extraordinary flexibility of financial structures.

Example of a bounded futures contract as a hedge for a sale contract

Suppose we have the following scenario:

Chair spot price: 0.01BTC BTC spot price: $300 One month futures price for BTC $300. Chair in USD: $3

We agree to buy the chair to receive 0.01BTC in one month and wish to hedge the USD/BTC exposure.

To hedge with a normal futures contract, we agree to sell 0.01BTC in one month (short selling - shorting - bitcoin) for the futures price of $300/BTC ($3). Any changes in the price of BTC are fully hedged.

To hedge with a bounded futures contract we agree to sell 0.01BTC in one month for the futures price of $300/BTC ($3) bounded between 250USD/BTC ($2.5) and 350 USD/BTC ($3.5).

If the price of BTC after a month is at the upper bound ($350), the contract to sell 0.01BTC for $300 ($3.5) has a market value of -$0.5 (i.e. $3 - $3.5 = -$0.5). At the lower bound ($250) the contract is worth $0.5 (i.e. $3 - $2.5 = $0.5).

Both parties to the bounded futures contract put up $0.5 in collateral, in the multisignature escrow address, to cover their the maximum possible loss.

If the price of BTC/USD varies less than 50% the bounded futures contract provides a perfect hedge. If it moves more in either direction (above $350 or below $250) then the hedge is only partial.


(*) This is summarised by the following:

where F is the bounded contract "price" which makes the contract a fair trade for both parties. A more general form is:

(**) In the limit as the bound approaches zero this is known as the “risk neutral” probability. This allows a probability distribution (the “risk neutral distribution”) to be constructed across the range of price where the contract trades.

2.0 Bounded Futures Ricardian Contract for OpenBazaar

This is an example of a bounded futures contract that may be issued in OpenBazaar:

{
  "stage01_issuer": {
    "genesis": {
      "metadata": {
        "obcv": "0.1",
        "category": "Securities",
        "subcategory,": "Bounded Futures",
        "Nonce": "XXX-XXX",
        "Expiration": "XXXX-XX-XX XX:XX"
      },
      "futures_contract": {
        "item": "Wheat",
        "units": "30 bushels",
        "current_price_per_unit_btc": " 0.02",
        "price_total_btc": "0.6",
        "term_days": "5 days",
        "limit_btc": "0.05",
        "spot_price_source": "http://data.tradingcharts.com/futures/quotes/W.html"
      },
      "issuer": {
        "guid": "b5016e193656d33693a38bc2dbea7c80440c09ee",
        "handle": "drwasho",
        "legal_address": "",
        "pubkeys": {
          "pgp": "xsFNBFMZcEIBEADJlq0oVgLfFDdW9WOBguskPdSSeAfHe4s9w8QlmRuO/Zj548gKfofbM84rtP3rHSOSkeOTsu5GwDt48V/md6gyJ69BTZJkJ6qmxFtGaWVRLP/UD4mavW4EAn3PvWY6X7Z8x36U3j2I6vknH1Ufu5Dh5qvQC3WsMliul9ZxlJQZ1/TkQE+qI/gBPRmsMFZ/xV2VOEjMtM3qOPoemhYFzU39/ra0isk81sXrotySkvWw6zsrx8NrkBaw9mxhs0kumF06AfKSrBjytFIdbJaWtNrCdxJ+NMfzQUHmq9bzpBI2VpNJzFQI4WlO8eRYDS1Z88VxXOjMZchd70JfNNWcXwCUeOA/HUgHO4tWczvb/5/C5pfZRKuDqfOLntcMEzpPxbhAbXvU+K5TK394SGgu9ioXl3rdrFj1B1EBPH2BfnOdwCiOOr5ccWVPUHdG34i4D98ARgeqEDxq9WZwq8FG9rgSszqkmnGQtSZxz8aoW1kU1h1SQumqs2ZUrEoLGACkNg16kRq2z7RBLc4MAm3/GW3ygeEFQxK0PMief0X2+l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464866efbf61c37098440bcdcc88bedf7f1e9c201e294cf3c064d39e372692a0568c01565b838e06af0b"
        }
      }
    },
    "signatures":{
      "pgp": "XXX",
      "bitcoin_key": "XXX"
    }
  }
}

Following the creation of the contract, the buyer would submit a bid offer on the contract. Involvement of the notary along with digitial signatures and counter-signatures would proceed as previously described in our theory work.

Above, drwasho is locking in the purchase (in 5 days) of 30 bushels of wheat at a current price of 0.02 BTC per bushel (total price: 0.6 BTC). As this is a bounded futures contract, drwasho places a limit on his exposure to price volatility equal to 0.05 BTC. In other words, drwasho is going long on wheat, setting a maximum profit/loss margin of 0.05 BTC. If in 5 days the price for 30 bushels is > 0.65 BTC, drwasho will withdraw 0.1 BTC from the multisignature escrow (his original 0.05 BTC and the 0.05 BTC from the losing counterparty). If the price is < 0.55 BTC, drwasho will lose 0.05 BTC from the multisignature escrow address. Remember, the intention of these contracts are to hedge against price volatility, not necessarily trade the full value of the commoditity to be hedged!

Summary

Bounded futures contracts can be easily created and issued over OpenBazaar. The price limits that can be imposed using bitcoin multisignature escrow address enables a significant risk management feature that merchants and buyers can comfortably use to hedge against fluctuations in the price of bitcoin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment