Gamification of my digital currency assets

March 30, 2018 bitcoin

To predict a digital currency price, can be thought as an optimization problem where you have to find the optimal solution that gives you more benefit. Nowadays this is usually addressed using some kind of Machine Learning algorithm, that can vary from a Neural Network to an Evolutionary algorithm or something in between. It's important to understand that there's no correct answer and every day you can find new different ones. Besides, when speaking of digital currency, its pretty much unpredictable:

As many optimization problems, one good solution is to consider all the alternatives and make them compete. The approach is similar to an evolutionary system but simpler: not representing the solution as a gnome, neither considering mutation or any other concept related to Evolutionary Algorithms. Instead, just model a game where the best strategy gains the control of the wallet, while the others will use a virtual one.

Thinking of strategies (or we can call them players), there might be different ones to try:

  1. Try with an algorithm based on my strategy without learning. Just a couple of rules that triggers the sell or buy action.
  2. Use a neural network that may predict the price for an asset in the following X minutes and take some decision on that.
  3. Use another neural network that feeds from all the predictions from the previous and gives a score for buying
  4. Create a classifier that may tell me whether or not to buy based on the gain that I might get.

For all of this options, I can also think on different approaches, but there's also a simple alternative that can also be a good one: Do nothing. This is the simplest one, but it might be effective and can work as a protection strategy in case my algorithms behave bad and make me loose money.

Sketching the idea:

One thing that impacts the design is that the API to get information from the assets have limitations. In case of Exchange API there's a limit of 1200 request per minute, 10 orders per second and up to 100000 orders per day (you can check here). In order to reduce the amount of requests, only one process will fetch all the information required by any of the players and broadcast it to each player.

This allows me to draw each player's budget (in BTC). For that I'm using ElasticSearch + Kibana, since I have experience in both and it's useful to draw values or date in time, but also it's good to store and search data. I created different players with fancy names but no specific logic to try to draw their budgets, and this is more or less how it looks:

Each player budget

After the game will invoke each player's logic, so that each one decides whether they want to put an order or not, and that graph will start looking more fun.

Also, another thing I'm interested in seeing is the relative gain or loss of each asset. Having ElasticSearch + Kibana in place it's easy and this is the result:

Next steps:

  1. Create a virtual exchange to simulate the behavior of a real one: place an order and wait to see if it's fulfilled
  2. Add logic to the players to run a simulated game where they can buy and sell assets

Profile picture

Written by Gastón Fournier Software Engineer at @getunleash working from Cunit, Tarragona, Spain, where I live with my wife and 2 dogs. Find me on Twitter Github LinkedIn