|
| 1 | +# binance.com websocket client |
| 2 | + |
| 3 | +Client for binance.com public WebSocket APIs. Built with oat++ (AKA oatpp) web framework. |
| 4 | + |
| 5 | +See more: |
| 6 | + |
| 7 | +- [Oat++ Website](https://oatpp.io/) |
| 8 | +- [Oat++ Github Repository](https://github.com/oatpp/oatpp) |
| 9 | +- [Get Started With Oat++](https://oatpp.io/docs/start) |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +This websocket client connects to stream.binance.com, listens to events and prints data to log-output. |
| 14 | + |
| 15 | +Listeners are implemented for the following streams: |
| 16 | + |
| 17 | +- Aggregate Trade Streams |
| 18 | +- Trade Streams |
| 19 | +- Kline/Candlestick Streams |
| 20 | + |
| 21 | +*more detailes on binance.com API [here](https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md)* |
| 22 | + |
| 23 | +### Project layout |
| 24 | + |
| 25 | +``` |
| 26 | +|- CMakeLists.txt // projects CMakeLists.txt |
| 27 | +|- src/ |
| 28 | +| | |
| 29 | +| |- Model.hpp // DTOs for binance.com API models |
| 30 | +| |- AggregateTradesListener.hpp // WebSocket listener for AggregateTrades streams |
| 31 | +| |- TradesListener.hpp // WebSocket listener for Trades streams |
| 32 | +| |- KlineCandlestickListener.hpp // WebSocket listener for Kline/Candlestick streams |
| 33 | +| |- WSEventListener.hpp // Template listener for stream objects. Deserialize received message to an event object. |
| 34 | +| |- WSListener.hpp // Base WebSocket listener. Implements "pongs" and reads messages. |
| 35 | +| |- App.cpp |
| 36 | +| |
| 37 | +|- utility/install-oatpp-modules.sh // utility script to install required oatpp-modules. |
| 38 | +``` |
| 39 | + |
| 40 | +## Build and Run |
| 41 | + |
| 42 | +### Using CMake |
| 43 | + |
| 44 | +**Requires** |
| 45 | +- MbedTLS installed - see [install mbedtls](#install-mbedtls). |
| 46 | +- [oatpp](https://github.com/oatpp/oatpp), [oatpp-websocket](https://github.com/oatpp/oatpp-websocket), |
| 47 | +and [oatpp-mbedtls](https://github.com/oatpp/oatpp-mbedtls) modules installed. You may run `utility/install-oatpp-modules.sh` |
| 48 | +script to install required oatpp modules. |
| 49 | + |
| 50 | +``` |
| 51 | +$ mkdir build && cd build |
| 52 | +$ cmake .. |
| 53 | +$ make |
| 54 | +$ ./ws-client-binance.com-exe # - run application. |
| 55 | +``` |
| 56 | + |
| 57 | +## Install MbedTLS |
| 58 | + |
| 59 | +```bash |
| 60 | +git clone -b 'mbedtls-2.16.1' --single-branch --depth 1 --recurse-submodules https://github.com/ARMmbed/mbedtls |
| 61 | + |
| 62 | +cd mbedtls |
| 63 | +mkdir build && cd build |
| 64 | + |
| 65 | +cmake .. |
| 66 | +make install |
| 67 | +``` |
| 68 | + |
0 commit comments