Currency Exchange Rate Extraction using investing.com Python Library
investpy is a Python package to retrieve data fromĀ Investing.com, which provides data retrieval from up to 39952 stocks, 82221 funds, 11403 ETFs, 2029 currency crosses, 7797 indices, 688 bonds, 66 commodities, 250 certificates, and 4697 cryptocurrencies.
Steps for extracting AED/INR exchange rate
investpy Installation
pip install investpy
Start python and import the library
[root@gp /]# python3
Python 3.6.8 (default, Apr 2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import investpy
>>> investpy.get_currency_cross_recent_data(currency_cross='AED/INR')
Open High Low Close Currency
Date
2021-06-07 19.84 19.86 19.80 19.81 INR
2021-06-08 19.82 19.87 19.81 19.86 INR
2021-06-09 19.86 19.88 19.84 19.87 INR
2021-06-10 19.87 19.91 19.86 19.89 INR
2021-06-11 19.90 19.95 19.84 19.94 INR
2021-06-14 19.94 19.96 19.90 19.92 INR
2021-06-15 19.93 19.98 19.92 19.97 INR
2021-06-16 19.97 19.98 19.94 19.95 INR
2021-06-17 19.95 20.21 19.95 20.19 INR
2021-06-18 20.20 20.22 20.09 20.17 INR
2021-06-21 20.18 20.24 20.16 20.18 INR
2021-06-22 20.19 20.26 20.16 20.23 INR
2021-06-23 20.24 20.25 20.16 20.18 INR
2021-06-24 20.19 20.22 20.18 20.19 INR
2021-06-25 20.20 20.22 20.18 20.20 INR
2021-06-28 20.21 20.23 20.19 20.22 INR
2021-06-29 20.22 20.24 20.20 20.22 INR
2021-06-30 20.23 20.27 20.20 20.24 INR
2021-07-01 20.25 20.32 20.24 20.30 INR
2021-07-02 20.30 20.39 20.28 20.28 INR
2021-07-05 20.29 20.30 20.22 20.22 INR
2021-07-06 20.23 20.32 20.21 20.30 INR
2021-07-07 20.35 20.37 20.31 20.37 INR
>>> investpy.get_currency_cross_recent_data(currency_cross='AED/INR').tail(1)
Open High Low Close Currency
Date
2021-07-07 20.35 20.37 20.31 20.37 INR
>>>
>>> investpy.get_currency_cross_recent_data(currency_cross='AED/INR').tail(1).iloc[0]
Open 20.35
High 20.37
Low 20.31
Close 20.37
Currency INR
Name: 2021-07-07 00:00:00, dtype: object
Extracting the AEDINR exchange rate alone
>>> investpy.get_currency_cross_recent_data(currency_cross='AED/INR').tail(1).iloc[0]['Close']
20.37
>>>
Assign the extracted value to the variable
bhd_string = investpy.get_currency_cross_recent_data(currency_cross='BHD/INR').tail(1).iloc[0]['Close']