Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/letsila/vwap
- Owner: letsila
- License: mit
- Created: 2021-12-04T15:49:24.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-06T17:12:32.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T03:37:49.746Z (5 months ago)
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.## 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
```