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:
GENIUS.
— Josh Wolfe (@wolfejosh) March 11, 2018
Emotionally choreographed to historic price of Bitcoin.
(Tip: put sound on)pic.twitter.com/lCQ2Ia1mgi
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:
- Try with an algorithm based on my strategy without learning. Just a couple of rules that triggers the sell or buy action.
- Use a neural network that may predict the price for an asset in the following X minutes and take some decision on that.
- Use another neural network that feeds from all the predictions from the previous and gives a score for buying
- 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:
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:
- Create a virtual exchange to simulate the behavior of a real one: place an order and wait to see if it's fulfilled
- Add logic to the players to run a simulated game where they can buy and sell assets