This project has as objective shows how to connect to the websocket and web service of Bitso cryptocurrency exchange using rxjava as a implementation of observer pattern and manipulates the data in real time.
The first window that you can see it's of the loading, works as a splash screen, while the app start.
After load, the app shows the next window
The UI is composed for 5 important parts.
- Header, where we can to stop all the connections and close the application
- Ticks, allows to see the actual upticks and downticks
- The best orders values (Bids and Asks)
- The buy and sell of BTC into the application (simulation)
- Recent trades
The X best bids, best asks and recent trades
Consecutive M upticks and N downticks
build it! the project with maven 👍
git clone https://github.com/haroldjcastillo/btc.git
cd btc
mvn clean install && java -jar btc-ui/target/btc-ui-0.0.1.jar
It's posible to configure the HTTP connection, request and socket timeout in the file /btc/config/pooling.json
{
"connectTimeout": 15000,
"connectionRequestTimeout": 30000,
"defaultMaxPerRoute": 20,
"httpHost": [
{
"hostName": "api.bitso.com",
"port": 808
}
],
"maxTotal": 100,
"socketTimeout": 15000
}
Additional notes:
- The http request for query the trades it's called each 1 second.
- In each Sell or Buy the ticks counter it's restarted.
- By default the X value it's 10 and M and N it's 2
Feature | File name | Method name |
---|---|---|
Schedule the polling of trades over REST. | ScheduleHttp | start() |
Request a book snapshot over REST. | OrderController | loadCurrentOrders() |
Listen for diff-orders over websocket. | OrderObserver | onNext(java.lang.String) |
Replay diff-orders. | OrderManager | diffOrder(java.lang.String) |
Use config option X to request recent trades. | TradeManager | addRecentTrade(com.github.haroldjcastillo.btc.dao.TradePayloadResponse) |
Use config option X to limit number of ASKs displayed in UI. | OrderManager | toSortBook(javafx.collections.ObservableList, List) |
The loop that causes the trading algorithm to reevaluate. | OrderManager | diffOrder(java.lang.String) |