Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cd2ab2a
Added basic 2FA access
traderjoe1968 Sep 26, 2023
4f65711
Added Pro Data Download
traderjoe1968 Sep 26, 2023
21e12f3
Added websocket timeout handing
traderjoe1968 Sep 27, 2023
49a7eed
Fixed erronous delete token
traderjoe1968 Sep 27, 2023
2e2cb74
add login error response
Pofatoezil Mar 22, 2024
a116b86
add futures backward adjustment
Pofatoezil Mar 22, 2024
22cde40
Enhanced TvDatafeed library for asynchronous operations and flexible …
KoushikEng Nov 25, 2024
f9248db
Updated readme for usage
KoushikEng Nov 25, 2024
3821a9a
Updated readme
KoushikEng Nov 25, 2024
a49fec1
Updated Readme again, forgot to write something.
KoushikEng Nov 25, 2024
e7d6f68
Added usage guide for Ipython notebook users.
KoushikEng Nov 25, 2024
7166919
Merge pull request #1 from koushikghosh11/async
KoushikEng Dec 5, 2024
894193c
Update main.py
KoushikEng Jan 15, 2025
f08f390
add feature: get prodata
KoushikEng May 14, 2025
bf8d8b8
Update readme: option to automate totp, flexible data output, multipl…
KoushikEng May 14, 2025
b8c90a3
update requirements.txt, setup.py
KoushikEng May 14, 2025
bf101dd
Merge branch 'ProData' into ProData
traderjoe1968 May 15, 2025
7de15c6
Merge pull request #3 from KoushikEng/ProData
traderjoe1968 May 15, 2025
06e2aa5
Merge branch 'ProData' into BackwardAdjustment
traderjoe1968 May 15, 2025
c1f77fb
Merge pull request #2 from Pofatoezil/BackwardAdjustment
traderjoe1968 May 15, 2025
80ce613
Merge fix
traderjoe1968 May 15, 2025
47f757b
Update requirements.txt
traderjoe1968 Jul 6, 2025
56a5249
Update requirements.txt
traderjoe1968 Jul 7, 2025
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.pydevproject
main_test.py
.vscode
*workspace
dist
build
*.egg-info/
Expand All @@ -19,4 +20,8 @@ ENV/
env.bak/
venv.bak/
tvDatafeed/symbols.pkl
tvDatafeed/beta.py
tvDatafeed/beta.py

token*
.DS_Store
*.log
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,25 @@ Full tutorial

Version 2.0.0 is a major release and is not backward compatible. make sure you update your code accordingly. Thanks to [stefanomorni](https://github.com/stefanomorni) for contributing and removing selenium dependancy.

### Appreciation
Original ***[ProData](https://github.com/traderjoe1968/tvdatafeed/tree/ProData)*** code was implementer, thanks to **`@traderjoe1968`**.

## Usage

Import the packages and initialize with your tradingview username and password.

```python
from tvDatafeed import TvDatafeed, Interval

username = 'YourTradingViewUsername'
password = 'YourTradingViewPassword'
username: str = 'YourTradingViewUsername'
password: str = 'YourTradingViewPassword'
pro: bool = True # if subscribed to paid plans else False (default)

tv = TvDatafeed(username, password)
tv = TvDatafeed(username, password, pro)
```

You can store your accounts `2FA TOTP key` in **.env** file as <u>TOTP_KEY=*YOUR TOTP KEY*</u> if your to fully automate the process or type `totp` when asked.

You may use without logging in, but in some cases tradingview may limit the symbols and some symbols might not be available.

To use it without logging in
Expand All @@ -63,15 +69,28 @@ when using without login, following warning will be shown `you are using nologin

To download the data use `tv.get_hist` method.

It accepts following arguments and returns pandas dataframe
It accepts following arguments and returns pandas dataframe if `dataFrame` is set to True (default) to get pandas DataDrame, if False it will return data in list format


```python
(symbol: str, exchange: str = 'NSE', interval: Interval = Interval.in_daily, n_bars: int = 10, fut_contract: int | None = None, extended_session: bool = False) -> DataFrame)
(symbol: str|List[str], exchange: str = 'NSE', interval: Interval = Interval.in_daily, n_bars: int = 10, dataFrame: bool = True, fut_contract: int | None = None, extended_session: bool = False) -> pd.DataFrame|Dict[str, List[List]|pd.DataFrame]|List[List])
```

Note: If symbol (str) given it will return DataFrame or List of historical data of the symbol.
If List of symbols is passed to `tv.get_hist` it will return python Dictionary in {'symbol': Data, ......} format.
For multiple symbols, it fetches data asynchronously to get faster results.

for example-

```python
symbols = ['SBIN', 'EICHERMOT', 'INFY', 'BHARTIARTL', 'NESTLEIND', 'ASIANPAINT', 'ITC']

# returns {symbol1: pd DataFrame, symbol2: pd DataFrame, .....}
results = tv.get_hist(symbols, "NSE", n_bars=500)

# returns {symbol1: [[Timestamp, open, high, low, close, volume], .....], symbol2: [[Timestamp, open, high, low, close, volume], .....], .....}
results = tv.get_hist(symbols, "NSE", n_bars=500, dataFrame=False)

# index
nifty_index_data = tv.get_hist(symbol='NIFTY',exchange='NSE',interval=Interval.in_1_hour,n_bars=1000)

Expand All @@ -85,6 +104,12 @@ crudeoil_data = tv.get_hist(symbol='CRUDEOIL',exchange='MCX',interval=Interval.i
extended_price_data = tv.get_hist(symbol="EICHERMOT",exchange="NSE",interval=Interval.in_1_hour,n_bars=500, extended_session=False)
```

To use in Ipython notebooks, add these lines at first
```python
import nest_asyncio # To run asyncio in a notebook environment
nest_asyncio.apply() # Enable asyncio in a notebook environment
```

---

## Search Symbol
Expand Down Expand Up @@ -273,4 +298,4 @@ Before creating an issue in this library, please follow the following steps.

[Example:](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks)

![1659809630082](image/README/1659809630082.png)
![1659809630082](image/README/1659809630082.png)
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
setuptools~=49.2.0
pandas~=1.0.5
websocket-client~=0.57.0
requests
setuptools
pandas
websocket-client
requests
dotenv
pyotp
Loading