From 379649471cfd431f42d229171d8110f1785f96e0 Mon Sep 17 00:00:00 2001 From: Prajjwal Nijhara Date: Sat, 2 May 2020 17:26:09 +0530 Subject: [PATCH 01/22] Remove unused variables --- .deepsource.toml | 11 +++++++++++ test_alpha_vantage/test_integration_alphavantage.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..ed79c73 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,11 @@ +version = 1 + +test_patterns = ["test_alpha_vantage/**"] + +[[analyzers]] +name = "python" +enabled = true + + [analyzers.meta] + runtime_version = "3.x.x" + \ No newline at end of file diff --git a/test_alpha_vantage/test_integration_alphavantage.py b/test_alpha_vantage/test_integration_alphavantage.py index b52b7a1..bc017ed 100644 --- a/test_alpha_vantage/test_integration_alphavantage.py +++ b/test_alpha_vantage/test_integration_alphavantage.py @@ -70,9 +70,9 @@ def test_rapidapi_key_with_get_daily(self): ts_rapidapi = TimeSeries( key=TestAlphaVantage._RAPIDAPI_KEY_TEST, rapidapi=True) ts = TimeSeries(key=TestAlphaVantage._API_KEY_TEST) - rapidapi_data, rapidapi_metadata = ts_rapidapi.get_daily( + rapidapi_data, _ = ts_rapidapi.get_daily( symbol=TestAlphaVantage._API_EQ_NAME_TEST) - data, metadata = ts.get_daily( + data, _ = ts.get_daily( symbol=TestAlphaVantage._API_EQ_NAME_TEST) self.assertTrue(rapidapi_data == data) From 789d3a0faaf5cd98afff3951ae0013d6f7dac9c3 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Mon, 15 Jun 2020 17:59:04 -0400 Subject: [PATCH 02/22] Update index.rst --- docs/index.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 88aaa98..6acc8ee 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,9 +14,11 @@ Welcome to alpha_vantage's documentation! data, plus a comprehensive set of technical indicators. This project is a python wrapper around this API to offer python plus json/pandas support. I hope you enjoy it. It requires a free API, that can be -requested on http://www.alphavantage.co/support/#api-key. +requested on http://www.alphavantage.co/support/#api-key. This `stock API article `_ also contains general guidance on ingesting and integrating with market data. -If you are a spreadsheet user, try out the `Google Sheets Add-on `_ and `Microsoft Excel Add-on `_ from Alpha Vantage. Check out this `stock API article `_ for general tips on working with financial market data. +If you are a spreadsheet user, see also: +`Microsoft Excel Add-on `_ and +`Google Sheets Add-on `_ Install ------- From a50417b3e61a0f58f2609f57604f4a52d626acd8 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Mon, 15 Jun 2020 20:08:17 -0400 Subject: [PATCH 03/22] Update index.rst --- docs/index.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 6acc8ee..ccc2852 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -60,8 +60,12 @@ And the issue tracker as well: https://github.com/RomelTorres/alpha_vantage/issu Contributions ============= -If you have a feature that you want to see merged in the code, please do a pull -request with it and it will be evaluated. +If you have a feature that you want to see merged in the code, please do a pull request with it and it will be evaluated. + +Community Pulse +=============== +* Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) +* Alpha Vantage featured by Xignite's `stock API press release `_ License ======= From 0e249c57d930ffeab69c12dabbbe17c40243b2ef Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Mon, 15 Jun 2020 23:12:16 -0400 Subject: [PATCH 04/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7306eb8..46885b3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ *Python module to get stock data/cryptocurrencies from the Alpha Vantage API* -Alpha Vantage delivers a free API for real time financial data and most used finance indicators in a simple json or pandas format. This module implements a python interface to the free API provided by [Alpha Vantage Stock API](https://www.alphavantage.co/). It requires a free API key, that can be requested on http://www.alphavantage.co/support/#api-key. You can have a look at all the API calls available in their [API documentation](https://www.alphavantage.co/documentation/). +Alpha Vantage delivers a free API for real time financial data and most used finance indicators in a simple json or pandas format. This module implements a python interface to the free API provided by [Alpha Vantage](https://www.alphavantage.co/). It requires a free API key, that can be requested on http://www.alphavantage.co/support/#api-key. You can have a look at all the API calls available in their [API documentation](https://www.alphavantage.co/documentation/). For code-less access to the APIs, you may also consider the official [Google Sheet Add-on](https://gsuite.google.com/marketplace/app/alpha_vantage_market_data/434809773372) or the [Microsoft Excel Add-on](https://appsource.microsoft.com/en-us/product/office/WA200001365) by Alpha Vantage. Check out this [stock API guide](https://medium.com/@patrick.collins_58673/stock-api-landscape-5c6e054ee631) for some common tips on working with financial market data. From 5fb5240fb51cf962d8bca46d6edb33ad5a9028fe Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Wed, 17 Jun 2020 23:07:17 -0400 Subject: [PATCH 05/22] Update index.rst --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index ccc2852..f1c12e2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -65,7 +65,7 @@ If you have a feature that you want to see merged in the code, please do a pull Community Pulse =============== * Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) -* Alpha Vantage featured by Xignite's `stock API press release `_ +* Alpha Vantage featured in `Xignite stock API press release `_, `Google Cloud Tutorial `_, and `MATLAB tutorial `_ License ======= From c4394458c99072ac9f5ecaddc5514999c750a1f4 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Tue, 23 Jun 2020 10:42:06 -0400 Subject: [PATCH 06/22] Update index.rst --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index f1c12e2..4613c4e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -66,6 +66,7 @@ Community Pulse =============== * Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) * Alpha Vantage featured in `Xignite stock API press release `_, `Google Cloud Tutorial `_, and `MATLAB tutorial `_ +* Alpha Vantage highlighted by several leading universities, including `Best 5 Stock APIs in 2020 – A Guide for Investors `_ by Harvard Business School and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by New York University License ======= From 48df38d0350b03e7fbb29afa02cdb29745160401 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Wed, 24 Jun 2020 23:05:00 -0400 Subject: [PATCH 07/22] Update index.rst --- docs/index.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 4613c4e..2f510f9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -65,8 +65,7 @@ If you have a feature that you want to see merged in the code, please do a pull Community Pulse =============== * Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) -* Alpha Vantage featured in `Xignite stock API press release `_, `Google Cloud Tutorial `_, and `MATLAB tutorial `_ -* Alpha Vantage highlighted by several leading universities, including `Best 5 Stock APIs in 2020 – A Guide for Investors `_ by Harvard Business School and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by New York University +* Alpha Vantage featured in `Xignite stock API press release `_, `Google Cloud Tutorial `_, `MATLAB tutorial `_, and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by NYU's quant investing project License ======= From bb584ca8eb05d339c4b369d5ef7ef6e460ef9147 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Wed, 1 Jul 2020 11:27:35 -0400 Subject: [PATCH 08/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46885b3..e6931df 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Alpha Vantage delivers a free API for real time financial data and most used finance indicators in a simple json or pandas format. This module implements a python interface to the free API provided by [Alpha Vantage](https://www.alphavantage.co/). It requires a free API key, that can be requested on http://www.alphavantage.co/support/#api-key. You can have a look at all the API calls available in their [API documentation](https://www.alphavantage.co/documentation/). -For code-less access to the APIs, you may also consider the official [Google Sheet Add-on](https://gsuite.google.com/marketplace/app/alpha_vantage_market_data/434809773372) or the [Microsoft Excel Add-on](https://appsource.microsoft.com/en-us/product/office/WA200001365) by Alpha Vantage. Check out this [stock API guide](https://medium.com/@patrick.collins_58673/stock-api-landscape-5c6e054ee631) for some common tips on working with financial market data. +For code-less access to the APIs, you may also consider the official [Google Sheet Add-on](https://gsuite.google.com/marketplace/app/alpha_vantage_market_data/434809773372) or the [Microsoft Excel Add-on](https://appsource.microsoft.com/en-us/product/office/WA200001365) by Alpha Vantage. Check out [this](https://medium.com/@patrick.collins_58673/stock-api-landscape-5c6e054ee631) guide for some common tips on working with financial market data. ## News From 6589929d83a2ce9c862bba0d30b09dbf7ee39c27 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Sat, 4 Jul 2020 23:10:52 -0400 Subject: [PATCH 09/22] Update index.rst --- docs/index.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 2f510f9..1f29117 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,11 +10,8 @@ Welcome to alpha_vantage's documentation! *Python module to get stock data from the Alpha Vantage API* -`Alpha Vantage Stock API `_ is a free JSON APIs for stock market -data, plus a comprehensive set of technical indicators. This project is a python wrapper -around this API to offer python plus json/pandas support. I hope you enjoy it. -It requires a free API, that can be -requested on http://www.alphavantage.co/support/#api-key. This `stock API article `_ also contains general guidance on ingesting and integrating with market data. +The `Alpha Vantage Stock API `_ provides free JSON access to the stock market, plus a comprehensive set of technical indicators. This project is a python wrapper around this API to offer python plus json/pandas support. I hope you enjoy it. +It requires a free API, that can be requested on http://www.alphavantage.co/support/#api-key. This `stock API article `_ also contains general guidance on ingesting and integrating with market data. If you are a spreadsheet user, see also: `Microsoft Excel Add-on `_ and @@ -65,7 +62,7 @@ If you have a feature that you want to see merged in the code, please do a pull Community Pulse =============== * Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) -* Alpha Vantage featured in `Xignite stock API press release `_, `Google Cloud Tutorial `_, `MATLAB tutorial `_, and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by NYU's quant investing project +* Alpha Vantage featured in `Xignite stock API press release `_ and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by NYU's Quantitative Investing project License ======= From df2628f8621c0ea8a0d91f07ea3cd9b0516e05fd Mon Sep 17 00:00:00 2001 From: David Roitman Date: Wed, 15 Jul 2020 11:01:11 +0300 Subject: [PATCH 10/22] Fixed exception from empty search results when output is pandas. Fixes Issue #244 Signed-off-by: David Roitman --- alpha_vantage/alphavantage.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/alpha_vantage/alphavantage.py b/alpha_vantage/alphavantage.py index be501f4..34d9777 100644 --- a/alpha_vantage/alphavantage.py +++ b/alpha_vantage/alphavantage.py @@ -239,11 +239,14 @@ def _format_wrapper(self, *args, **kwargs): # in the resulting data frame. If in the future # alphavantage decides to do more with returning arrays # this might become buggy. For now will do the trick. - data_array = [] - for val in data: - data_array.append([v for _, v in val.items()]) - data_pandas = pandas.DataFrame(data_array, columns=[ - k for k, _ in data[0].items()]) + if not data: + data_pandas = pandas.DataFrame() + else: + data_array = [] + for val in data: + data_array.append([v for _, v in val.items()]) + data_pandas = pandas.DataFrame(data_array, columns=[ + k for k, _ in data[0].items()]) else: try: data_pandas = pandas.DataFrame.from_dict(data, From 91a93e6c988ee716e1f20621078dd000f9808fd7 Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Sun, 19 Jul 2020 23:18:21 -0400 Subject: [PATCH 11/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6931df..2234202 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ *Python module to get stock data/cryptocurrencies from the Alpha Vantage API* -Alpha Vantage delivers a free API for real time financial data and most used finance indicators in a simple json or pandas format. This module implements a python interface to the free API provided by [Alpha Vantage](https://www.alphavantage.co/). It requires a free API key, that can be requested on http://www.alphavantage.co/support/#api-key. You can have a look at all the API calls available in their [API documentation](https://www.alphavantage.co/documentation/). +Alpha Vantage delivers a free API for real time financial data and most used finance indicators in a simple json or pandas format. This module implements a python interface to the free API provided by [Alpha Vantage](https://www.alphavantage.co/). It requires a free API key, that can be requested from http://www.alphavantage.co/support/#api-key. You can have a look at all the API calls available in their [API documentation](https://www.alphavantage.co/documentation/). For code-less access to the APIs, you may also consider the official [Google Sheet Add-on](https://gsuite.google.com/marketplace/app/alpha_vantage_market_data/434809773372) or the [Microsoft Excel Add-on](https://appsource.microsoft.com/en-us/product/office/WA200001365) by Alpha Vantage. Check out [this](https://medium.com/@patrick.collins_58673/stock-api-landscape-5c6e054ee631) guide for some common tips on working with financial market data. From 993166630c9e69af6d58850e43312b95c973be4d Mon Sep 17 00:00:00 2001 From: Ramon Carrasco Date: Fri, 28 Aug 2020 19:03:55 -0400 Subject: [PATCH 12/22] adding crypto-rating functionality --- alpha_vantage/cryptocurrencies.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/alpha_vantage/cryptocurrencies.py b/alpha_vantage/cryptocurrencies.py index 14a828c..7b98219 100644 --- a/alpha_vantage/cryptocurrencies.py +++ b/alpha_vantage/cryptocurrencies.py @@ -60,17 +60,14 @@ def get_digital_currency_monthly(self, symbol, market): @av._output_format @av._call_api_on_func - def get_digital_currency_exchange_rate(self, symbol, market): - """ Returns the current exchange rate for a digital currency - (e.g., BTC) traded on a specific market (e.g., CNY/Chinese Yuan), - and when it was last updated. + def get_digital_crypto_rating(self, symbol): + """ Returns the Fundamental Crypto Asset Score for a digital currency + (e.g., BTC), and when it was last updated. Keyword Arguments: symbol: The digital/crypto currency of your choice. It can be any of the currencies in the digital currency list. For example: symbol=BTC. - market: The exchange market of your choice. It can be any of the - market in the market list. For example: market=CNY. """ - _FUNCTION_KEY = 'CURRENCY_EXCHANGE_RATE' - return _FUNCTION_KEY, 'Dictonary (Digital Currency Exchange Rate)', 'Meta Data' + _FUNCTION_KEY = 'CRYPTO_RATING' + return _FUNCTION_KEY, 'Crypto Rating (FCAS)', None From 64e7dae37f0d1dd2080a697789e8efe6e4a237d6 Mon Sep 17 00:00:00 2001 From: Ramon Carrasco Date: Fri, 28 Aug 2020 20:02:30 -0400 Subject: [PATCH 13/22] adding getting digital currency exchange rate --- alpha_vantage/cryptocurrencies.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/alpha_vantage/cryptocurrencies.py b/alpha_vantage/cryptocurrencies.py index 7b98219..a79c690 100644 --- a/alpha_vantage/cryptocurrencies.py +++ b/alpha_vantage/cryptocurrencies.py @@ -58,6 +58,22 @@ def get_digital_currency_monthly(self, symbol, market): _FUNCTION_KEY = 'DIGITAL_CURRENCY_MONTHLY' return _FUNCTION_KEY, 'Time Series (Digital Currency Monthly)', 'Meta Data' + @av._output_format + @av._call_api_on_func + def get_digital_currency_exchange_rate(self, from_currency, to_currency): + """ Returns the realtime exchange rate for any pair of digital + currency (e.g., BTC) or physical currency (e.g., USD). + Keyword Arguments: + from_currency: The currency you would like to get the exchange rate + for. It can either be a physical currency or digital/crypto currency. + For example: from_currency=USD or from_currency=BTC. + to_currency: The destination currency for the exchange rate. + It can either be a physical currency or digital/crypto currency. + For example: to_currency=USD or to_currency=BTC. + """ + _FUNCTION_KEY = 'CURRENCY_EXCHANGE_RATE' + return _FUNCTION_KEY, 'Realtime Currency Exchange Rate', None + @av._output_format @av._call_api_on_func def get_digital_crypto_rating(self, symbol): From a7afc54638f0d7bdb2f6b0b20624716969f01afa Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Mon, 31 Aug 2020 12:08:48 -0400 Subject: [PATCH 14/22] Update index.rst --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 1f29117..db9fdd9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -61,7 +61,7 @@ If you have a feature that you want to see merged in the code, please do a pull Community Pulse =============== -* Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) +* Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) and `a recent economic review from Harvard `_ * Alpha Vantage featured in `Xignite stock API press release `_ and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by NYU's Quantitative Investing project License From 0f530e4514c3366fa8a25d9d576460efade5d8ff Mon Sep 17 00:00:00 2001 From: SteveAlphaVantage <45717018+SteveAlphaVantage@users.noreply.github.com> Date: Mon, 31 Aug 2020 13:10:00 -0400 Subject: [PATCH 15/22] Update index.rst --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index db9fdd9..3131ae9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -61,7 +61,7 @@ If you have a feature that you want to see merged in the code, please do a pull Community Pulse =============== -* Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) and `a recent economic review from Harvard `_ +* Alpha Vantage used by `Harvard COVID-19 Global Policy Tracker `_ (`link `_) and `a recent economic review `_ * Alpha Vantage featured in `Xignite stock API press release `_ and `Best 5 (Free and Paid) Stock Market APIs in 2020 `_ by NYU's Quantitative Investing project License From c1e76d8fda3a9dddc4227c57e17a01c2a5fafeda Mon Sep 17 00:00:00 2001 From: Patrick Collins <54278053+PatrickAlphaC@users.noreply.github.com> Date: Mon, 31 Aug 2020 13:19:08 -0400 Subject: [PATCH 16/22] Update .travis.yml updating for numpy==1.16.4 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 03aee73..1c62193 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: - pip install pandas==0.19.2 - pip install requests - pip install requests-mock + - pip install numpy==1.16.4 script: nosetests --nocapture test_alpha_vantage/test_alphavantage.py allow_failure: From 57a7d8c1d119032ff6debd19524fc75d8c8be3f9 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Thu, 3 Sep 2020 10:18:03 -0300 Subject: [PATCH 17/22] Mock data to run test_alphavantage --- .../test_data/mock_company_overview | 61 ++ .../test_data/mock_fundamental_data | 782 ++++++++++++++++++ 2 files changed, 843 insertions(+) create mode 100644 test_alpha_vantage/test_data/mock_company_overview create mode 100644 test_alpha_vantage/test_data/mock_fundamental_data diff --git a/test_alpha_vantage/test_data/mock_company_overview b/test_alpha_vantage/test_data/mock_company_overview new file mode 100644 index 0000000..4802d3a --- /dev/null +++ b/test_alpha_vantage/test_data/mock_company_overview @@ -0,0 +1,61 @@ +{ + "Symbol": "IBM", + "AssetType": "Common Stock", + "Name": "International Business Machines Corporation", + "Description": "International Business Machines Corporation operates as an integrated solutions and services company worldwide. Its Cloud & Cognitive Software segment offers software for vertical and domain-specific solutions in health, financial services, and Internet of Things (IoT), weather, and security software and services application areas; and customer information control system and storage, and analytics and integration software solutions to support client mission critical on-premise workloads in banking, airline, and retail industries. It also offers middleware and data platform software, including Red Hat, which enables the operation of clients' hybrid multi-cloud environments; and Cloud Paks, WebSphere distributed, and analytics platform software, such as DB2 distributed, information integration, and enterprise content management, as well as IoT, Blockchain and AI/Watson platforms. The company's Global Business Services segment offers business consulting services; system integration, application management, maintenance, and support services for packaged software; finance, procurement, talent and engagement, and industry-specific business process outsourcing services; and IT infrastructure and platform services. Its Global Technology Services segment provides project, managed, outsourcing, and cloud-delivered services for enterprise IT infrastructure environments; and IT infrastructure support services. The company's Systems segment offers servers for businesses, cloud service providers, and scientific computing organizations; data storage products and solutions; and z/OS, an enterprise operating system, as well as Linux. Its Global Financing segment provides lease, installment payment, loan financing, short-term working capital financing, and remanufacturing and remarketing services. The company was formerly known as Computing-Tabulating-Recording Co. and changed its name to International Business Machines Corporation in 1924. The company was founded in 1911 and is headquartered in Armonk, New York.", + "Exchange": "NYSE", + "Currency": "USD", + "Country": "USA", + "Sector": "Technology", + "Industry": "Information Technology Services", + "Address": "One New Orchard Road, Armonk, NY, United States, 10504", + "FullTimeEmployees": "352600", + "FiscalYearEnd": "December", + "LatestQuarter": "2020-06-30", + "MarketCapitalization": "114234572800", + "EBITDA": "15576999936", + "PERatio": "14.1327", + "PEGRatio": "8.7525", + "BookValue": "23.076", + "DividendPerShare": "6.52", + "DividendYield": "0.0529", + "EPS": "8.811", + "RevenuePerShareTTM": "85.058", + "ProfitMargin": "0.1043", + "OperatingMarginTTM": "0.1185", + "ReturnOnAssetsTTM": "0.0362", + "ReturnOnEquityTTM": "0.4097", + "RevenueTTM": "75499003904", + "GrossProfitTTM": "36489000000", + "DilutedEPSTTM": "8.811", + "QuarterlyEarningsGrowthYOY": "-0.458", + "QuarterlyRevenueGrowthYOY": "-0.054", + "AnalystTargetPrice": "135.19", + "TrailingPE": "14.1327", + "ForwardPE": "11.2867", + "PriceToSalesRatioTTM": "1.4762", + "PriceToBookRatio": "5.4017", + "EVToRevenue": "2.2076", + "EVToEBITDA": "11.0349", + "Beta": "1.2071", + "52WeekHigh": "158.75", + "52WeekLow": "90.56", + "50DayMovingAverage": "124.9097", + "200DayMovingAverage": "122.2713", + "SharesOutstanding": "890579008", + "SharesFloat": "889189445", + "SharesShort": "21600483", + "SharesShortPriorMonth": "23242369", + "ShortRatio": "4.51", + "ShortPercentOutstanding": "0.02", + "ShortPercentFloat": "0.0243", + "PercentInsiders": "0.108", + "PercentInstitutions": "58.555", + "ForwardAnnualDividendRate": "6.52", + "ForwardAnnualDividendYield": "0.0529", + "PayoutRatio": "0.7358", + "DividendDate": "2020-09-10", + "ExDividendDate": "2020-08-07", + "LastSplitFactor": "2:1", + "LastSplitDate": "1999-05-27" +} \ No newline at end of file diff --git a/test_alpha_vantage/test_data/mock_fundamental_data b/test_alpha_vantage/test_data/mock_fundamental_data new file mode 100644 index 0000000..6c6f259 --- /dev/null +++ b/test_alpha_vantage/test_data/mock_fundamental_data @@ -0,0 +1,782 @@ +{ + "symbol": "IBM", + "annualReports": [ + { + "fiscalDateEnding": "2019-12-31", + "reportedCurrency": "USD", + "totalRevenue": "77147000000", + "totalOperatingExpense": "25945000000", + "costOfRevenue": "40659000000", + "grossProfit": "36488000000", + "ebit": "11511000000", + "netIncome": "9431000000", + "researchAndDevelopment": "5989000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "10166000000", + "minorityInterest": "144000000", + "sellingGeneralAdministrative": "19956000000", + "otherNonOperatingIncome": "968000000", + "operatingIncome": "10543000000", + "otherOperatingExpense": "-614000000", + "interestExpense": "1344000000", + "taxProvision": "731000000", + "interestIncome": "349000000", + "netInterestIncome": "-995000000", + "extraordinaryItems": "-150000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "731000000", + "totalOtherIncomeExpense": "529000000", + "discontinuedOperations": "-4000000", + "netIncomeFromContinuingOperations": "9435000000", + "netIncomeApplicableToCommonShares": "9431000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2018-12-31", + "reportedCurrency": "USD", + "totalRevenue": "79591000000", + "totalOperatingExpense": "23719000000", + "costOfRevenue": "42655000000", + "grossProfit": "36936000000", + "ebit": "12065000000", + "netIncome": "8728000000", + "researchAndDevelopment": "5379000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "11342000000", + "minorityInterest": "134000000", + "sellingGeneralAdministrative": "18340000000", + "otherNonOperatingIncome": "-1152000000", + "operatingIncome": "13217000000", + "otherOperatingExpense": "-998000000", + "interestExpense": "723000000", + "taxProvision": "2619000000", + "interestIncome": "264000000", + "netInterestIncome": "-459000000", + "extraordinaryItems": "-2032000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "2619000000", + "totalOtherIncomeExpense": "-1482000000", + "discontinuedOperations": "5000000", + "netIncomeFromContinuingOperations": "8723000000", + "netIncomeApplicableToCommonShares": "8728000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2017-12-31", + "reportedCurrency": "USD", + "totalRevenue": "79139000000", + "totalOperatingExpense": "24428000000", + "costOfRevenue": "42913000000", + "grossProfit": "36227000000", + "ebit": "12015000000", + "netIncome": "5753000000", + "researchAndDevelopment": "5787000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "11400000000", + "minorityInterest": "131000000", + "sellingGeneralAdministrative": "18641000000", + "otherNonOperatingIncome": "216000000", + "operatingIncome": "11799000000", + "otherOperatingExpense": "-1466000000", + "interestExpense": "615000000", + "taxProvision": "5642000000", + "interestIncome": "144000000", + "netInterestIncome": "-471000000", + "extraordinaryItems": "-5480000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "5642000000", + "totalOtherIncomeExpense": "17000000", + "discontinuedOperations": "-5000000", + "netIncomeFromContinuingOperations": "5758000000", + "netIncomeApplicableToCommonShares": "5753000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2016-12-31", + "reportedCurrency": "USD", + "totalRevenue": "79919000000", + "totalOperatingExpense": "25189000000", + "costOfRevenue": "41625000000", + "grossProfit": "38294000000", + "ebit": "12960000000", + "netIncome": "11872000000", + "researchAndDevelopment": "5751000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "12330000000", + "minorityInterest": "146000000", + "sellingGeneralAdministrative": "19438000000", + "otherNonOperatingIncome": "-145000000", + "operatingIncome": "13105000000", + "otherOperatingExpense": "-1604000000", + "interestExpense": "630000000", + "taxProvision": "449000000", + "interestIncome": "108000000", + "netInterestIncome": "-522000000", + "extraordinaryItems": "-9000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "449000000", + "totalOtherIncomeExpense": "-339000000", + "discontinuedOperations": "-9000000", + "netIncomeFromContinuingOperations": "11881000000", + "netIncomeApplicableToCommonShares": "11872000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2015-12-31", + "reportedCurrency": "USD", + "totalRevenue": "81741000000", + "totalOperatingExpense": "24995000000", + "costOfRevenue": "41057000000", + "grossProfit": "40684000000", + "ebit": "16413000000", + "netIncome": "13190000000", + "researchAndDevelopment": "5247000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "15945000000", + "minorityInterest": "162000000", + "sellingGeneralAdministrative": "19748000000", + "otherNonOperatingIncome": "724000000", + "operatingIncome": "15689000000", + "otherOperatingExpense": "-669000000", + "interestExpense": "468000000", + "taxProvision": "2581000000", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "-174000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "2581000000", + "totalOtherIncomeExpense": "-572000000", + "discontinuedOperations": "-174000000", + "netIncomeFromContinuingOperations": "13364000000", + "netIncomeApplicableToCommonShares": "13190000000", + "preferredStockAndOtherAdjustments": "None" + } + ], + "quarterlyReports": [ + { + "fiscalDateEnding": "2020-06-30", + "reportedCurrency": "USD", + "totalRevenue": "18123000000", + "totalOperatingExpense": "6627000000", + "costOfRevenue": "9423000000", + "grossProfit": "8700000000", + "ebit": "1894000000", + "netIncome": "1361000000", + "researchAndDevelopment": "1582000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "1571000000", + "minorityInterest": "137000000", + "sellingGeneralAdministrative": "5045000000", + "otherNonOperatingIncome": "-179000000", + "operatingIncome": "2073000000", + "otherOperatingExpense": "-202000000", + "interestExpense": "323000000", + "taxProvision": "209000000", + "interestIncome": "23000000", + "netInterestIncome": "-300000000", + "extraordinaryItems": "-1000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "209000000", + "totalOtherIncomeExpense": "-200000000", + "discontinuedOperations": "-1000000", + "netIncomeFromContinuingOperations": "1362000000", + "netIncomeApplicableToCommonShares": "1361000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2020-03-31", + "reportedCurrency": "USD", + "totalRevenue": "17571000000", + "totalOperatingExpense": "7464000000", + "costOfRevenue": "9649000000", + "grossProfit": "7922000000", + "ebit": "276000000", + "netIncome": "1175000000", + "researchAndDevelopment": "1625000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "-49000000", + "minorityInterest": "129000000", + "sellingGeneralAdministrative": "5839000000", + "otherNonOperatingIncome": "-182000000", + "operatingIncome": "458000000", + "otherOperatingExpense": "-116000000", + "interestExpense": "326000000", + "taxProvision": "-1226000000", + "interestIncome": "51000000", + "netInterestIncome": "-275000000", + "extraordinaryItems": "-150000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "-1226000000", + "totalOtherIncomeExpense": "-234000000", + "discontinuedOperations": "-1000000", + "netIncomeFromContinuingOperations": "1177000000", + "netIncomeApplicableToCommonShares": "1175000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2019-12-31", + "reportedCurrency": "USD", + "totalRevenue": "21777000000", + "totalOperatingExpense": "17511000000", + "costOfRevenue": "10677000000", + "grossProfit": "11100000000", + "ebit": "5997000000", + "netIncome": "3670000000", + "researchAndDevelopment": "1596000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "3993000000", + "minorityInterest": "144000000", + "sellingGeneralAdministrative": "5103000000", + "otherNonOperatingIncome": "None", + "operatingIncome": "4266000000", + "otherOperatingExpense": "-153000000", + "interestExpense": "354000000", + "taxProvision": "324000000", + "interestIncome": "48000000", + "netInterestIncome": "-306000000", + "extraordinaryItems": "15000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "324000000", + "totalOtherIncomeExpense": "30000000", + "discontinuedOperations": "1000000", + "netIncomeFromContinuingOperations": "3669000000", + "netIncomeApplicableToCommonShares": "3670000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2019-09-30", + "reportedCurrency": "USD", + "totalRevenue": "18027000000", + "totalOperatingExpense": "16090000000", + "costOfRevenue": "9692000000", + "grossProfit": "8336000000", + "ebit": "3623000000", + "netIncome": "1672000000", + "researchAndDevelopment": "1553000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "1522000000", + "minorityInterest": "139000000", + "sellingGeneralAdministrative": "4735000000", + "otherNonOperatingIncome": "None", + "operatingIncome": "1938000000", + "otherOperatingExpense": "-155000000", + "interestExpense": "432000000", + "taxProvision": "-151000000", + "interestIncome": "63000000", + "netInterestIncome": "-369000000", + "extraordinaryItems": "-6000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "-151000000", + "totalOtherIncomeExpense": "-46000000", + "discontinuedOperations": "-1000000", + "netIncomeFromContinuingOperations": "1673000000", + "netIncomeApplicableToCommonShares": "1672000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2019-06-30", + "reportedCurrency": "USD", + "totalRevenue": "19161000000", + "totalOperatingExpense": "16775000000", + "costOfRevenue": "10151000000", + "grossProfit": "9010000000", + "ebit": "4410000000", + "netIncome": "2498000000", + "researchAndDevelopment": "1407000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "2768000000", + "minorityInterest": "131000000", + "sellingGeneralAdministrative": "5344000000", + "otherNonOperatingIncome": "None", + "operatingIncome": "2386000000", + "otherOperatingExpense": "-206000000", + "interestExpense": "348000000", + "taxProvision": "269000000", + "interestIncome": "167000000", + "netInterestIncome": "-181000000", + "extraordinaryItems": "-15000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "269000000", + "totalOtherIncomeExpense": "562000000", + "discontinuedOperations": "-1000000", + "netIncomeFromContinuingOperations": "2499000000", + "netIncomeApplicableToCommonShares": "2498000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2019-03-31", + "reportedCurrency": "USD", + "totalRevenue": "18182000000", + "totalOperatingExpense": "6023000000", + "costOfRevenue": "10139000000", + "grossProfit": "8043000000", + "ebit": "2093000000", + "netIncome": "1591000000", + "researchAndDevelopment": "1433000000", + "effectOfAccountingCharges": "None", + "incomeBeforeTax": "1883000000", + "minorityInterest": "126000000", + "sellingGeneralAdministrative": "4590000000", + "otherNonOperatingIncome": "73000000", + "operatingIncome": "2020000000", + "otherOperatingExpense": "-101000000", + "interestExpense": "210000000", + "taxProvision": "289000000", + "interestIncome": "70000000", + "netInterestIncome": "-140000000", + "extraordinaryItems": "-143000000", + "nonRecurring": "None", + "otherItems": "None", + "incomeTaxExpense": "289000000", + "totalOtherIncomeExpense": "-19000000", + "discontinuedOperations": "-2000000", + "netIncomeFromContinuingOperations": "1594000000", + "netIncomeApplicableToCommonShares": "1591000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2018-12-31", + "reportedCurrency": "USD", + "totalRevenue": "21760000000", + "totalOperatingExpense": "5875000000", + "costOfRevenue": "11073000000", + "grossProfit": "10687000000", + "ebit": "4628000000", + "netIncome": "1951000000", + "researchAndDevelopment": "1358000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "4434000000", + "minorityInterest": "134000000", + "sellingGeneralAdministrative": "4517000000", + "otherNonOperatingIncome": "-184000000", + "operatingIncome": "4812000000", + "otherOperatingExpense": "-168000000", + "interestExpense": "194000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "-1946000000", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "2482000000", + "totalOtherIncomeExpense": "5000000", + "discontinuedOperations": "-2000000", + "netIncomeFromContinuingOperations": "1952000000", + "netIncomeApplicableToCommonShares": "1951000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2018-09-30", + "reportedCurrency": "USD", + "totalRevenue": "18756000000", + "totalOperatingExpense": "5340000000", + "costOfRevenue": "9953000000", + "grossProfit": "8803000000", + "ebit": "3188000000", + "netIncome": "2694000000", + "researchAndDevelopment": "1252000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "2996000000", + "minorityInterest": "134000000", + "sellingGeneralAdministrative": "4088000000", + "otherNonOperatingIncome": "-275000000", + "operatingIncome": "3463000000", + "otherOperatingExpense": "-267000000", + "interestExpense": "191000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "304000000", + "totalOtherIncomeExpense": "-99000000", + "discontinuedOperations": "2000000", + "netIncomeFromContinuingOperations": "2692000000", + "netIncomeApplicableToCommonShares": "2694000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2018-06-30", + "reportedCurrency": "USD", + "totalRevenue": "20003000000", + "totalOperatingExpense": "5971000000", + "costOfRevenue": "10804000000", + "grossProfit": "9199000000", + "ebit": "2948000000", + "netIncome": "2404000000", + "researchAndDevelopment": "1364000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "2776000000", + "minorityInterest": "128000000", + "sellingGeneralAdministrative": "4607000000", + "otherNonOperatingIncome": "-280000000", + "operatingIncome": "3228000000", + "otherOperatingExpense": "-246000000", + "interestExpense": "173000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "373000000", + "totalOtherIncomeExpense": "-472000000", + "discontinuedOperations": "1000000", + "netIncomeFromContinuingOperations": "2403000000", + "netIncomeApplicableToCommonShares": "2404000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2018-03-31", + "reportedCurrency": "USD", + "totalRevenue": "19072000000", + "totalOperatingExpense": "6533000000", + "costOfRevenue": "10825000000", + "grossProfit": "8247000000", + "ebit": "1301000000", + "netIncome": "1679000000", + "researchAndDevelopment": "1405000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "1136000000", + "minorityInterest": "124000000", + "sellingGeneralAdministrative": "5128000000", + "otherNonOperatingIncome": "-413000000", + "operatingIncome": "1714000000", + "otherOperatingExpense": "-317000000", + "interestExpense": "165000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "-540000000", + "totalOtherIncomeExpense": "-1118000000", + "discontinuedOperations": "4000000", + "netIncomeFromContinuingOperations": "1676000000", + "netIncomeApplicableToCommonShares": "1679000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2017-12-31", + "reportedCurrency": "USD", + "totalRevenue": "22542000000", + "totalOperatingExpense": "6227000000", + "costOfRevenue": "11682000000", + "grossProfit": "10861000000", + "ebit": "4632000000", + "netIncome": "-1054000000", + "researchAndDevelopment": "1428000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "4468000000", + "minorityInterest": "13000000", + "sellingGeneralAdministrative": "4799000000", + "otherNonOperatingIncome": "-2000000", + "operatingIncome": "4634000000", + "otherOperatingExpense": "-910000000", + "interestExpense": "165000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "5521000000", + "totalOtherIncomeExpense": "-498000000", + "discontinuedOperations": "2000000", + "netIncomeFromContinuingOperations": "-1053000000", + "netIncomeApplicableToCommonShares": "-1054000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2017-09-30", + "reportedCurrency": "USD", + "totalRevenue": "19153000000", + "totalOperatingExpense": "5682000000", + "costOfRevenue": "10353000000", + "grossProfit": "8800000000", + "ebit": "3232000000", + "netIncome": "2726000000", + "researchAndDevelopment": "1342000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "3065000000", + "minorityInterest": "356000000", + "sellingGeneralAdministrative": "4340000000", + "otherNonOperatingIncome": "114000000", + "operatingIncome": "3118000000", + "otherOperatingExpense": "-1502000000", + "interestExpense": "168000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "339000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "-15000000", + "netIncomeFromContinuingOperations": "2726000000", + "netIncomeApplicableToCommonShares": "2726000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2017-06-30", + "reportedCurrency": "USD", + "totalRevenue": "19289000000", + "totalOperatingExpense": "6279000000", + "costOfRevenue": "10495000000", + "grossProfit": "8794000000", + "ebit": "2591000000", + "netIncome": "2331000000", + "researchAndDevelopment": "1484000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "2443000000", + "minorityInterest": "-359000000", + "sellingGeneralAdministrative": "4795000000", + "otherNonOperatingIncome": "76000000", + "operatingIncome": "2515000000", + "otherOperatingExpense": "1411000000", + "interestExpense": "147000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "111000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "11000000", + "netIncomeFromContinuingOperations": "2332000000", + "netIncomeApplicableToCommonShares": "2331000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2017-03-31", + "reportedCurrency": "USD", + "totalRevenue": "18155000000", + "totalOperatingExpense": "6240000000", + "costOfRevenue": "10383000000", + "grossProfit": "7772000000", + "ebit": "1560000000", + "netIncome": "1750000000", + "researchAndDevelopment": "1533000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "1424000000", + "minorityInterest": "121000000", + "sellingGeneralAdministrative": "4707000000", + "otherNonOperatingIncome": "28000000", + "operatingIncome": "1532000000", + "otherOperatingExpense": "-444000000", + "interestExpense": "135000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "-329000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "-3000000", + "netIncomeFromContinuingOperations": "1753000000", + "netIncomeApplicableToCommonShares": "1750000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2016-12-31", + "reportedCurrency": "USD", + "totalRevenue": "21771000000", + "totalOperatingExpense": "5886000000", + "costOfRevenue": "10877000000", + "grossProfit": "10893000000", + "ebit": "5144000000", + "netIncome": "4501000000", + "researchAndDevelopment": "1431000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "4984000000", + "minorityInterest": "465000000", + "sellingGeneralAdministrative": "4455000000", + "otherNonOperatingIncome": "137000000", + "operatingIncome": "5007000000", + "otherOperatingExpense": "-1604000000", + "interestExpense": "158000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "479000000", + "totalOtherIncomeExpense": "-1840000000", + "discontinuedOperations": "-5000000", + "netIncomeFromContinuingOperations": "4506000000", + "netIncomeApplicableToCommonShares": "4501000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2016-09-30", + "reportedCurrency": "USD", + "totalRevenue": "19226000000", + "totalOperatingExpense": "5601000000", + "costOfRevenue": "10213000000", + "grossProfit": "9013000000", + "ebit": "3420000000", + "netIncome": "2853000000", + "researchAndDevelopment": "1397000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "3263000000", + "minorityInterest": "-475000000", + "sellingGeneralAdministrative": "4204000000", + "otherNonOperatingIncome": "8000000", + "operatingIncome": "3412000000", + "otherOperatingExpense": "0", + "interestExpense": "158000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "409000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "-1000000", + "netIncomeFromContinuingOperations": "2854000000", + "netIncomeApplicableToCommonShares": "2853000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2016-06-30", + "reportedCurrency": "USD", + "totalRevenue": "20238000000", + "totalOperatingExpense": "6449000000", + "costOfRevenue": "10536000000", + "grossProfit": "9702000000", + "ebit": "3216000000", + "netIncome": "2505000000", + "researchAndDevelopment": "1465000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "3049000000", + "minorityInterest": "156000000", + "sellingGeneralAdministrative": "4984000000", + "otherNonOperatingIncome": "-37000000", + "operatingIncome": "3253000000", + "otherOperatingExpense": "0", + "interestExpense": "167000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "544000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "-1000000", + "netIncomeFromContinuingOperations": "2505000000", + "netIncomeApplicableToCommonShares": "2505000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2016-03-31", + "reportedCurrency": "USD", + "totalRevenue": "18684000000", + "totalOperatingExpense": "7253000000", + "costOfRevenue": "9999000000", + "grossProfit": "8686000000", + "ebit": "1180000000", + "netIncome": "2013000000", + "researchAndDevelopment": "1458000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "1034000000", + "minorityInterest": "0", + "sellingGeneralAdministrative": "5795000000", + "otherNonOperatingIncome": "-253000000", + "operatingIncome": "1433000000", + "otherOperatingExpense": "0", + "interestExpense": "147000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "-983000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "-3000000", + "netIncomeFromContinuingOperations": "2016000000", + "netIncomeApplicableToCommonShares": "2013000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2015-12-31", + "reportedCurrency": "USD", + "totalRevenue": "22058000000", + "totalOperatingExpense": "6327000000", + "costOfRevenue": "10652000000", + "grossProfit": "11406000000", + "ebit": "5226000000", + "netIncome": "4464000000", + "researchAndDevelopment": "1362000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "5099000000", + "minorityInterest": "162000000", + "sellingGeneralAdministrative": "4965000000", + "otherNonOperatingIncome": "147000000", + "operatingIncome": "5079000000", + "otherOperatingExpense": "-669000000", + "interestExpense": "128000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "639000000", + "totalOtherIncomeExpense": "-572000000", + "discontinuedOperations": "3000000", + "netIncomeFromContinuingOperations": "4461000000", + "netIncomeApplicableToCommonShares": "4464000000", + "preferredStockAndOtherAdjustments": "None" + }, + { + "fiscalDateEnding": "2015-09-30", + "reportedCurrency": "USD", + "totalRevenue": "19280000000", + "totalOperatingExpense": "5830000000", + "costOfRevenue": "9844000000", + "grossProfit": "9436000000", + "ebit": "3739000000", + "netIncome": "2950000000", + "researchAndDevelopment": "1287000000", + "effectOfAccountingCharges": "0", + "incomeBeforeTax": "3621000000", + "minorityInterest": "0", + "sellingGeneralAdministrative": "4543000000", + "otherNonOperatingIncome": "133000000", + "operatingIncome": "3606000000", + "otherOperatingExpense": "0", + "interestExpense": "117000000", + "taxProvision": "None", + "interestIncome": "None", + "netInterestIncome": "None", + "extraordinaryItems": "0", + "nonRecurring": "0", + "otherItems": "0", + "incomeTaxExpense": "659000000", + "totalOtherIncomeExpense": "0", + "discontinuedOperations": "-12000000", + "netIncomeFromContinuingOperations": "2962000000", + "netIncomeApplicableToCommonShares": "2950000000", + "preferredStockAndOtherAdjustments": "None" + } + ] +} \ No newline at end of file From 3f4e06603d2440a612916ccfce2c24f9a73c1f76 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Thu, 3 Sep 2020 10:19:02 -0300 Subject: [PATCH 18/22] Return pd df when isinstance(data, list) in JSON --- alpha_vantage/alphavantage.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/alpha_vantage/alphavantage.py b/alpha_vantage/alphavantage.py index 34d9777..9a5f594 100644 --- a/alpha_vantage/alphavantage.py +++ b/alpha_vantage/alphavantage.py @@ -219,7 +219,11 @@ def _format_wrapper(self, *args, **kwargs): self, *args, **kwargs) if 'json' in self.output_format.lower() or 'pandas' \ in self.output_format.lower(): - data = call_response[data_key] + if data_key is not None: + data = call_response[data_key] + else: + data = call_response + if meta_data_key is not None: meta_data = call_response[meta_data_key] @@ -232,7 +236,22 @@ def _format_wrapper(self, *args, **kwargs): output_format = override.lower() # Choose output format if output_format == 'json': - return data, meta_data + if isinstance(data, list): + # If the call returns a list, then we will append them + # in the resulting data frame. If in the future + # alphavantage decides to do more with returning arrays + # this might become buggy. For now will do the trick. + if not data: + data_pandas = pandas.DataFrame() + else: + data_array = [] + for val in data: + data_array.append([v for _, v in val.items()]) + data_pandas = pandas.DataFrame(data_array, columns=[ + k for k, _ in data[0].items()]) + return data_pandas, meta_data + else: + return data, meta_data elif output_format == 'pandas': if isinstance(data, list): # If the call returns a list, then we will append them From 4be20274ebc753e25e37c1f2b53424770541f710 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Thu, 3 Sep 2020 10:19:21 -0300 Subject: [PATCH 19/22] New class to request Fundamental Data --- alpha_vantage/fundamentaldata.py | 117 +++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 alpha_vantage/fundamentaldata.py diff --git a/alpha_vantage/fundamentaldata.py b/alpha_vantage/fundamentaldata.py new file mode 100644 index 0000000..c3b0c00 --- /dev/null +++ b/alpha_vantage/fundamentaldata.py @@ -0,0 +1,117 @@ +from .alphavantage import AlphaVantage as av + +from datetime import datetime +search_date = datetime.now().date().strftime('%Y-%m-%d') + +class FundamentalData(av): + + """This class implements all the api calls to fundamental data + """ + def __init__(self, *args, **kwargs): + """ + Inherit AlphaVantage base class with its default arguments. + """ + super(FundamentalData, self).__init__(*args, **kwargs) + self._append_type = False + if self.output_format.lower() == 'csv': + raise ValueError("Output format {} is not compatible with the FundamentalData class".format( + self.output_format.lower())) + + @av._output_format + @av._call_api_on_func + def get_company_overview(self, symbol): + """ + Returns the company information, financial ratios, + and other key metrics for the equity specified. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'OVERVIEW' + return _FUNCTION_KEY, None, None + + @av._output_format + @av._call_api_on_func + def get_income_statement_annual(self, symbol): + """ + Returns the annual and quarterly income statements for the company of interest. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'INCOME_STATEMENT' + return _FUNCTION_KEY, 'annualReports', 'symbol' + + @av._output_format + @av._call_api_on_func + def get_income_statement_quarterly(self, symbol): + """ + Returns the annual and quarterly income statements for the company of interest. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'INCOME_STATEMENT' + return _FUNCTION_KEY, 'quarterlyReports', 'symbol' + + @av._output_format + @av._call_api_on_func + def get_balance_sheet_annual(self, symbol): + """ + Returns the annual and quarterly balance sheets for the company of interest. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'BALANCE_SHEET' + return _FUNCTION_KEY, 'annualReports', 'symbol' + + @av._output_format + @av._call_api_on_func + def get_balance_sheet_quarterly(self, symbol): + """ + Returns the annual and quarterly balance sheets for the company of interest. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'BALANCE_SHEET' + return _FUNCTION_KEY, 'quarterlyReports', 'symbol' + + @av._output_format + @av._call_api_on_func + def get_cash_flow_annual(self, symbol): + """ + Returns the annual and quarterly cash flows for the company of interest. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'CASH_FLOW' + return _FUNCTION_KEY, 'annualReports', 'symbol' + + @av._output_format + @av._call_api_on_func + def get_cash_flow_quarterly(self, symbol): + """ + Returns the annual and quarterly cash flows for the company of interest. + Data is generally refreshed on the same day a company reports its latest + earnings and financials. + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + """ + _FUNCTION_KEY = 'CASH_FLOW' + return _FUNCTION_KEY, 'quarterlyReports', 'symbol' From 03484a39026ff5cded8affe903b411ad5d776d4c Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Thu, 3 Sep 2020 10:19:46 -0300 Subject: [PATCH 20/22] New tests of class FundamentalData --- test_alpha_vantage/test_alphavantage.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test_alpha_vantage/test_alphavantage.py b/test_alpha_vantage/test_alphavantage.py index 624254c..4ad9c5b 100644 --- a/test_alpha_vantage/test_alphavantage.py +++ b/test_alpha_vantage/test_alphavantage.py @@ -4,6 +4,7 @@ from ..alpha_vantage.techindicators import TechIndicators from ..alpha_vantage.sectorperformance import SectorPerformances from ..alpha_vantage.foreignexchange import ForeignExchange +from ..alpha_vantage.fundamentaldata import FundamentalData from pandas import DataFrame as df, Timestamp @@ -200,3 +201,27 @@ def test_foreign_exchange(self, mock_request): from_currency='BTC', to_currency='CNY') self.assertIsInstance( data, dict, 'Result Data must be a dictionary') + + @requests_mock.Mocker() + def test_fundamental_data(self, mock_request): + """Test that api call returns a json file as requested + """ + fd = FundamentalData(key=TestAlphaVantage._API_KEY_TEST) + url = 'https://www.alphavantage.co/query?function=INCOME_STATEMENT&symbol=IBM&apikey=test' + path_file = self.get_file_from_url("mock_fundamental_data") + with open(path_file) as f: + mock_request.get(url, text=f.read()) + data, _ = fd.get_income_statement_annual(symbol='IBM') + self.assertIsInstance(data, df, 'Result Data must be a pandas data frame') + + @requests_mock.Mocker() + def test_company_overview(self, mock_request): + """Test that api call returns a json file as requested + """ + fd = FundamentalData(key=TestAlphaVantage._API_KEY_TEST) + url = "https://www.alphavantage.co/query?function=OVERVIEW&symbol=IBM&apikey=test" + path_file = self.get_file_from_url("mock_company_overview") + with open(path_file) as f: + mock_request.get(url, text=f.read()) + data, _ = fd.get_company_overview(symbol='IBM') + self.assertIsInstance(data, dict, 'Result Data must be a dictionary') \ No newline at end of file From e2568f8bace6fb4d6cbf911616a00657779bc6cc Mon Sep 17 00:00:00 2001 From: Tobias Kaesser Date: Sun, 20 Dec 2020 19:49:06 +0100 Subject: [PATCH 21/22] add intraday-extended endpoint --- alpha_vantage/timeseries.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/alpha_vantage/timeseries.py b/alpha_vantage/timeseries.py index 045fcd2..c12c1c0 100644 --- a/alpha_vantage/timeseries.py +++ b/alpha_vantage/timeseries.py @@ -24,6 +24,23 @@ def get_intraday(self, symbol, interval='15min', outputsize='compact'): _FUNCTION_KEY = "TIME_SERIES_INTRADAY" return _FUNCTION_KEY, "Time Series ({})".format(interval), 'Meta Data' + @av._output_format + @av._call_api_on_func + def get_intraday_extended(self, symbol, interval='15min', slice='year1month1'): + """ Return extended intraday time series in one csv_reader object. + It raises ValueError when problems arise + + Keyword Arguments: + symbol: the symbol for the equity we want to get its data + interval: time interval between two conscutive values, + supported values are '1min', '5min', '15min', '30min', '60min' + (default '15min') + slice: the trailing 2 years of intraday data is evenly divided into + 24 "slices" - year1month1, year1month2, ..., year2month12 + """ + _FUNCTION_KEY = "TIME_SERIES_INTRADAY_EXTENDED" + return _FUNCTION_KEY, "Time Series ({})".format(interval), 'Meta Data' + @av._output_format @av._call_api_on_func def get_daily(self, symbol, outputsize='compact'): @@ -115,7 +132,7 @@ def get_monthly_adjusted(self, symbol): @av._call_api_on_func def get_quote_endpoint(self, symbol): """ Return the latest price and volume information for a - security of your choice + security of your choice Keyword Arguments: symbol: the symbol for the equity we want to get its data From 83ffe43674dc9c27612e51964c60defe417b34fe Mon Sep 17 00:00:00 2001 From: PatrickAlphaC Date: Sun, 20 Dec 2020 21:24:47 -0500 Subject: [PATCH 22/22] prep for 2.3.0 --- README.md | 1 + docs/conf.py | 4 ++-- setup.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2234202..6f29801 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ For code-less access to the APIs, you may also consider the official [Google She ## News +* From version 2.3.0 onwards, fundamentals data and extended intraday is supported. * From version 2.2.0 onwards, asyncio support now provided. See below for more information. * From version 2.1.3 onwards, [rapidAPI](https://rapidapi.com/alphavantage/api/alpha-vantage-alpha-vantage-default) key integration is now available. * From version 2.1.0 onwards, error logging of bad API calls has been made more apparent. diff --git a/docs/conf.py b/docs/conf.py index 4974f39..6ca3ac0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = u'2.2.0' +version = u'2.3.0' # The full version, including alpha/beta/rc tags. -release = u'2.2.0' +release = u'2.3.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index a29a174..8c7df6b 100644 --- a/setup.py +++ b/setup.py @@ -4,14 +4,14 @@ here = path.abspath(path.dirname(__file__)) try: - with open(path.join(here, 'README.rst'), encoding='utf-8') as f: - long_description = f.read() + with open("README.md", "r") as fh: + long_description = fh.read() except IOError: long_description = 'Python module to get stock data from the Alpha Vantage Api' setup( name='alpha_vantage', - version='2.2.0', + version='2.3.0', author='Romel J. Torres', author_email='romel.torres@gmail.com', license='MIT',