alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.59k stars 375 forks source link

Unable to get historical crypto data relating to specific coin pairs (non-usd pairings) #403

Open LHamnett opened 3 years ago

LHamnett commented 3 years ago

I think it would be advantageous to be able to return historical information for crypto coins against a different crypto/currency instead of just against the default of the crypto vs usd pairing.

For example: The data from https://www.investing.com/crypto/vechain/ven-usd is currently returned when investpy.get_crypto_historical_data(crypto='vechain', from_date='01/01/2012', to_date=today) is called.

But it could be useful to instead return the data showing data of one crypto against another crypto: For example vs btc: https://www.investing.com/crypto/vechain/ven-btc Or vs another currency like eur: https://www.investing.com/crypto/vechain/ven-eur

I think you would need to modify the crypto.py file and change the get_crypto_historical_data function.

I see in the params variable, the crypto_id is included and has been obtained previously from a csv file within the package. Perhaps it would be possible to include coin pairings within the csv file included with the package.

Or maybe we can rewrite the function slightly and add another variable 'reference_currency': investpy.get_crypto_historical_data(crypto='vechain', reference = 'btc' from_date='01/01/2012', to_date=today) returns information from https://www.investing.com/crypto/vechain/ven-btc and if the reference_currency is not provided, the default behaviour is to return data from the usd pair as it currently works.