← World

Watching BitCoin Prices

←Blog ·

I'd like to summarize and open source a small project I've strung together from a few open source projects for bitcoin arbitrage trading, log, and chart streaming to the browser.

Given the inspiration from an anonymous friend, I stumbled upon an open source BitCoin Arbitrage trading system on github called blackbird.

One thing lead to another and I couldn't help myself but to take the opportunity to make use of, and test out, auto-devops to Kubernetes via GitLab, which makes it's really easy to deploy new projects just by defining their Dockerfile.

As a developer it's also really handy to have dependencies and versions isolated by using Docker which means I don't need to find a server that can run the language and dependencies required by blackbird, which I might not have.

In this case I wanted to use as much existing tools as possible to get the most bang for the buck, without doing anything from scratch, but staring on the shoulders of giants. And I've yet to execute on the bitcoin trading, but it's been a good excuse to check things out.

Blackbird

I found this C++ application on github that has a bunch of discussion, and contributors. It runs great, and I can use the terminal to view the logs it generates right in GitLab.

In the log file it writes the prices it gets from each of the exchanges every few seconds, an also the current opportunity and strategy details.

It's setup to send an email when a trade occurs (which won't happen in demo-mode), but the problem is that I'd like to interface with this via a browser (obviously). So thinking in the nodejs microservices nature, I searched for a log stream server..

Frontail

By just running, frontail ./output/*, I could get all the blackbird logs right in my browser - great!

Now that's fun and all, but I'd really enjoy being able to visualize these number, so I searched for a chart stream..

Chart Stream

This nice little single page app comes with a server that consumes the prices log file that blackbird outputs, and streams it to the browser - nice!

It's using C3, D3 and EventStream data. Cool stuff.

It took a little configuration to get the options I wanted, to not overload the chart with infinite data, and add time stamps. Plus it had to be black.

Node Http Proxy

I could avoid this in the future, but I wanted to see if I could just get this running on a single docker image to keep databases out of this. Obviously for production, as more of a micro architecture, the web server could run on it's own, reading the data from a database blackbird writes to.

Thus we want to be able to run both http servers, through the same host, using a path like "/logs/" to route to the log server.

Having had great success and experience with node proxy in the past, I decided to go ahead and set it up to do the job. There was a bit of a hickup getting the log app to work configured with a non root path, but it works.

Development

This has been a great chance to test the tech tools and process. Here's a few improvements to the chart that I wanted to make after getting things up and running:

- Invert the colors
- Shift the max x points, so the data doesn't overflow memory.
- Fix the date stamp for the x axis