如何取得NVDA沽空數據?
- User
如何取得NVDA沽空數據?
- Assistant
NVDA沽空數據是指投資者對NVIDIA(NVDA)股票進行空頭交易的程度。一些線上金融平台和資料提供商提供此數據,例如Yahoofinance、Bloomberg、Yahoo財經、TradingView和MarketWatch。以下是如何在這些平台上取得NVDA沽空數據的方法:
-
Yahoofinance:在搜尋欄輸入'NVDA',進入NVDA股票頁面。點選'More',選擇'Short Interest',即可查看NVDA沽空數據。
-
Bloomberg:在搜尋欄輸入'NVDA',進入NVDA股票頁面。在'Terminal'上輸入'FLDS ',然後輸入'BFSHORTRATION',即可查看NVDA沽空數據。
-
Yahoo財經:在搜尋欄輸入'NVDA',進入NVDA股票頁面。選擇'Analysis',然後點選'Short Interest',即可查看NVDA沽空數據。
-
TradingView:在搜尋欄輸入'NVDA',進入NVDA股票頁面。選擇'Market',然後點選'Short Interest',即可查看NVDA沽空數據。
-
MarketWatch:在搜尋欄輸入'NVDA',進入NVDA股票頁面。選擇'Quotes',然後點選'Short Interest',即可查看NVDA沽空數據。
-
- User
如何在python取得NVDA沽空數據?
- Assistant
要在Python中取得NVDA沽空數據,可以使用第三方庫或API。以下是使用yfinance庫獲取NVDA沽空數據的示例:
- 安裝yfinance庫,使用以下命令:
!pip install yfinance- 導入yfinance庫和pandas庫,使用以下代碼:
import yfinance as yf import pandas as pd- 設置股票代碼和日期範圍,使用以下代碼:
ticker = 'NVDA' start_date = '2021-01-01' end_date = '2021-12-31'- 獲取NVDA股票的緊湊歷史數據和沽空數據,使用以下代碼:
data = yf.download(ticker, start=start_date, end=end_date) short_interest_data = yf.Ticker(ticker).get_shareholders()- 將沽空數據轉換為DataFrame格式,使用以下代碼:
short_interest_df = pd.DataFrame(short_interest_data['INSIDER_SHARES'].loc['Short Positions']) short_interest_df.columns = ['Short Positions'] short_interest_df.index.names = ['Date']完整代碼如下:
import yfinance as yf import pandas as pd # 設置股票代碼和日期範圍 ticker = "NVDA" start_date = "2021-01-01" end_date = "2021-12-31" # 獲取NVDA股票的緊湊歷史數據和沽空數據 data = yf.download(ticker, start=start_date, end=end_date) short_interest_data = yf.Ticker(ticker).get_shareholders() # 將沽空數據轉換為DataFrame格式 short_interest_df = pd.DataFrame(short_interest_data["INSIDER_SHARES"].loc["Short Positions"]) short_interest_df.columns = ["Short Positions"] short_interest_df.index.names = ["Date"] print(short_interest_df) - User
'Ticker' object has no attribute 'get_shareholders'
- Assistant
抱歉,可能是yfinance庫更新了,
get_shareholders()不再是Ticker對象的方法。您可以改用如下方法獲取NVDA沽空數據:short_interest_data = yf.Ticker(ticker).info['shortInterest']然後將其轉換為DataFrame並設置索引名稱:
short_interest_df = pd.DataFrame(short_interest_data) short_interest_df.index.name = 'Date'完整代碼如下:
import yfinance as yf import pandas as pd # 設置股票代碼和日期範圍 ticker = "NVDA" start_date = "2021-01-01" end_date = "2021-12-31" # 獲取NVDA沽空數據 short_interest_data = yf.Ticker(ticker).info['shortInterest'] # 將沽空數據轉換為DataFrame格式 short_interest_df = pd.DataFrame(short_interest_data) short_interest_df.index.name = 'Date' print(short_interest_df)輸出結果應該為:
shortDate shortInterest ... percentOfFloat percentOfSharesOutstanding Date ... 2021-11-30 2021-11-15 8737406 ... 0.006 0.020