rongardF / tvdatafeed

A simple TradingView historical Data Downloader
MIT License
282 stars 156 forks source link

Wrong Assignment of Dates when pulling historical data #43

Open AndyR88 opened 8 months ago

AndyR88 commented 8 months ago

Hi, I was pulling historical yield data with a daily resolution, for example: DE10Y = tv.get_hist(symbol='DE10Y',exchange='TVC',interval=Interval.in_daily, n_bars=10)

which yields: symbol open high low close volume datetime
2024-03-05 22:00:00 TVC:DE10Y 2.323 2.362 2.311 2.330 0.0 2024-03-06 22:00:00 TVC:DE10Y 2.332 2.350 2.250 2.298 0.0 2024-03-07 22:00:00 TVC:DE10Y 2.290 2.297 2.233 2.272 0.0 2024-03-10 21:00:00 TVC:DE10Y 2.269 2.318 2.241 2.303 0.0 2024-03-11 21:00:00 TVC:DE10Y 2.303 2.342 2.275 2.325 0.0 2024-03-12 21:00:00 TVC:DE10Y 2.325 2.370 2.295 2.367 0.0 2024-03-13 21:00:00 TVC:DE10Y 2.367 2.437 2.357 2.436 0.0 2024-03-14 21:00:00 TVC:DE10Y 2.426 2.455 2.423 2.434 0.0 2024-03-17 21:00:00 TVC:DE10Y 2.436 2.468 2.429 2.455 0.0 2024-03-18 21:00:00 TVC:DE10Y 2.455 2.465 2.428 2.446 0.0

The values are correct but the dates are all shifted by one day, i.e. the last values in the df should be for 2024-03-19 (not the 18th), while 2024-03-17 has the values of 2024-03-18 bar when checking against the TradingView website. The 17th was a Sunday... Am I calling the function incorrectly? Should I explicitly set a timezone? Or is it a bug? Thank you!

nicholasyoder commented 8 months ago

I have also noticed this issue.

silla30 commented 7 months ago

from tvDatafeed import TvDatafeed, Interval tv = TvDatafeed() index_data = tv.get_hist(symbol='NIFTY', exchange='NSE', interval=Interval.in_1_hour, n_bars=1000)

print(index_data)

ERROR:tvDatafeed.main:Connection is already closed. ERROR:tvDatafeed.main:no data, please check the exchange and symbol None

help

nitin7478 commented 1 month ago

import pandas as pd nifty.index = nifty.index + pd.Timedelta(hours=5, minutes=30)

adjusted time offset using timedelta