Melonport and Streamr: Decentralized trading by robots?

At EDCON Paris 2017, we met Mona El Isa and were struck by the ingenuity of the Melonport vision: a platform for asset management on the blockchain which allows anyone to set up well-designed, trustworthy funds and portfolios of digital investment instruments. Quite revolutionary!

Saying so is by no means a simple platitude. As mentioned in a previous blog post, we Streamr principals are all finance professionals from the “old world”: One algorithmic trader, one trading platform architect, and one with a distinguished background in institutional and quantitative asset management.

Armed with a certain understanding of the terrain, we could immediately see the usefulness of the Melon project, and also how Streamr could complement it. In this blog post, we outline some early ideas that spring to mind.

Data, data, data…

As described in our whitepaper draft, Streamr’s DATAcoin vision is one of a decentralized data backbone for Ðapps. The Streamr stack includes a data transport layer based on a peer-to-peer network, a data market above, and a processing engine and usability layer as the cherry on top. Melon funds will thrive on high-quality, professional financial data, which we have precisely the means to provide. In concrete terms, this is about building datafeed modules as per the Melon protocol, something we know how to do and are very much excited about.

So yes, Streamr can act as a data source for Melon, but Melon can equally well act as a data source for Streamr. An important part of the Streamr roadmap is the marketplace for real-time data, and lots of highly relevant data will be generated by live asset management processes in Melon. Such data includes portfolio holdings, valuations, transactions, and the like. Streamr can be the conduit whereby such data are easily made available to relevant and authorized recipients.

Algorithmic trading

Quantitative investing based on computerized trading algorithms is an increasingly popular and successful way to put money to work. Hedge funds such as Citadel, Millennium, AQR, Renaissance Technologies, D.E. Shaw, Two Sigma, AHL, Winton, and many others have a long and enviable track record. And quantitative investing is by no means limited to CTAs and hedge funds. Many of the world’s largest asset managers and financial institutions offer quantitative funds and investment products.

Systematic strategies can be used for many purposes, ranging from long-term, rule-based investing to medium or high-frequency strategies which aim to exploit potential inefficiencies or which take advantage of various risk premia. Quantitative investment is a fascinating field with lots of clever people working on great ideas. Many of the strategies and certainly much of the actual code is, of course, proprietary. But if you want to get a flavour of what works, you could do much worse than start with Antti Ilmanen’s highly rated and very readable treatise on Expected Returns.

This is also a space where innovation is making waves. Disruptive platforms such as Quantopian and QuantConnect allow anyone to try their hand at quantitative investing. Numerai and Quantiacs offer outlets for data scientists who want to apply their skills to real-life investment decisions. For new entrants to the world of computer-driven investing, barriers are lower than ever before.

There is of course no reason to assume that investment decisions will always be done by human beings. As it is, many quantitative strategies have been automated and computerized for more than two decades by now. This is often a necessity, given that human traders are simply too slow to find and act upon many fleeting opportunities.

Computerized trading systems — or robot traders for want of a better word — have a somewhat sinister reputation by association with things like dark pools and flash crashes. But there is no reason why robot traders — or swarms of decentralized robot  traders — cannot make long-term investment decisions. And there is a very real possibility that our dedicated trading robots with clever software will make much better decisions than we humans with our all-too-emotional wetware.

All change, please

If you have the investment ideas and the market knowledge, it is easy enough to get started. You need some amount of capital, the ability to code in Python, Matlab or the like, an account with a financial broker, and a platform where you can try and out and simulate your ideas, and even build your very own trading robot. But what about the next step? Even if you can accumulate a respectable live track record, how do you scale up and set up a professional trading operation?

The unfortunate reality is that setting up a fund used to be costly and time-consuming. Typically more than half the cost of running an asset management operation is spent on support functions, including fund administration, portfolio valuation, risk management, performance and management fee calculations, compliance monitoring, and reporting.

Unless you already started rich, you would need to raise tens of millions of outside capital to cover the costs of institutional money management. Enter Melon, and things are suddenly different. The time, effort, and cost can be cut by orders of magnitude. For aspiring money managers, this is exciting indeed!

Automating the asset management process

Where does all this lead to? Would it not be great if any asset manager could easily and reliably automate their investment process? We believe that Melon provides the right elements for making such a vision a reality.

One highly useful property of the Melon protocol is its modular design. This makes it amenable for use through a web portal with an advanced user interface. Imagine building a new fund in a drag-and-drop fashion: Pick the relevant valuation and risk management modules from professional and reputable third parties, choose data modules for financial market data and other inputs, adjust parameters, run backtests and simulations, build the whole process visually in a low-code front-end.

There is, of course, one such web portal already, i.e. the Melon portal. Our good friends at Melonport tell us that the portal is open and free for anyone for customization and white labelling. The Melon portal is a great starting point, and you can add any kind of functionality on top: An off-chain processing engine, integrations to data providers, know-your-customer (KYC) processes, backtesting capabilities, algorithmic trading tools — the possibilities are endless. And as it happens, Streamr is very well placed to provide such additional functionality, given our existing tools, the technology stack, and the skills.

There are huge potential gains here in terms of lower cost, lower barriers to entry, higher efficiency, transparency, reliability, and trust. Melonport is embarking on an exciting journey, we wish them the best of luck, and will contribute to their effort where we can.

In a future blog post, we will go into specifics and implement a Streamr DataFeed module using the Melon protocol. Who knows, we might even get carried away and show how to create an automated robot trading strategy for systematically investing in popular cryptocurrencies. Watch this space, and in the meanwhile, Aux Barricades Citoyens!

Posted by / June 30, 2017

Watching the flippening on Twitter with Streamr and Oraclize

We’ve met with the Oraclize people a few times, and we love what they do. There are also important synergies in what Streamr and Oraclize can do together. Let me explain, and show an example.

For fun, and to demonstrate Streamr and Oraclize working in tandem, we built a little example that watches the flippening (Ethereum potentially overtaking Bitcoin as the leading blockchain) in real-time. This idea was inspired by flippening.watch, which lists many metrics such as market cap and number of transactions, but none related to social media. So we chose to add some analytics using social media data. Using the streaming Twitter API and Streamr we build a process that listens to raw tweets mentioning either Ethereum or Bitcoin, counts the tweets in various timeframes, and makes the results available from our API. Later in this post, we’ll query this data from a smart contract.

Just to show you what the data currently looks like, here’s a table of real-time Twitter statistics, as received from our streaming API:

Window Ethereum tweets Bitcoin tweets Flippening
1 min
1 hour
24 hours


In the Streamr Engine, there’s two ways to convey data to smart contracts. The first method is event-driven: sending transactions directly from the Canvas via the EthereumCall module (see this or this example). The second option is to query for data from our web API when needed. This is preferable in use cases where a smart contract needs the data upon request instead of being constantly notified about the newest data.

Oraclize can easily facilitate this. They offer a request-response bridge between the blockchain and any web API such as Streamr’s. A smart contract can call a function on the Oraclize smart contract in order to request for data from a source such as an URL. Their off-chain system watches for these calls, and when one occurs, they go ahead and fetch the required data, and send the response back to the requesting smart contract by calling its callback function. Oraclize can even generate a proof if required, cryptographically showing that the data really came from our web API.

The results are being calculated from raw tweets using a canvas that counts the tweets in 1 minute, 1 hour, and 24 hour rolling windows and produces the results to a new stream. The result stream can be listened to by external applications, similarly to how this web page subscribes to it to show the table above. However, events in the stream can also be queried via our HTTP API. The following URL returns the latest event in the stream:

https://eth.streamr.com/api/v1/streams/I1AWyGXDRg28AO33ztPBZg/data/partitions/0/last?wrapper=object&content=json
To enable a smart contract to get the latest data on demand (for betting purposes, for example 😊), you can use Oraclize. Below is an example for Ethereum, written in Solidity. It requests Oraclize to fetch the current statistics from the Streamr API by calling the oraclize_query function. The result is soon thereafter delivered to the __callback function by Oraclize:
pragma solidity ^0.4.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

contract StreamrFlippeningDemo is usingOraclize {

    string public latest;

    event newOraclizeQuery(string description, uint256 fee);
    event newFlippeningData(string data);

    function StreamrFlippeningDemo() {
        // update();
    }

    function __callback(bytes32 myid, string result) {
        if (msg.sender != oraclize_cbAddress()) throw;
        latest = result;
        newFlippeningData(latest);
    }

    function update() payable {
        uint256 fee = oraclize_getPrice("URL");
        if (fee > this.balance) {
            newOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee.", fee);
        } else {
            newOraclizeQuery("Oraclize query was sent, standing by for the answer..", fee);
            oraclize_query("URL", "json(https://eth.streamr.com/api/v1/streams/I1AWyGXDRg28AO33ztPBZg/data/partitions/0/last?wrapper=object&content=json).0.content.flippening_24h");
        }
    }
}

Streamr Editor is a low-code environment that allows users to build data-driven processes visually using drag and drop. Below, you can see the Canvas that counts tweets for the various time frames on both source streams, and produces the result into another stream (click here to open in full screen):

Take a look at our white paper draft if you want to dig deeper into our stack. In the draft we explain how streaming data can be tokenized and traded in the peer-to-peer Streamr Network powered by a token called DATAcoin. As all data in the Streamr Network will be signed at the source, smart contracts always receive trusted data from the real world. In this scenario, Oraclize can act as a valuable request-response bridge which natively supports data queries from the Streamr Network.

This simple example is just a taster, but it should immediately help you get started in building data-driven smart contracts. There’s so much more that can be achieved using Streamr and Oraclize either together or separately, depending on the use case. We’ll be hard at work in making the data-driven decentralized vision a reality!

Questions and comments about this post and Streamr in general are appreciated! Join us on Slack, and of course feel free to follow us on Twitter as well.