Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forex Data not runs? #35

Open
optimvsjag opened this issue Dec 2, 2023 · 4 comments
Open

Forex Data not runs? #35

optimvsjag opened this issue Dec 2, 2023 · 4 comments

Comments

@optimvsjag
Copy link

Hi team,

I find this excellent lib today and I'm testing it with my PRO TV account and runs for stocks, crypto or futures but not for forex pairs.

I didn't found any example for forex pair in the guide and I'm testing with majors pairs like EURUSD and not run in any exchange (FXCM, ICE, OANDA, etc)

Print this error in the terminal:

ERROR:tvDatafeed.main:Connection timed out
ERROR:tvDatafeed.main:no data, please check the exchange and symbol

I'm using this code to get EURUSD FX data:
eurusd_data = tv.get_hist(symbol='EURUSD',exchange='FXCM',interval=Interval.in_daily,n_bars=10000)

Can be an issue or forex needs other code?

Thanks a lot.

@liebig
Copy link

liebig commented Dec 3, 2023

Hi,
I can confirm that FXCM and e.g. FOREX.com do not work as an exchange, or that they close with the error message you mentioned. But OANDA as an exchange works, maybe that's enough for you?

@optimvsjag
Copy link
Author

optimvsjag commented Dec 3, 2023

Hi, I can confirm that FXCM and e.g. FOREX.com do not work as an exchange, or that they close with the error message you mentioned. But OANDA as an exchange works, maybe that's enough for you?

Thanks @liebig I tested again and runs OANDA for EURUSD but not for other pairs. I find this URL https://tvdb.brianthe.dev/ to search what exchange can download for any ticker and take "FX_IDC" for all forex pairs and runs ok.

But I've another problem, I use a for loop to download many tickers and when one ticker can't download returns "ERROR:tvDatafeed.main:no data, please check the exchange and symbol" and stop the loop.

Should print the error message but continue with other pairs. At the moment I am deleting the problematic tickers but it is a heavy work for any market.

Any idea to protect this problem?

@liebig
Copy link

liebig commented Dec 3, 2023

A loop should actually work, as no error is thrown here, only an error message is logged. This is roughly what my loop looks like:

    for symbol in symbols:
        logger.info(f"Download {symbol} from {exchange} for {interval} interval and {bars} bars")
        hist_df = tvl.get_hist(symbol,
                               exchange,
                               interval=Interval(interval),
                               n_bars=bars,
                               fut_contract=None,
                               extended_session=False)

        if hist_df is None or hist_df.empty:
            logger.error(
                f"Could not download data for {symbol} from {exchange} for {interval} interval and {bars} bars")
            continue

        hist_df.to_csv(basename, index=True)

Currently I use my fork of this library to get more historical data via Pro membership and to save the login token as token.txt and not always have to log in again.

EDIT
Okay, this only works because of the fix from traderjoe1968@21e12f3

@optimvsjag
Copy link
Author

A loop should actually work, as no error is thrown here, only an error message is logged. This is roughly what my loop looks like:

    for symbol in symbols:
        logger.info(f"Download {symbol} from {exchange} for {interval} interval and {bars} bars")
        hist_df = tvl.get_hist(symbol,
                               exchange,
                               interval=Interval(interval),
                               n_bars=bars,
                               fut_contract=None,
                               extended_session=False)

        if hist_df is None or hist_df.empty:
            logger.error(
                f"Could not download data for {symbol} from {exchange} for {interval} interval and {bars} bars")
            continue

        hist_df.to_csv(basename, index=True)

Currently I use my fork of this library to get more historical data via Pro membership and to save the login token as token.txt and not always have to log in again.

EDIT Okay, this only works because of the fix from traderjoe1968@21e12f3

Thanks for your answer. My loop error is when can't download one ticker data, the lib stops the loop and not continue with next tickers (this tickers exist in TV) but returns error. I deleted manually this conflictive tickers and now runs perfect for all TV pairs, about 2000. I made a reduced list with majors, minors and exotics pairs with 115 results and it is enought in my app for forex marquet.
Can be a great upgrade in this lib to solve this problem in a future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants