Mô hình AI/ML
Mô hình AI để phân tích giá cổ phiếu trong lịch sử
import requests
import google.generativeai as genai
import pandas as pd
from FiinQuantX import FiinSession
from bs4 import BeautifulSoup
GOOGLE_GEMINI_API_KEY = 'YOUR_GOOGLE_GEMINI_API_KEY'
genai.configure(api_key=GOOGLE_GEMINI_API_KEY)
model = genai.GenerativeModel("gemini-1.5-flash")
username = 'REPLACE_WITH_YOUR_USER_NAME'
password = 'REPLACE_WITH_YOUR_PASS_WORD'
client = FiinSession(
username=username,
password=password
).login()
VCB_data = client.Fetch_Trading_Data(
tickers=['VCB'],
fields=['close'],
realtime=False,
adjusted=True,
by='1d',
from_date='2020-01-01',
to_date='2025-01-29').get_data()Output:
Mô Hình Machine Learning dự đoán giá cổ phiếu
Lấy dữ liệu cổ phiếu từ thư viện Fiinquant
1. Linear Regression
Chuẩn bị dữ liệu và chạy mô hình

2. Random Forest/ XG Boost

3. Long short-term memory network (LSTM)
Mạng LSTM cần thêm features ngoài Open High Low Volume để học được tính chất giá của cổ phiếu
Tạo cột Label chính là giá 'Close' của ngày hôm trước
Tạo thêm feature
Chuẩn hoá dữ liệu
Model
.....

Last updated