-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancements to address 400 error related performance issues, #148
- Loading branch information
Connor Sanders
committed
Jun 21, 2023
1 parent
a01b485
commit bf30c47
Showing
8 changed files
with
85 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,11 @@ | |
|
||
setup( | ||
name='yahoofinancials', | ||
version='1.14', | ||
version='1.15', | ||
description='A powerful financial data module used for pulling both fundamental and technical data from Yahoo Finance', | ||
long_description=long_description, | ||
url='https://github.com/JECSand/yahoofinancials', | ||
download_url='https://github.com/JECSand/yahoofinancials/archive/1.14.tar.gz', | ||
download_url='https://github.com/JECSand/yahoofinancials/archive/1.15.tar.gz', | ||
author='Connor Sanders', | ||
author_email='[email protected]', | ||
license='MIT', | ||
|
@@ -32,7 +32,6 @@ | |
'Topic :: Software Development :: Libraries :: Python Modules', | ||
'Operating System :: OS Independent', | ||
'License :: OSI Approved :: MIT License', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
# YahooFinancials Unit Tests v1.14 | ||
# Version Released: 02/21/2023 | ||
# YahooFinancials Unit Tests v1.15 | ||
# Version Released: 06/21/2023 | ||
# Author: Connor Sanders | ||
# Tested on Python 3.6, 3.7, 3.8, 3.9, 3.10, and 3.11 | ||
# Copyright (c) 2023 Connor Sanders | ||
# Tested on Python 3.7, 3.8, 3.9, 3.10, and 3.11 | ||
# Copyright (c) 2023 Connor Sanders <[email protected]> | ||
# MIT License | ||
|
||
from unittest import main as test_main, TestCase | ||
|
||
from yahoofinancials import YahooFinancials | ||
from yahoofinancials import YahooFinancials as yf | ||
from unittest import main as t_main, TestCase | ||
|
||
# Test Configuration Variables | ||
stocks = ['AAPL', 'MSFT', 'C', 'IL&FSTRANS.NS'] | ||
|
@@ -40,12 +39,12 @@ def check_fundamental(test_data, test_type): | |
class TestModule(TestCase): | ||
|
||
def setUp(self): | ||
self.test_yf_stock_single = YahooFinancials('C') | ||
self.test_yf_stock_multi = YahooFinancials(stocks) | ||
self.test_yf_treasuries_single = YahooFinancials('^IRX') | ||
self.test_yf_treasuries_multi = YahooFinancials(us_treasuries) | ||
self.test_yf_currencies = YahooFinancials(currencies) | ||
self.test_yf_concurrent = YahooFinancials(stocks, concurrent=True) | ||
self.test_yf_stock_single = yf('C') | ||
self.test_yf_stock_multi = yf(stocks) | ||
self.test_yf_treasuries_single = yf('^IRX') | ||
self.test_yf_treasuries_multi = yf(us_treasuries) | ||
self.test_yf_currencies = yf(currencies) | ||
self.test_yf_concurrent = yf(stocks, concurrent=True) | ||
|
||
# Fundamentals Test | ||
def test_yf_fundamentals(self): | ||
|
@@ -78,20 +77,34 @@ def test_yf_fundamentals(self): | |
# Historical Price Test | ||
def test_yf_historical_price(self): | ||
single_stock_prices = self.test_yf_stock_single.get_historical_price_data('2015-01-15', '2017-10-15', 'weekly') | ||
expect_dict = {'high': 49.099998474121094, 'volume': 125737200, 'formatted_date': '2015-01-12', | ||
'low': 46.599998474121094, 'date': 1421038800, | ||
'close': 47.61000061035156, 'open': 48.959999084472656} | ||
expected = {'high': 49.099998474121094, 'volume': 125737200, 'formatted_date': '2015-01-12', | ||
'low': 46.599998474121094, 'date': 1421038800, | ||
'close': 47.61000061035156, 'open': 48.959999084472656} | ||
# ignore adjclose as it will change with every dividend paid in the future | ||
del single_stock_prices['C']['prices'][0]['adjclose'] | ||
self.assertDictEqual(single_stock_prices['C']['prices'][0], expect_dict) | ||
self.assertDictEqual(single_stock_prices['C']['prices'][0], expected) | ||
|
||
# Historical Stock Daily Dividend Test | ||
def test_yf_dividend_price(self): | ||
single_stock_dividend = self.test_yf_stock_single.get_daily_dividend_data('1986-09-15', '1987-09-15') | ||
expect_dict = {"C": [{'date': 544714200, 'formatted_date': '1987-04-06', 'amount': 0.332}, | ||
{'date': 552576600, 'formatted_date': '1987-07-06', 'amount': 0.332}] | ||
} | ||
self.assertDictEqual(single_stock_dividend, expect_dict) | ||
expected = {"C": [{'date': 544714200, 'formatted_date': '1987-04-06', 'amount': 0.332}, | ||
{'date': 552576600, 'formatted_date': '1987-07-06', 'amount': 0.332}]} | ||
self.assertDictEqual(single_stock_dividend, expected) | ||
|
||
# Test concurrent functionality of module | ||
def test_yf_concurrency(self): | ||
# Multi stock test | ||
multi_balance_sheet_data_qt = self.test_yf_concurrent.get_financial_stmts('quarterly', 'balance') | ||
multi_income_statement_data_qt = self.test_yf_concurrent.get_financial_stmts('quarterly', 'income') | ||
multi_all_statement_data_qt = self.test_yf_concurrent.get_financial_stmts('quarterly', | ||
['income', 'cash', 'balance']) | ||
# Multi stock check | ||
result = check_fundamental(multi_balance_sheet_data_qt, 'bal') | ||
self.assertEqual(result, True) | ||
result = check_fundamental(multi_income_statement_data_qt, 'inc') | ||
self.assertEqual(result, True) | ||
result = check_fundamental(multi_all_statement_data_qt, 'all') | ||
self.assertEqual(result, True) | ||
|
||
# Extra Module Methods Test | ||
def test_yf_module_methods(self): | ||
|
@@ -112,14 +125,15 @@ def test_yf_module_methods(self): | |
self.assertEqual(True, True) | ||
else: | ||
self.assertEqual(False, True) | ||
# Stock Profile Data | ||
if self.test_yf_stock_single.get_stock_profile_data().get("C").get("sector") == "Financial Services": | ||
|
||
# Stock Financial Data | ||
if self.test_yf_stock_single.get_financial_data().get("C").get("financialCurrency") == "USD": | ||
self.assertEqual(True, True) | ||
else: | ||
self.assertEqual(False, True) | ||
|
||
# Stock Financial Data | ||
if self.test_yf_stock_single.get_financial_data().get("C").get("financialCurrency") == "USD": | ||
# Stock Profile Data | ||
if self.test_yf_stock_single.get_stock_profile_data().get("C").get("sector") == "Financial Services": | ||
self.assertEqual(True, True) | ||
else: | ||
self.assertEqual(False, True) | ||
|
@@ -154,21 +168,6 @@ def test_yf_module_methods(self): | |
else: | ||
self.assertEqual(False, True) | ||
|
||
# Test concurrent functionality of module | ||
def test_yf_concurrency(self): | ||
# Multi stock test | ||
multi_balance_sheet_data_qt = self.test_yf_concurrent.get_financial_stmts('quarterly', 'balance') | ||
multi_income_statement_data_qt = self.test_yf_concurrent.get_financial_stmts('quarterly', 'income') | ||
multi_all_statement_data_qt = self.test_yf_concurrent.get_financial_stmts('quarterly', | ||
['income', 'cash', 'balance']) | ||
# Multi stock check | ||
result = check_fundamental(multi_balance_sheet_data_qt, 'bal') | ||
self.assertEqual(result, True) | ||
result = check_fundamental(multi_income_statement_data_qt, 'inc') | ||
self.assertEqual(result, True) | ||
result = check_fundamental(multi_all_statement_data_qt, 'all') | ||
self.assertEqual(result, True) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_main() | ||
t_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
""" | ||
============================== | ||
The Yahoo Financials Module | ||
Version: 1.14 | ||
Version: 1.15 | ||
============================== | ||
Author: Connor Sanders | ||
Email: [email protected] | ||
Version Released: 02/21/2023 | ||
Tested on Python 3.6, 3.7, 3.8, 3.9, 3.10, and 3.11 | ||
Version Released: 06/21/2023 | ||
Tested on Python 3.7, 3.8, 3.9, 3.10, and 3.11 | ||
Copyright (c) 2023 Connor Sanders | ||
MIT License | ||
|
@@ -44,7 +44,7 @@ | |
from yahoofinancials.calcs import num_shares_outstanding, eps | ||
from yahoofinancials.etl import YahooFinanceETL | ||
|
||
__version__ = "1.14" | ||
__version__ = "1.15" | ||
__author__ = "Connor Sanders" | ||
|
||
|
||
|
@@ -76,7 +76,7 @@ def _run_financial_stmt(self, statement_type, report_num, frequency, reformat): | |
report_name = self.YAHOO_FINANCIAL_TYPES[statement_type][report_num] | ||
if reformat: | ||
raw_data = self.get_stock_data(statement_type, report_name=report_name, hist_obj=hist_obj) | ||
data = self.get_reformatted_stmt_data(raw_data, statement_type) | ||
data = self.get_reformatted_stmt_data(raw_data) | ||
else: | ||
data = self.get_stock_data(statement_type, report_name=report_name, hist_obj=hist_obj) | ||
return data | ||
|