Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/letsila/vwap

Real time crypto VWAP calculator
https://github.com/letsila/vwap

Last synced: about 14 hours ago
JSON representation

Real time crypto VWAP calculator

Awesome Lists containing this project

README

        

# VWAP calculator
A realtime VWAP calculator of crypto currencies. It uses coinbase as its default provider for real time data over websocket.

screenshot

## Design
The service in `./internal/service.go` is composed of two main components:
* A websocket client that pulls data off an exchange.
* The default choice is coinbase.
* Any exchange can be used as long as it implements the client interface defined in the websocket package.
* A list of data points defined in the VWAP package.
* The VWAP calculation is performed each time a data point is pushed to the list and saved in a hash map for each trading pairs.
* We don't loop over the datapoints so the VWAP calculation is done in constant time, O(1).

## Configuration
The following flags are available while running the project through CLI using the binary.
* `trading-pairs`: a comma separated strings of crypto currencies pairs, default is set to `BTC-USD,ETH-USD,ETH-BTC`
* `ws-url`: the URL of the websocket server to use, default is coinbase websocket URL.
* `window-size`: the sliding window used for the VWAP calculation, default is set to **200**.

## Decimal
For precision sake we used https://github.com/shopspring/decimal for all calculation.

## Run it
First, make sure that you have go version 0.17 installed on your machine. Then ...
```
make run
```
or
```
make build
```
then ...
```
./vwap -ws-url "" -trading-pairs "" -window-size
```

## Tests
* Runs all the tests.
```
make test
```
* Runs the unit tests.
```
make test-unit
```
* Runs the integration test.
```
make test-intergration
```