Subject: [PATCH 03/17] gnu: Add python-yfinance.

From: Vinicius Monego <[email-masked]>
Date: Sat, 17 Jun 2023 15:18:26 +0000

* gnu/packages/finance.scm (python-yfinance): New variable.
---
 gnu/packages/finance.scm | 43 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index 2a4929ccd0..769742c015 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -19,7 +19,7 @@
 ;;; Copyright © 2020 Christine Lemmer-Webber <[email-masked]>
 ;;; Copyright © 2020 Tom Zander <[email-masked]>
 ;;; Copyright © 2020 Marius Bakke <[email-masked]>
-;;; Copyright © 2020, 2021, 2022 Vinicius Monego <[email-masked]>
+;;; Copyright © 2020, 2021, 2022, 2023 Vinicius Monego <[email-masked]>
 ;;; Copyright © 2020 Carlo Holl <[email-masked]>
 ;;; Copyright © 2020 Giacomo Leidi <[email-masked]>
 ;;; Copyright © 2021 ZmnSCPxj jxPCSnmZ <[email-masked]>
@@ -1034,6 +1034,47 @@ (define-public python-mnemonic
 of Bitcoin BIP-0039.")
     (license license:expat)))
 
+(define-public python-yfinance
+  (package
+    (name "python-yfinance")
+    (version "0.2.20")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "yfinance" version))
+              (sha256
+               (base32
+                "0p8m2445vyanpc7dk3fcfqis66217zn5kswh9f0ryjn3c2x5zsdr"))))
+    (build-system python-build-system)
+    (arguments
+     (list #:tests? #f ;no tests in PyPI and they test the online API
+           #:phases #~(modify-phases %standard-phases
+                        ;; we have pytz==2022.1 and it's a core package
+                        (add-after 'unpack 'relax-pytz
+                          (lambda _
+                            (substitute* "setup.py"
+                              (("pytz>=2022.5")
+                               "pytz"))))
+                        ;; yfinance provides a sample script via entry_points
+                        ;; which breaks sanity-check.
+                        (delete 'sanity-check))))
+    (propagated-inputs (list python-appdirs
+                             python-beautifulsoup4
+                             python-cryptography
+                             python-frozendict
+                             python-html5lib
+                             python-lxml
+                             python-multitasking
+                             python-numpy
+                             python-pandas
+                             python-pytz
+                             python-requests))
+    (home-page "https://github.com/ranaroussi/yfinance")
+    (synopsis "Download market data from Yahoo! Finance API")
+    (description
+     "@code{yfinance} offers a threaded and Pythonic way to download market
+ data from Yahoo! finance.")
+    (license license:asl2.0)))
+
 (define-public python-u2flib-host
   ;; The package is obsolete and superseded by python-fido2, but
   ;; needed for [email-masked].
-- 
2.34.1