Skip to content

RHDZMOTA/bitso-trades-consumer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitso Trades Consumer

This is a scala application that consumes real-time trades from the bitso exchange.

Bitso exposes a web-socket API for live data retrieval. In this application we consume the trades 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-trades-consumer.git
    • cd bitso-trades-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-trades-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.trades (
  id bigint, 
  book text, 
  received timestamp, 
  arrival int, 
  amount double, 
  rate double, 
  value double, 
  maker_side_action text, 
  maker_order text, 
  taker_order text,
  PRIMARY KEY (id, book, received, arrival)
  );

Authors and contribution

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

Authors:

License

See the LICENSE.md file.