Skip to content

Commit

Permalink
Merge pull request #397 from alvarobartt/dev
Browse files Browse the repository at this point in the history
Several improvements and bug fixes in `investpy.search_quotes`
  • Loading branch information
Álvaro Bartolomé authored Jun 13, 2021
2 parents 86a6d4f + 159ec00 commit 6bf3d3d
Show file tree
Hide file tree
Showing 28 changed files with 763 additions and 905 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
117 changes: 92 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<h2 align="center">Financial Data Extraction from Investing.com with Python</h2>

investpy is a Python package to retrieve data from [Investing.com](https://www.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 2812 cryptocurrencies.
from up to 39952 stocks, 82221 funds, 11403 ETFs, 2029 currency crosses, 7797 indices, 688 bonds, 66 commodities, 250 certificates,
and 4697 cryptocurrencies.

investpy allows the user to download both recent and historical data from all the financial products indexed at Investing.com.
**It includes data from all over the world**, from countries such as United States, France, India, Spain, Russia, or Germany,
Expand Down Expand Up @@ -51,6 +51,9 @@ some basic functionality will be sorted out with sample Python code blocks. Addi
can be found under [examples/](https://github.com/alvarobartt/investpy/tree/master/examples) directory, which
contains a collection of Jupyter Notebooks on how to use investpy and handle its data.

:pushpin: __Note that `investpy.search_quotes` is the only function that ensures that the data is updated and aligned 1:1 with
the data provided by Investing.com!__

### :chart_with_upwards_trend: Recent/Historical Data Retrieval

investpy allows the user to **download both recent and historical data from any financial product indexed**
Expand Down Expand Up @@ -79,7 +82,7 @@ Date
To get to know all the available recent and historical data extraction functions provided by
investpy, and also, parameter tuning, please read the docs.

### :mag: Search Data
### :mag: Search Live Data

**Investing.com search engine is completely integrated** with investpy, which means that any available
financial product (quote) can be easily found. The search function allows the user to tune the parameters
Expand All @@ -90,34 +93,98 @@ presented in the following piece of code:
```python
import investpy

search_results = investpy.search_quotes(text='apple',
products=['stocks'],
countries=['united states'],
n_results=10)
search_result = investpy.search_quotes(text='apple', products=['stocks'],
countries=['united states'], n_results=1)
print(search_result)
```
```{r, engine='python', count_lines}
{"id_": 6408, "name": "Apple Inc", "symbol": "AAPL", "country": "united states", "tag": "/equities/apple-computer-inc", "pair_type": "stocks", "exchange": "NASDAQ"}
Retrieved search results will be a `list` of `investpy.utils.search_obj.SearchObj` class instances. To get to know
which are the available functions and attributes of the returned search results, please read the related
```

Retrieved search results will be a `list` of `investpy.utils.search_obj.SearchObj` class instances, unless
`n_results` is set to 1, when just a single `investpy.utils.search_obj.SearchObj` class instance will be returned.
To get to know which are the available functions and attributes of the returned search results, please read the related
documentation at [Search Engine Documentation](https://investpy.readthedocs.io/search_api.html). So on, those
search results let the user retrieve both recent and historical data from that concrete product, its
information, etc., as presented in the piece of code below:
search results let the user retrieve both recent and historical data, its information, the technical indicators,
the default currency, etc., as presented in the pieces of code below:

#### Recent Data

```python
recent_data = search_result.retrieve_recent_data()
print(recent_data.head())
```
```{r, engine='python', count_lines}
Open High Low Close Volume Change Pct
Date
2021-05-13 124.58 126.15 124.26 124.97 105861000 1.79
2021-05-14 126.25 127.89 125.85 127.45 81918000 1.98
2021-05-17 126.82 126.93 125.17 126.27 74245000 -0.93
2021-05-18 126.56 126.99 124.78 124.85 63343000 -1.12
2021-05-19 123.16 124.92 122.86 124.69 92612000 -0.13
```

#### Historical Data

```python
historical_data = search_result.retrieve_historical_data(from_date='01/01/2019', to_date='01/01/2020')
print(historical_data.head())
```
```{r, engine='python', count_lines}
Open High Low Close Volume Change Pct
Date
2020-01-02 74.06 75.15 73.80 75.09 135647008 2.28
2020-01-03 74.29 75.14 74.13 74.36 146536000 -0.97
2020-01-06 73.45 74.99 73.19 74.95 118579000 0.80
2020-01-07 74.96 75.22 74.37 74.60 111511000 -0.47
2020-01-08 74.29 76.11 74.29 75.80 132364000 1.61
```

#### Information

```python
for search_result in search_results[:1]:
print(search_result)
search_result.retrieve_historical_data(from_date='01/01/2019', to_date='01/01/2020')
print(search_result.data.head())
information = search_result.retrieve_information()
print(information)
```
```{r, engine='python', count_lines}
{"id_": 6408, "name": "Apple Inc", "symbol": "AAPL", "country": "united states", "tag": "apple-computer-inc", "pair_type": "stocks", "exchange": "NASDAQ"}
{'prevClose': 126.11, 'dailyRange': '126.1-127.44', 'revenue': 325410000000, 'open': 126.53, 'weekRange': '83.14-145.09', 'eps': 4.46, 'volume': 53522373, 'marketCap': 2130000000000, 'dividend': '0.88(0.70%)', 'avgVolume': 88858729, 'ratio': 28.58, 'beta': 1.2, 'oneYearReturn': '50.35%', 'sharesOutstanding': 16687631000, 'nextEarningDate': '03/08/2021'}
Open High Low Close Volume
Date
2019-01-02 154.89 158.85 154.23 157.92 37039736
2019-01-03 143.98 145.72 142.00 142.19 91312192
2019-01-04 144.53 148.55 143.80 148.26 58607072
2019-01-07 148.70 148.83 145.90 147.93 54777764
2019-01-08 149.56 151.82 148.52 150.75 41025312
```

#### Currency

```python
default_currency = search_result.retrieve_currency()
print(default_currency)
```
```{r, engine='python', count_lines}
'USD'
```

#### Technical Indicators

```python
technical_indicators = search_result.retrieve_technical_indicators(interval='daily')
print(technical_indicators)
```
```{r, engine='python', count_lines}
indicator signal value
0 RSI(14) neutral 52.1610
1 STOCH(9,6) buy 63.7110
2 STOCHRSI(14) overbought 100.0000
3 MACD(12,26) sell -0.6700
4 ADX(14) neutral 21.4750
5 Williams %R buy -20.9430
6 CCI(14) buy 67.1057
7 ATR(14) less_volatility 1.7871
8 Highs/Lows(14) buy 0.4279
9 Ultimate Oscillator sell 47.3620
10 ROC buy 1.5150
11 Bull/Bear Power(13) buy 1.3580
```

Expand All @@ -131,15 +198,15 @@ consider it.
As already presented previously, **historical data retrieval using investpy is really easy**. The piece of code
presented below shows how to retrieve the past years of historical data from Bitcoin (BTC).

````python
```python
import investpy

data = investpy.get_crypto_historical_data(crypto='bitcoin',
from_date='01/01/2014',
to_date='01/01/2019')

print(data.head())
````
```
```{r, engine='python', count_lines}
Open High Low Close Volume Currency
Date
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx==2.4.4
sphinx_rtd_theme==0.4.3
recommonmark==0.6.0
recommonmark==0.6.0
furo==2021.4.11b34
21 changes: 21 additions & 0 deletions docs/source/_info/citation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## 📝 Citation

When citing this repository on your scientific publications please use the following **BibTeX** citation:

```bibtex
@misc{investpy,
author = {Alvaro Bartolome del Canto},
title = {investpy - Financial Data Extraction from Investing.com with Python},
year = {2018-2021},
publisher = {GitHub},
journal = {GitHub Repository},
howpublished = {\url{https://github.com/alvarobartt/investpy}},
}
```

When citing this repository on any other social media, please use the following citation:

``investpy - Financial Data Extraction from Investing.com with Python developed by Alvaro Bartolome del Canto``

You should also mention the source from where the data is retrieved, Investing.com; even though it's already
included in the package short description title.
10 changes: 10 additions & 0 deletions docs/source/_info/contact_information.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 👨‍💻 Contact Information

You can contact me at any of my social network profiles:

- 💼 LinkedIn: https://linkedin.com/in/alvarobartt
- 🐦 Twitter: https://twitter.com/alvarobartt
- 🐙 GitHub: https://github.com/alvarobartt

Or via email at [email protected], even though this last one is not recommended
as mentioned in the FAQs.
11 changes: 6 additions & 5 deletions docs/source/_info/disclaimer.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Disclaimer
## ⚠️ Disclaimer

This Python Package has been made for research purposes in order to fit a needs that Investing.com does not cover,
so this package works like an Application Programming Interface (API) of Investing.com developed in an altruistic way.
This Python package has been made for **research purposes** to fit the needs that Investing.com does not cover,
so this package works like an Application Programming Interface (API) of Investing.com developed in an **altruistic way**.

Conclude that this package is not related in any way with Investing.com or any dependant company, the only requirement
for developing this package was to mention the source where data is retrieved.
Conclude that **investpy is not affiliated in any way to Investing.com or any dependant company**, the only
requirement specified by Investing.com to develop this package was to "mention the source where data is
retrieved from".
39 changes: 39 additions & 0 deletions docs/source/_info/discussions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ❓ Discussions (Q&A, AMA)

GitHub recently released a new feature named __GitHub Discussions__ (still in beta). GitHub Discussions is a
collaborative communication forum for the community around an open source project.

Check the investpy GitHub Discussions page at [Discussions](https://github.com/alvarobartt/investpy/discussions),
and feel free to ask me (ar any developer) anything, share updates, have open-ended conversations, and follow along
on decisions affecting the community's way of working.

:pushpin: __Note__. Usually I don't answer emails asking me questions about investpy, as we currently have the
GitHub Discussions tab, and I encourage you to use it. GitHub Discussions is the easiest way to contact me about
investpy, so that I don't answer the same stuff more than once via email, as anyone can see the opened/answered
discussions.

Also, in this section some Frequent Asked Questions are answered, so please read this section before posting a
question or openning an issue since duplicates will not be solved or will be referenced to this section. Also,
if you think that there are more possible FAQs, consider openning an issue in GitHub so to notify it, since if we
all contribute this section can be clear enough so to ease question answering.

## Where can I find the reference of a function and its usage?

Currently the `docs/` are still missing a lot of information, but they can be clear enough so that users can get to know which functions can be used and how. If you feel that any functionallity or feature is not clear enough, please let me know in the issues tab, so that I can explain it properly for newcomers, so that answers are more general and help more users than just the one asking it. Docs can be found at: [Documentation](https://investpy.readthedocs.io/)

## What do I do if the financial product I am looking for is not indexed in investpy?

As it is known, investpy gathers and retrieves data from Investing.com which is a website that contains a lot of financial information. Since investpy relies on Investing.com data, some of it may not be available in Investing, which will mean that it will not be available in investpy either. Anyways, it can be an investpy problem while retrieving data, so on, there is a search function (`investpy.search_quotes(text, products, countries, n_results)`) that can be used for searching financial products that are available in Investing.com but they can not be retrieved using investpy main functions.

## I am having problems while installing the package.

If you followed the [Installation Guide](https://github.com/alvarobartt/investpy/blob/master/README.md#Installation), you should be able to use investpy without having any problem, anyways, if you are stuck on it, open an issue at investpy issues tab so to let the developers know which is your problem in order to solve it as soon as possible. If you were not able to complete the installation, please check that you are running at least Python 3.6 and that you are installing the latest version available, if you are still having problems, open an issue.

## How do I contribute to investpy?

As this is an open-source project it is **open to contributions, bug reports, bug fixes, documentation improvements,
enhancements, and ideas**. There is an open tab of [issues](https://github.com/alvarobartt/investpy/issues) where
anyone can open new issues if needed or navigate through them to solve them or contribute to its solving.
Remember that issues are not threads to describe multiple problems, this does not mean that issues can not
be discussed, but so to keep structured project management, the same issue should not describe different
problems, just the main one and some nested/related errors that may be found.
25 changes: 0 additions & 25 deletions docs/source/_info/faq.md

This file was deleted.

Loading

0 comments on commit 6bf3d3d

Please sign in to comment.