/bitso-market-consumer

Scala consumer of Bitso market data.

Primary LanguageScalaApache License 2.0Apache-2.0

Bitso Market Consumer

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

Dependencies

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).

Usage

Consider editing the application.conf file according to your needs.

Instructions:

  1. Clone this repository and enter to the project dir:
    • git clone https://github.com/rhdzmota/bitso-market-consumer.git
    • cd bitso-market-consumer
  2. Edit the configuration file if needed.
    • vim src/main/resources/application.conf
  3. Run the application:
    • Using SBT: sbt run
    • Using java:
      • Create a fat-jar: sbt assembly
      • Run using java -jar

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

Databases

Currently there's only support for Cassandra Database. Although support for any other database should be straightforward (see the com.rhdzmota.service.database package).

Cassandra

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)
);

Authors and contribution

Feel free to contribute by opening an issue or sending a PR.

Authors:

License

See the LICENSE.md file.