-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
thank you for the great project. valuable for online trading.
I found one issue, could you please fix it?
vwap from pandas_ta will reset volume for each day(can pass in as parameter, timeframe can be month, week, hour or other timeframe), but Hexital vwap won't.
and here is the code to reproduce it(please download the attachment)
import pandas as pd
import pandas_ta as pta
from dataclasses import dataclass
import talib
from datetime import timedelta
import hexital
import math
import json
import pickle
import copy
from talipp.indicator_util import composite_to_lists
import talipp.indicators
from talipp.ohlcv import OHLCVFactory, OHLCV
pd.options.display.max_columns = None
pd.options.display.max_rows = None
pd.options.display.width = None
pd.options.display.precision = 10
pd.options.display.unicode.east_asian_width = True
with open(r"DOGE`FDUSD`5m`pandas_ta.zip", "rb") as file:
df = pickle.load(file)
df.rename(columns={"OpenTime": "timestamp"}, inplace=True)
df.columns = df.columns.str.lower()
ohlcv_dicts = df.to_dict(orient="records")
# necessary to set index as datetime for pandas_ta
df["timestamp"] = pd.to_datetime(df["timestamp"])
df.set_index("timestamp", inplace=True)
# Convert the columns to NumPy arrays
open = df["open"].to_numpy()
high = df["high"].to_numpy()
low = df["low"].to_numpy()
close = df["close"].to_numpy()
volume = df["volume"].to_numpy()
len = 16
decimal_places = 10
pta_atr = pta.atr(df.high, df.low, df.close, length=len).round(decimal_places).to_list()
pta_vwap = pta.vwap(df.high, df.low, df.close, df.volume).round(decimal_places).to_list()
pta_rsi = pta.rsi(df.close, len).round(decimal_places).to_list()
pta_sma = pta.sma(df.close, len).round(decimal_places).to_list()
pta_ema = pta.ema(df.close, len).round(decimal_places).to_list()
pta_wma = pta.wma(df.close, len).round(decimal_places).to_list()
pta_rma = pta.rma(df.close, len).round(decimal_places).to_list()
pta_dema = pta.dema(df.close, len).round(decimal_places).to_list()
pta_vwma = pta.vwma(df.close, df.volume, len).round(decimal_places).to_list()
pta_adx = pta.adx(df.high, df.low, df.close, len)
pta_adx = pta_adx.round(decimal_places)
pta_bbands = pta.bbands(df.close, length=len, std=2.0)
pta_bbands = pta_bbands.round(decimal_places)
talipp_sma = talipp.indicators.SMA(period=len)
talipp_ema = talipp.indicators.EMA(period=len)
talipp_wma = talipp.indicators.WMA(period=len)
talipp_dema = talipp.indicators.DEMA(period=len)
talipp_vwap = talipp.indicators.VWAP()
for index, ohlcv_dict in enumerate(ohlcv_dicts):
candle = hexital.Candle.from_dict(ohlcv_dict)
print(f"checking {index}~")
ohlcv = OHLCV(ohlcv_dict['open'], ohlcv_dict['high'], ohlcv_dict['low'], ohlcv_dict['close'], ohlcv_dict['volume'], ohlcv_dict['timestamp'])
talipp_vwap.add(ohlcv)
if talipp_vwap[-1] is not None:
# the following assert will be triggered
assert math.isclose(talipp_vwap[-1], pta_vwap[index], abs_tol=1e-9)
Metadata
Metadata
Assignees
Labels
No labels
