使用OpenAI chatGPT技術, 根據公司公開重大訊息的內容做出解讀,主要是看這訊息對公司股東的影響,進而會不會影響到股價
公開資訊觀測站 : https://mops.twse.com.tw/mops/web/t05sr01_1
天地AI股市新聞 : http://www.tendy.net/tendy_ai_news.php
天地AI股市新聞 : http://www.tendy.net/tendy_ai_news.php
天地資訊 : http://www.tendy.net/
程式碼
import requests
from bs4 import BeautifulSoup
import openai
url = "https://mops.twse.com.tw/mops/web/ajax_t05st01?firstin=1&TYPEK=all&step=2&seq_no=2&spoke_time=175712&spoke_date=20230501&co_id=2402&skey=2402202305012"
resp = requests.get(url)
html = resp.content
soup = BeautifulSoup(html,'html.parser')
text = soup.get_text()
text = text.replace('\n','')
openai.api_key = '自己的api key'
q = f"解讀以下內容對股東的影響 用少於100字來說明: \n\n{text}"
res = openai.ChatCompletion.create( model="gpt-3.5-turbo",messages=[{"role":"user","content":q}])
ans = res['choices'][0]['message']['content']
print(ans)