Fun side project that fetches cryptocurrency orderbooks, computes arbitrage opportunities and show cool D3 charts.
Technical stack includes:
- Golang
- MySQL 5.7 (with JSON support)
- React
- React Router
- Material UI
- Browserify
- Vagrant
- Ansible
- Google Compute Engine
Install
Vagrant Install
Install VirtualBox, Vagrant, and Google Cloud SDK.
Create the Vagrant machine:
$ vagrant up
Connect to the VM:
$ vagrant ssh
Create the MySQL database:
$ sudo mysql -u root < db/init.sql
Start the Services
You first need to compile the Go code and build the JavaScript application:
$ cd /vagrant
$ make
Now you can start the record
service which fetches Bitcoin orderbooks from several exchangers:
$ bin/record
Start the web
service that powers the UI and provides the API (you will need another SSH session):
$ bin/web -b 0.0.0.0:8080
Open your browser and point it at localhost:8080
Note: you will need to run make and restart the services each time you make a change to the code.
Deploy the Code on GCE
Install Ansible
$ git clone git://github.com/ansible/ansible.git --recursive
$ cd ./ansible
$ source ./hacking/env-setup
$ git pull --rebase
$ git submodule update --init --recursive
$ sudo make install
Create the Server
Create the VM, the disk and provision the VM:
$ ./ansible/server-create.sh
Connect to the MV and initialize the MySQL database "manually":
$ gcloud compute ssh bitbot-1
Deployment
You can test deployment playbook with vagrant:
$ ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key -i ansible/vagrant_host ansible/deploy.yaml --extra-vars "project_dir=/vagrant dev=true"
Configure gcloud ssh (only once):
$ gcloud compute config-ssh --project the-bitbot-project
Run ansible-playbook:
$ ansible-playbook -i ansible/gce_host ansible/deploy.yaml