mindspore/test.py

64 lines
1.2 KiB
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'])
17:06:11.16
17:06:54.18
17:07:25.83
17:07:56.14
17:08:25.27
17:08:56.32
17:09:24.92
17:09:54.98
17:10:25.73
17:10:56.38
17:11:28.12
17:11:56.77
17:12:25.80
17:12:54.73
17:13:23.69
17:13:55.85
17:14:27.10
17:15:00.01
17:15:30.13
17:15:59.72
17:16:28.79
17:16:56.86
17:17:25.80
17:17:56.23
17:18:25.92
17:18:55.75
17:19:24.76
17:19:54.77
17:20:22.73
17:20:53.17
17:21:22.24
17:21:52.94
17:22:20.78
17:22:49.96
17:23:18.93
17:23:48.80
17:24:17.78
17:24:46.79
17:25:15.75
17:25:44.34