mindspore/test.py

24 lines
742 B
Python

import yfinance as yf
from datetime import datetime, timedelta
import tushare as ts
# 使用你的Tushare API Token
ts.set_token('')
pro = ts.pro_api()
def get_stock_data(ticker: str, years: int = 1) -> tuple:
end_date = datetime.now().strftime('%Y%m%d')
start_date = (datetime.now() - timedelta(days=years * 365)).strftime('%Y%m%d')
df = pro.daily(ts_code='600000.SH', start_date='20100101', end_date='')
pe = pro.balancesheet(ts_code='600000.SH')
news_a = pro.news(src='600000.SH', start_date='2024-01-20 09:00:00', end_date='2024-10-8 10:10:00')
forecast = pro.forecast(start_date='20200101', end_date='20241010', ts_code='600570.SH')
current_price = pro.daily(ts_code='600570.SH')
print(current_price.iloc[0]['close'])