How to create a provably-fair high risk financial product with live data feeds provided by oracles.
Introducing Binary Options
This time, we gonna gamble. We will construct a financial product, more specifcally: a binary option, European style, cash-or-nothing.
Binary options are “a type of option in which the payoff is structured to be either a fixed amount of compensation if the option expires in the money, or nothing at all if the option expires out of the money” , therefore cash-or-nothing. European style means the option “can only be exercised at the end of its life, at its maturity” .
This is a high risk product which is “most likely traded over the Internet on platforms existing outside of regulations” , so “the customer is betting against the broker, who is acting as a bucket shop.” 
In general, this means that “because these platforms operate outside of regulations, investors are at greater risk of fraud”  and “manipulation of price data to cause customers to lose is common” .
So, in contrast to common regulated financial products we have a really comprehensible option, which is mostly valued as high-risk, because there is a real clash of interests if the broker also evaluates the stock against the strike price and thus is highly motivated to manipulate this evaluation.
Smart Contracts to the Rescue
So, can smart contracts help here? You bet! The blockchain is trust-less, so you just don’t have to trust anyone, be it broker or bucket shop or both, but you can just prove if everything’s ok.
If a smart contract guarantees you that you will get 195% if you predict correctly and 0% if not, this rule has to be implemented in the contract.
Meeting the Oracle
Given that we can trust the contract, it should be easy to implement a binary option like this:
After deploying the contract, you have 1 hour to invest Ether on calls or puts on the contracts conditions (eg. DAX is above the strike price in 1 hour). After the 1 hour offering period, it's rien ne va plus, no purchase of calls or puts are possible. At this point of time, the current value of the DAX is stored. After exactly 1 hour the DAX is evaluated against the stored DAX value.
- if the value is above or equal to the stored value, all calls are returned 195% of their investment, all puts lose all invested money
- if the value is below the stored value, all puts are returned 195% of their investment, all calls lose all invested money
Sounds simple? It is!
You can easily prove that the contract actually implements the described rules, but there are two problems: how does the contract know the DAX spot? Contracts in Ethereum intentionally cannot connect to the outside world, therefore the outside world has to call the contract and provide the necessary data. Who tells the contract the exact time it has to retrieve the DAX spot? There must be some callback mechanism, since Ethereum smart contracts are not able to call themselves, have a Daemon, Threading etc.
Let’s gonna oraclize.it
There is a startup solving this problems in a elegant way: oraclize.it
You should look up and understand how oraclize.it works and helps us to solve our problems. In short, callbacks are used by oraclize.it and you can determine the exact data feed of the data which oraclize.it will provide at a certain point of time to our contract.Here the two problems are addressed:
- The contract has to provide a callback for the oracle to call. The data feed is configured when the callback is provided, as well as the time interval.
- The oracle facilitates a scheduling to call the provided smart contract callback at the configured time interval.
Both solutions require the user and the contract owner to actually trust the “trusted datasource” (the contract’s user can decide if he trusts this datasource) and the oracle itself to have a working scheduling and not to manipulate the data. In contrast to the “broker” above, the oracle has no interest in manipulating the data.
However, oraclize.it not only offers a service, but even more defines a protocol, so there will most likely be more than one oracle to choose from to offer redundancy in the future.
Building Binary Options in Ethereum Studio
…in the next post.
Realizing how long this post already is, we decided to split the tutorial and the theoretical part. The tutorial will follow soon! Please let us know in the comments if you’d like to have this tutorial and what you expect of it.
Meanwhile, try out this ether.camp tutorial which describes the integration of oraclize.it into Ethereum Studio.