วิเคราะห์ข้อมูลหุ้น BMW ด้วย Python

การวิเคราะห์และแสดงกราฟ

การวิเคราะห์แนวโน้มราคา

สร้างกราฟแนวโน้มราคา
plt.figure(figsize=(10, 6))
data['Adj_Close'].plot(title='Stock Price Trend (Adj_Close)', ylabel='Price', xlabel='Date')
plt.show()

กราฟแสดงแนวโน้มราคาปรับปรุง (Adj_Close) ของหุ้น BMW

0 20 40 60 80 1996 2000 2004 2008 2012 2024

โค้ดส่วนนี้สร้างกราฟเส้นแสดงแนวโน้มของราคาปรับปรุง (Adjusted Close Price) ของหุ้น BMW ตลอดช่วงเวลาในข้อมูล ซึ่งช่วยให้เห็นภาพรวมของการเปลี่ยนแปลงราคาหุ้น

การวิเคราะห์การเติบโตรายปี

คำนวณการเติบโตรายปี
yearly_growth = data.groupby('Year')['Adj_Close'].agg(['first', 'last'])
yearly_growth['Growth (%)'] = ((yearly_growth['last'] - yearly_growth['first']) / yearly_growth['first']) * 100
print(yearly_growth[['Growth (%)']])

plt.figure(figsize=(10, 6))
plt.plot(yearly_growth.index, yearly_growth['Growth (%)'], marker='o', linestyle='-', color='b', label='Yearly Growth (%)')
plt.title('Yearly Growth of Adjusted Close Price')
plt.xlabel('Year')
plt.ylabel('Growth (%)')
plt.grid(True)
plt.legend()
plt.show()

กราฟแสดงการเติบโตของราคาหุ้นรายปี (%)

0% -20% 0% 20% 40% 1996 2000 2004 2008 2012 2016 2020 2024

การวิเคราะห์การเติบโตรายปี: