Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# **NOTE**

> **This is an improved fork of TvDatafeed.**
>
> - Windows compatibility: Dates before 1970 now work correctly when fetching historical data.
> - Nologin method: Can fetch more than 5000 bars for some symbols (typically daily timeframe, e.g., XAUUSD:OANDA).
> - See below for more details and usage notes.

---

# **NOTE**

This is a fork of the original [TvDatafeed](https://github.com/rongardF/tvdatafeed.git) project by StreamAlpha. This fork has live data retrieving feature implemented.
More information about this will be found in the TvDatafeedLive section down below in the README.

Expand Down Expand Up @@ -63,6 +73,10 @@ tv = TvDatafeed()

when using without login, following warning will be shown `you are using nologin method, data you access may be limited`

**Note:** The nologin method now works for more than 5000 bars for some symbols (e.g., `XAUUSD:OANDA`). Try your symbol to check availability.

This extended limit is typically available for the daily timeframe. Other intervals may still be restricted.

---

## Getting Data
Expand Down
25 changes: 23 additions & 2 deletions tvDatafeed/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,35 @@ def __send_message(self, func, args):
@staticmethod
def __parse_data(raw_data, is_return_dataframe:bool) -> List[List]:
try:
out = re.search(r""""s":\[(.+?)\}\]""", raw_data).group(1)
out = re.search(r'"s":\[(.+?)\}\]', raw_data).group(1)
x = out.split(',{"')
data = list()
volume_data = True

epoch = datetime.datetime(1970, 1, 1)

for xi in x:
xi = re.split(r"\[|:|,|\]", xi)
ts = datetime.datetime.fromtimestamp(float(xi[4])) if is_return_dataframe else int(xi[4].split('.')[0])

if is_return_dataframe:
try:
ts_raw = float(xi[4])
except ValueError:
# malformed row, skip
continue

try:
# works for negative timestamps too (pre-1970)
ts = epoch + datetime.timedelta(0, ts_raw)
except OverflowError:
# insane timestamp, skip
continue
else:
try:
ts = int(xi[4].split('.')[0])
except ValueError:
# malformed row, skip
continue

row = [ts]

Expand Down