Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session Management Refactor & Hardening #168

Merged
merged 11 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@
1.16 07/17/2023 -- Minor code cleanup in test_yahoofinancials.py.
1.16 07/17/2023 -- Fixed HTTP 401 error when executing get_current_price() as reported in #152.
1.17 10/30/2023 -- Added a fix for 404 error reported in #157.
1.18 12/12/2023 -- Merged in branch from shaunpatterson to fix #164.
1.18 12/09/2023 -- Merged in branch from shaunpatterson to fix #164.
1.19 12/12/2023 -- Refactored session management system to handle cookie and crumbs better.
1.19 12/12/2023 -- Added fixes for #167, #166, #160.
7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ A python module that returns stock, cryptocurrency, forex, mutual fund, commodit
.. image:: https://static.pepy.tech/badge/yahoofinancials/week
:target: https://pepy.tech/project/yahoofinancials

Current Version: v1.18
Current Version: v1.19

Version Released: 12/09/2023
Version Released: 12/12/2023

Report any bugs by opening an issue here: https://github.com/JECSand/yahoofinancials/issues

Expand Down Expand Up @@ -47,8 +47,7 @@ A powerful financial data module used for pulling both fundamental and technical

Installation
-------------
- yahoofinancials runs on Python 3.7, 3.8, 3.9, 3.10, and 3.11.
- This package depends on pytz & requests to work.
- yahoofinancials runs on Python 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12

1. Installation using pip:

Expand Down
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@

setup(
name='yahoofinancials',
version='1.18',
version='1.19',
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.18.tar.gz',
download_url='https://github.com/JECSand/yahoofinancials/archive/1.19.tar.gz',
author='Connor Sanders',
author_email='[email protected]',
license='MIT',
keywords=['finance data', 'stocks', 'commodities', 'cryptocurrencies', 'currencies', 'forex', 'yahoo finance'],
packages=['yahoofinancials'],
install_requires=[
"pytz",
"requests>=2.26",
"pytz>=2022.5",
"requests>=2.31",
"appdirs>=1.4.4",
"frozendict>=2.3.4",
"peewee>=3.16.2",
"beautifulsoup4>=4.11.1",
"lxml>=4.9.1",
],
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand All @@ -37,6 +42,7 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
zip_safe=False
)
45 changes: 32 additions & 13 deletions test/test_yahoofinancials.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# YahooFinancials Unit Tests v1.18
# Version Released: 12/09/2023
# YahooFinancials Unit Tests v1.19
# Version Released: 12/12/2023
# Author: Connor Sanders
# Tested on Python 3.7, 3.8, 3.9, 3.10, and 3.11
# Copyright (c) 2023 Connor Sanders <[email protected]>
Expand Down Expand Up @@ -107,66 +107,85 @@ def test_yf_concurrency(self):
def test_yf_module_methods(self):

# 10 Day Average Daily Volume
if isinstance(self.test_yf_stock_single.get_ten_day_avg_daily_volume(), int):
out = self.test_yf_stock_single.get_ten_day_avg_daily_volume()
if isinstance(out, int):
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Current Price
if isinstance(self.test_yf_stock_single.get_current_price(), float):
out = self.test_yf_stock_single.get_current_price()
if isinstance(out, float):
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Net Income
if isinstance(self.test_yf_stock_single.get_net_income(), float):
out = self.test_yf_stock_single.get_net_income()
if isinstance(out, float):
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":
out = self.test_yf_stock_single.get_financial_data()
if out.get("C").get("financialCurrency") == "USD":
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":
out = self.test_yf_stock_single.get_stock_profile_data()
if out.get("C").get("sector") == "Financial Services":
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Summary Data
if self.test_yf_stock_single.get_summary_data().get("C").get("currency") == "USD":
out = self.test_yf_stock_single.get_summary_data()
if out.get("C").get("currency") == "USD":
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Price Data
if self.test_yf_stock_single.get_stock_price_data().get("C").get("exchangeName") == "NYSE":
out = self.test_yf_stock_single.get_stock_price_data()
if out.get("C").get("exchangeName") == "NYSE":
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Key Statistics
if isinstance(self.test_yf_stock_single.get_key_statistics_data().get("C").get("forwardPE"), float):
out = self.test_yf_stock_single.get_key_statistics_data()
if isinstance(out.get("C").get("forwardPE"), float):
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock ESG SCORES
if self.test_yf_stock_single.get_esg_score_data().get("C").get("peerGroup") == "Banks":
out = self.test_yf_stock_single.get_esg_score_data()
if out.get("C").get("peerGroup") == "Banks":
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Treasuries
if isinstance(self.test_yf_treasuries_single.get_current_price(), float):
out = self.test_yf_stock_single.get_current_price()
if isinstance(out, float):
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Earnings data check
if isinstance(self.test_yf_stock_single.get_stock_earnings_data().get("C").get("earningsChart").get("quarterly")[0].get("actual"), float):
out = self.test_yf_stock_single.get_stock_earnings_data()
if isinstance(out.get("C").get("earningsChart").get("quarterly")[0].get("actual"), float):
self.assertEqual(True, True)
else:
self.assertEqual(False, True)

# Stock Data
out = self.test_yf_stock_single.get_stock_data()
if out.get("C").get("sector") == "Financial Services":
self.assertEqual(True, True)
else:
self.assertEqual(False, True)
Expand Down
Loading