Skip to content

VWAP (Volume-Weighted Average Price) calculator

Notifications You must be signed in to change notification settings

gnoswap-labs/vwap

This branch is up to date with main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

77556f9 · May 21, 2024

History

20 Commits
May 9, 2024
May 21, 2024
May 16, 2024
May 8, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024
May 16, 2024

Repository files navigation

VWAP

This repository implements a Volume Weighted Average Price (VWAP) calculator for the gno.land ecosystem. It retrieves trading data from the Gnoswap RPC API, calculates the exchange ratios between tokens, and computes the VWAP for each token pair.

VWAP Calculation

The VWAP is calculated using the following formula:

V W A P = { i = 1 n ( P r i c e i × V o l u m e i ) i = 1 n V o l u m e i if  i = 1 n V o l u m e i > 0 L a s t A c t i v e P r i c e if  i = 1 n V o l u m e i = 0

where:

  • P r i c e i is the price of the i -th trade
  • V o l u m e i is the volume of the i -th trade
  • n is the total number of trades within the specified time window (e.g., last 10 minutes)
  • L a s t A c t i v e P r i c e is the last recorded price if there are no trades within the specified time window

The VWAP is calculated by summing up the product of price and volume for each trade within the specified time frame and dividing it by the total volume.

If there are no trades within the period, the last recorded price is used as the VWAP.

Features

  • Calculates the exchange ratios between tokens
  • Computes the VWAP for each token pair based on the trading data from the last 10 minutes

Pre-requisites

  • Go version 1.22 or higher

About

VWAP (Volume-Weighted Average Price) calculator

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages