fix vol bars

This commit is contained in:
David Brazda
2024-11-14 13:48:20 +01:00
parent fb5b2369e1
commit 169f07563e
2 changed files with 11 additions and 5 deletions

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='ttools',
version='0.7.3',
version='0.7.4',
packages=find_packages(),
install_requires=[
# list your dependencies here

View File

@ -257,7 +257,7 @@ def generate_volume_bars_nb(ticks, volume_per_bar):
price = tick[1]
tick_volume = tick[2]
tick_day = np.floor(tick_time / 86400) # Calculate the day of the current tick
splitted = False
# Check if the new tick is from a different day, then close the current bar
if tick_day != current_day:
if trades_count > 0:
@ -321,9 +321,15 @@ def generate_volume_bars_nb(ticks, volume_per_bar):
remaining_volume = volume_per_bar
buy_volume = 0
sell_volume = 0
# Increment bar time if splitting a trade
bar_time = bar_time + 1e-6
#if the same trade opened the bar (we are splitting trade to more bars)
#first splitted identified by time, next by flag
if bar_time == tick_time or splitted:
bar_time = bar_time + 1e-6
splitted = True
else:
bar_time = tick_time
splitted = False
prev_price = price