gluo88 commited on
Commit
7a554a1
·
verified ·
1 Parent(s): 8bcf58c

Update space_stock_plot.py

Browse files

2025-02.23.0027: fixing an issue (https://github.com/ranaroussi/yfinance/issues/2283)
which is introduced by yfinance version 0.2.54 (released on Feb 18, 2025 ).
The "Adj Close" column is missing from yf.download since yf.download default changed
from auto_adjust=False to auto_adjust=True. When auto_adjust=True, column Close is actually Adj Close and
Adj Close column does not exist any more. In order to fix the issue, auto_adjust=False is used explicitly in download function,
to get back the Adj Close column.
The "Adj Close" column is also missing from using ticker = yf.Ticker("AAPL") data = ticker.history(period="1y")

Files changed (1) hide show
  1. space_stock_plot.py +16 -7
space_stock_plot.py CHANGED
@@ -1,16 +1,26 @@
1
  '''
2
  graphical line diagram of stock cumulative returns
3
  Note: Raw Data is from Yahoo Finance using python yfinance
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  '''
5
- # versions:
6
- # 2024-01-28.1: creation of the file
7
- # 2025-0223-1104: yf.download default changed to auto_adjust=True at yfinance version 0.2.54,
8
- # when auto_adjust=True, Close = Adj Close and Adj Close does not exist
9
- script_version = '(2025-0223-1104)'
10
  # Import the libraries
11
  import gradio as gr
12
  import yfinance as yf
13
  import pandas as pd
 
14
 
15
  def stock_return_df(tickers, start, end):
16
  # Download the historical data
@@ -43,5 +53,4 @@ interface = gr.Interface(
43
  )
44
 
45
  # Launch the interface
46
- interface.launch(debug=False)
47
-
 
1
  '''
2
  graphical line diagram of stock cumulative returns
3
  Note: Raw Data is from Yahoo Finance using python yfinance
4
+ Author: Gang Luo
5
+
6
+ Revision history:
7
+ 2024-01-28.1:
8
+ Creation of the file
9
+ 2025-02.23.0027: fixing an issue (https://github.com/ranaroussi/yfinance/issues/2283)
10
+ which is introduced by yfinance version 0.2.54 (released on Feb 18, 2025 ).
11
+ The "Adj Close" column is missing from yf.download since yf.download default changed
12
+ from auto_adjust=False to auto_adjust=True. When auto_adjust=True, column Close is actually Adj Close and
13
+ Adj Close column does not exist any more. In order to fix the issue, auto_adjust=False is used explicitly in download function,
14
+ to get back the Adj Close column.
15
+ The "Adj Close" column is also missing from using ticker = yf.Ticker("AAPL") data = ticker.history(period="1y")
16
+
17
  '''
18
+ script_version = '(2025-0223-1156)'
 
 
 
 
19
  # Import the libraries
20
  import gradio as gr
21
  import yfinance as yf
22
  import pandas as pd
23
+ import matplotlib
24
 
25
  def stock_return_df(tickers, start, end):
26
  # Download the historical data
 
53
  )
54
 
55
  # Launch the interface
56
+ interface.launch(debug=False)