Tech, Weekend Projects

These are the crazy things we built as a result of fooling around with Cryptocurrency

9 January 2018
Image uploaded from iOS

Unless you were living in a cave for the past year, you would probably have heard of Bitcoins, or cryptocurrency in general.

Cryptocurrencies are digital currencies made possible through the use of encryption algorithms to create a decentralized and public data store (also known as a ‘blockchain’). This blockchain is resistant against manipulation by any single party, hackers or other forms of cyber attacks. Eventually, this technology evolved to be used as a protocol for the first ever online currency that is not backed by any governments or banks, also known as ‘cryptocurrencies’.

https://www.pwc.com/us/en/financial-services/fintech/bitcoin-blockchain-cryptocurrency.html
Source: PWC

Opinions on Bitcoin and cryptocurrencies around the world are divisive. While there are many who view cryptocurrency as one of the largest change-maker in human history, there are also many who think that it is purely a scam bound to collapse soon.

Nevertheless, as technologists who pride ourselves to be constantly at the forefront of developments in information technology, we could not resist getting our hands dirty with cryptocurrencies.

We started off pretty simple – by pouring over the massive treasure trove of information online to understand how cryptocurrencies such as Ethereum and Bitcoin work, their underlying technology and protocol, and their possible limitations, capabilities as well as usage scenarios.

After this was when the crazy stuff begins. Here are some things we tried over the past few weekends:

We wrote a bot that makes money for us.

One of our clients, Systematica Investments, deals primarily in algorithmic trading. One of my (Calixto, Managing Director) majors is in Financial Technologies too.

This combination inspired us to try our hands at writing a bot that could automatically trade Bitcoins. After all, it is everyone’s dream to sit back, relax, sip a cup of coffee while a robot makes money for you, isn’t it?

So we took up an account on Bitfinex, one of the largest cryptocurrency exchange that also has an extremely well-established set of application programming interfaces (APIs), which enable us to write bots that can be hooked onto that exchange.

Trading bots thrive on mathematical models – if you can figure out the various markers and signals that predate any significant market movement, your bot can automatically crunch the numbers and act on them. Serious algorithm trading firms spent millions if not billions of dollars on research and analysis to come up with robust mathematical models that support their bots. These models are also closely guarded trade secrets; firms will stop at nothing to protect this asset.

We are technologists, not mathematicians, so we know we are out of our depth here. What our Chief Technology Officer (CTO), Torin, did instead was to produce a rather simple bot that does the following:

  1. Buy Bitcoin a price X.
  2. If market price increased by Y%, sell it and take profit
  3. Repeat 1 and 2.

This bot was written with NodeJS, and also with the very bullish assumption that the price of Bitcoin would always go up. We ran the bot with an order size of USD$50 each time, just to test the idea in case we go bankrupt because of a programming bug.

The bot ran well for a couple of days, earning a few dollars a day based on a $50 capital, before we hit our first snag – Bitcoins price started trending downwards, leaving our bot stuck forever holding onto the bitcoin purchases waiting for (2.) to happen.

Eventually though, we were able to come up with a much smarter algorithm to handle when the price starts dipping, as well as run and manage multiple concurrent trades.

After two weeks, we conducted a stock take of our profits and realized something alarming: we actually earned less than what we would have if we simply just bought and held the coins. After analyzing some numbers, we realized this was due to the transaction fees that the exchange charges for every order; in the end, our bot was working hard to make money for Bitfinex – not us!

We decided to abandon this project at this point and to just buy up some of the coins we think had potential.

Which brought us to our next project, the Bitcoin Buddy.

Yeah, we made a Bitcoin Chatbot.

buddy

Now that we have had decided to just buy and hold cryptocurrencies, knowing the latest price at all times becomes important. We also wanted to know if the coins are currently in the middle of a uptrend or downtrend, and the strength of those trends. Thus, we built a messenger chatbot for that.

Chatbot development is one of the latest addition to the growing list of capabilities we have as a company, and many of our clients are also exploring to have a bot of their own.

While Torin prefers to develop backend in the hippy NodeJS language, I am more old-school and my language of choice is PHP. After having the idea for a Bitcoin price monitoring chatbot, I spun up ‘Swag’, our in-house PHP framework that we use in 80% of our client projects.

Swag allows us to save a lot of time (and our client’s money) when it comes to developing backend systems that power our chatbots and mobile apps as we have collected years and years of commonly used and highly reusable libraries written by our developers across all the projects we have done so far.

In two hours, I had a rudimentary chatbot working. Using the leading Natural Language Processing technologies from Google to understand users’ queries, it retrieved the latest Bitcoin price from Coinbase, and conducted machine learning to analyze the price movement over the past 60 minutes to determine if the price is currently on a upward or downward trend.

You can check out our Bitcoin chatbot, Bitcoin Buddy here.

Then we got a little too obsessed.

Cryptocurrency prices are pretty volatile. I was once looking at Bitcoin Cash (a fork of the Bitcoin cryptocurrency) when it was at USD 2,700 but abruptly, it dived to USD 1,900 the next instance.

Eventually, we felt that our good friend, the Bitcoin Buddy chatbot, was too slow for the job. We needed something that allows us to keep tabs on the latest cryptocurrency prices with one look or minimal interaction, even as we were slogging away in the office; something more ‘glanceable’.

We are no stranger to building such highly ‘glanceable’ interfaces. Our mobile app, SG BusLeh, now used more than 7 million times every single month, was designed to be extremely fast and easy to understand at a glance. After all, time is of utmost importance when trying to board the bus to get to work or school on time.

The same goes to dashboards we have built for clients where complex information are displayed smartly to be understood with a glance.

dashboards

Pulling from such experiences, we set out to work building a simple cryptocurrency price dashboard that allows anyone in the office to easily look up the latest price. This is the result:

Image uploaded from iOS

Powered by a Mac Mini that is also our enterprise build server, this crypto-dashboard we built provides us with real-time information on the prices of cryptocurrency that we have interest in.

However there is one serious problem – if we have such a setup at home, our wives will scold us for “wasting” electricity to power this dashboard!

So Torin set out to work his magic again, this time making use of his electrical engineering and IOT hardware experience.

It’s time for Internet-0f-things (IOT)!

We needed a constantly-running, low-power device that could display the latest cryptocurrency without the risk of driving up the electrical bills from high power consumption and our wives’ persistent nagging care to safeguard the interests of the household.

With a NodeJS backend, a few LED dot matrix panels and Arduino (the brain of the device), Torin came up with this:

26233014_10155984191942902_7277527444887354586_o

 

Ignore the big black device below the panel (that’s just my home theatre system); the actual device he built is contained entirely within just the LED panel you see above.

We fondly call it the ‘MoneyScreen’. Yeah, developers are just really straight-to-the-point.

The picture below shows the back of the device:

26001160_10155956250527902_1312305213909995239_n

Our wives finally gave us the stamp of approval to place this in our houses as the entire device is powered purely by a single mobile phone charger.

How does it work? Our custom NodeJS backend functions as a cloud-based server for MoneyScreen, allowing us to remotely control and update the currencies displayed on each screen. We also wrote a custom script in Arduino that automatically connects to our homes’ wifi hotspots, looks for our NodeJS server on the cloud and then displays the numbers on the screen. The LED panels and Arduino are hand-soldered together to keep the unit as compact as possible.

If you are interested in MoneyScreen, we are making some very limited quantity for sale in Singapore. More details can be found on my Carousell listing.

Entering the mineshaft

You have a bunch of hardcore technologists playing around with cryptocurrency. What is the next logical step (debatable), other than writing our own dapps (apps on the Ethereum blockchain)? Mining cryptocurrencies of course!

What is cryptocurrency mining? Due to the decentralized nature of cryptocurrencies, the entire currency network or protocol requires a large number of machines working together constantly to process and verify transactions. This process is done independently by machines around the world, ensuring that single individual or organization could tamper with the transaction data.

However, people don’t just voluntarily put up machines to process these transactions for nothing. This is why most cryptocurrencies have a reward mechanism: if you help to process transactions, you will get a financial reward. This is how ‘mining’ works.

 

 

26732942_10156118104257028_1563249465_o

On this note, we have just received our first Ethereum mining rig, the Powercolor RX570 8GB. The 6 blocks of hardware you see at the top of the rig are the AMD RX570 8GB graphic card, a high-end graphic card that could make any gamer go crazy if there are just one or two such graphic cards in a normal personal computer.

We have 6 of that in a single rig alone.

Within hours of setting it up, Torin was able to join a well-regarded mining pool, Ethermine.org. A mining pool is a large collection of mining rigs working together to share mining rewards.

Based on our calculation, this SGD3,700 rig can mine about 0.6ETH coins every single month, which is about USD720 value or SGD1000. After subtracting electricity bills, this rig should break even in about 6 months or less.

As with all hardware that has to run 24/7, such as our company’s application servers, we need a way to closely monitor the health and status of the machines.

Torin has started building a monitoring dashboard that can track various parameters on our rig, such as power consumption, temperature, processing power and amount mined. We intend to expand this into something more comprehensive as we acquire more rigs.

Yes, we will be acquiring more rigs in the near future – more ETH rigs are coming, as well as the Antminer S9, a specialized mining rig that was custom-developed and built for the sole purpose of mining bitcoins.

More To Come

This concludes the semi-detailed breakdown of our explorations into cryptocurrency over the past 6 weekends or so. Cryptocurrency and its related technologies remain an interesting channel and side project for us to expand our knowledge, challenge our abilities, or simply, to explore what is out there.

Ultimately, explorations like these help us sharpen and tune our senses to the latest IT development and also, serve our clients better. We can’t wait to see what’s next.

Interested to transform your organisation through information technology or turn your dreams into reality? Reach out to our consultants and technologists at hello@originally.us today!

Leave a Reply