https://github.com/khaliullov/coinbasevwap
Calculate VWAP for 200 last transactions of trading pairs
https://github.com/khaliullov/coinbasevwap
btc clean-architecture coinbase golang vwap websocket
Last synced: 5 months ago
JSON representation
Calculate VWAP for 200 last transactions of trading pairs
- Host: GitHub
- URL: https://github.com/khaliullov/coinbasevwap
- Owner: khaliullov
- License: unlicense
- Created: 2021-12-27T17:42:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T14:27:18.000Z (over 4 years ago)
- Last Synced: 2024-06-20T03:32:01.276Z (about 2 years ago)
- Topics: btc, clean-architecture, coinbase, golang, vwap, websocket
- Language: Go
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coinbase rate VWAP
[](https://github.com/khaliullov/coinbasevwap/actions/workflows/test.yml)
[](https://coveralls.io/github/khaliullov/coinbasevwap?branch=master)
[](https://goreportcard.com/report/github.com/khaliullov/coinbasevwap)
Application that calculates VWAP in a real-time using Coinbase websocket
steaming protocol of cryptocurrency transactions updates.
Calculated values of VWAP are streamed to os.Stdout for each trading pair.
By default, application subscribes for BTC-USD, ETH-USD and ETH-BTC
trading pairs.
## Synopsis
$ go run main.go -help
INFO[0000] Coinbase rate VWAP.
-capacity int
Capacity for storing data for VWAP calculation (default 200)
-channel string
Channel to subscribe to (default "matches")
-feed-url string
Coinbase feed URL (default "wss://ws-feed.exchange.coinbase.com")
-help
Show help
-log-level string
Logging level (default "error")
-products string
Products to subscribe to (default "BTC-USD,ETH-USD,ETH-BTC")
## VWAP
In finance, **volume-weighted average price (VWAP)** is the ratio of the
value of a security or financial asset traded to the total volume of
transactions during a trading session.

In this application the VWAP is calculated per trading pair using
a sliding window of last 200 data points (Could be configured).
## Architecture
Application uses clean architecture. Some of open-source projects was used
to build application. Websocket client is a state machine which subscribes
and unsubscribes from feeds with trading pair transaction updates.
Consumer is subscribed for such updates from Websocket client and supplies
data to use-case which calculates the VWAP of offered trading pair and
stores it in a repository. Storage is like a cyclic buffer and stores last
200 data points.
## Developer instructions
### Building
To build application run:
make
or
make BINARY_NAME=vwap build
### Testing
To start unit-tests:
make test
### Run
To start application with default arguments:
make run
### Run with verbose logging
To start application with error level set to Debug:
make debug