A real time VWAP calculator using the Coinbase websockets as data provider. This calculate the VWAP by trading pair.
An output example:
vwap.calculator | 2022/02/19 20:20:07 websocket connected to: wss://ws-feed.exchange.coinbase.com/
vwap.calculator | 2022/02/19 20:20:07 collecting datapoints for pairs: BTC-USD,ETH-USD,ETH-BTC | interval: 200
vwap.calculator | 2022/02/19 20:20:08 map[BTC-USD:40065.189999999995 ETH-BTC:0.06886 ETH-USD:2758.5899999999997]
vwap.calculator | 2022/02/19 20:20:08 map[BTC-USD:40065.189999999995 ETH-BTC:0.06886 ETH-USD:2758.5899999999997]
vwap.calculator | 2022/02/19 20:20:08 map[BTC-USD:40065.189999999995 ETH-BTC:0.06886 ETH-USD:2758.59]
vwap.calculator | 2022/02/19 20:20:09 map[BTC-USD:40065.19 ETH-BTC:0.06886 ETH-USD:2758.59]
vwap.calculator | 2022/02/19 20:20:09 map[BTC-USD:40065.19 ETH-BTC:0.06886 ETH-USD:2758.59]
vwap.calculator | 2022/02/19 20:20:09 map[BTC-USD:40065.189999999995 ETH-BTC:0.06886 ETH-USD:2758.59]
vwap.calculator | 2022/02/19 20:20:09 map[BTC-USD:40065.19520585874 ETH-BTC:0.06886 ETH-USD:2758.59]
vwap.calculator | 2022/02/19 20:20:09 map[BTC-USD:40065.1960835862 ETH-BTC:0.06886 ETH-USD:2758.59]
...
./coinbase/
contains all the code to connect to coinbase and get the real-time data. docs./vwap/
contains all the logic to calculate the VWAP indicator using the data received from Coinbase.
The command has two optionals flags
interval
: The sliding window to calculate the VWAP indicator. Default value: 200pairs
: a comma separated strings of cryptocurrencies pairs. Default valueBTC-USD,ETH-USD,ETH-BTC
./vwap_calculator -interval=50 -pairs=SOL-USD
make sure that you have go version 1.17
make run
make build
and then
./vwap_calculator
and finally
make clean
The VWAP calculator will run automatically
docker-compose up --build
You can execute the entire suit running the following command
make test
- This project run the tests using GitHub actions. Check the workflow runs here