This is a scala application that consumes real-time market data from the bitso exchange.
Bitso exposes a web-socket API for live data retrieval. In this application we consume the market data of the following coin pairs:
- btc/mxn
- eth/mxn
- xrp/mxn
- ltc/mxn
- bch/mxn
- tusd/mxn
You'll need sbt (scala build tool) to run/compile this project. We use the Akka Toolkit (e.g., streams, http, actors) to generate a websocket connection with Bitso and create a stream for decoding the data. We use Circe for decoding the json text messages into Scala objects and Alpakka for connecting to the database (sink).
Consider editing the application.conf
file according to your needs.
Instructions:
- Clone this repository and enter to the project dir:
git clone https://github.com/rhdzmota/bitso-market-consumer.git
cd bitso-market-consumer
- Edit the configuration file if needed.
vim src/main/resources/application.conf
- Run the application:
- Using SBT:
sbt run
- Using java:
- Create a fat-jar:
sbt assembly
- Run using
java -jar
- Create a fat-jar:
- Using SBT:
Note that the resulting jar
is on the target/scala-*
directory.
To execute the application with java use something similar to:
java -jar target/scala-2.12/bitso-market-consumer-assembly-1.0.0.jar
Currently there's only support for Cassandra Database. Although
support for any other database should be straightforward (see the
com.rhdzmota.service.database
package).
Open the Cassandra CLI with cqlsh
on a terminal
and create the keyspace and table:
- Create the keyspace:
CREATE KEYSPACE bitso WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':1};
- Create the table:
CREATE TABLE bitso.market (
book_id uuid,
received timestamp,
arrival int,
book text,
order_id text,
rate double,
amount double,
value double,
position text,
milliseconds bigint,
status text,
PRIMARY KEY (book_id, position, arrival, milliseconds, order_id, received, book)
);
Feel free to contribute by opening an issue or sending a PR.
Authors:
See the LICENSE.md
file.