-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AVWAPs from specific points #460
Comments
Hello @hadialaddin, I don't know off the top of my head. Is there a public TV source of available? Hopefully someone else may has a good idea or has implemented something similar will share. Kind Regards, |
Thanks @twopirllc here is more on the Anchored VWAP Calculation (https://school.stockcharts.com/doku.php?id=technical_indicators:vwap_intraday): The Anchored VWAP is calculated using the same formula as traditional VWAP. The only difference is in the bars that are included in the calculations. With traditional VWAP, the calculation starts with the first bar of the day and ends with the last bar of the day. Because it only incorporates one trading day of data, traditional VWAP can only be used on intraday charts. Anchored VWAP |
@twopirllc any thoughts on this so far? If there is a quick hack to do this manually using the already available VWAP function or to modify it? |
Basically the Anchored VWAP needs a candle to start from, and to define whether to pick the "High", "Low" or "Close" of the candle to calculate the VWAP for since then. |
Hello @hadialaddin, No. I understand what you want. The only idea I have is to make a new indicator called avwap (see #355), copy the source of vwap, take out Unfortunately, it will be some time until I can address this feature request since I am steeped in outstanding Issues. Contributions and PRs are the quickest way for one to get something included in this library. Thus, I added a Help Wanted tag to the Issue so hopefully someone else can eventually help you and others with the same feature request. Kind Regards, |
Hi all, I ended up writing this function to calculate the current anchored VWAP from the 15 minute bybit chart. It takes an 'anchor' value which should be the datetime in UTC from the point you want the anchor to start, format like '2022-08-14 07:45:00' # Define our modules here
from pybit import usdt_perpetual
import time
import pandas as pd
API_KEY = '<YOUR KEY HERE>'
API_SECRET = '<YOUR SECRET HERE>'
# Calculate anchored VWAP
def calc_anchored_vwap(anchor):
session = usdt_perpetual.HTTP('https://api.bybit.com', API_KEY, API_SECRET)
timestamp = int(time.time()) - 160000
kline = session.query_kline(symbol="BTCUSDT", interval=15, from_time=timestamp)
# convert kline.result to pandas dataframe
df = pd.DataFrame(kline['result'])
# Add new datetime column to dataframe based on open_time column
df['datetime'] = pd.to_datetime(df['open_time'], unit='s')
df.set_index(pd.DatetimeIndex(df["datetime"]), inplace=True)
df['hcl3_vol'] = ((df['high'] + df['low'] + df['close']) / 3) * df['volume']
#get all rows after the anchor
df_after = df.loc[df.index >= anchor]
sum_hcl3_vol = df_after['hcl3_vol'].sum()
sum_volume = df_after['volume'].sum()
vwap = sum_hcl3_vol / sum_volume
return vwap I know this snippet is not integrated into pandas_ta at all and it's very specific to calculating only the current anchored VWAP from bybits 15 minute chart, but I'm hoping it's ok to post this here in hopes that it may help someone else. |
I am trying to draw AVWAPs just like TradingView but from specific point (in my case the main Pivot Points on the chart). I already know the Pivot Points, I just want to know how to set the Anchor value so that it starts from those points. Lets say I have the 1 hour chart pulled from ByBit Kline (which fetches the last 200 hourly candles), what's the Pandas TA code snippet to draw:
Here is a TradingView chart export just for the sake of example where the Yellow is the "Close" AVWAP, and the "Green" is the Low and Red is "High":
The text was updated successfully, but these errors were encountered: