# Lưu giá trị API key vào mục Secrets của Colab thì dùng cách này, hoặc gán trực tiếp giá trị API cho biến GEMINI_TOKEN để dùng from google.colab import userdata GEMINI_TOKEN = userdata.get('gemini_tk_tvb') # !pip install aiconn !pip install git+https://github.com/thinh-vu/vnstock from aiconn import GeminiAI gemini = GeminiAI(api_key=GEMINI_TOKEN, gemini_model='gemini-1.5-flash') from vnstock3 import Vnstock stock = Vnstock().stock(symbol='VCI', source='VCI') income_df = stock.finance.income_statement(period='quarter', lang='vi') income_df.head() balance_df = stock.finance.balance_sheet(period='quarter', lang='vi') balance_df.head() cashflow_df = stock.finance.cash_flow(period='quarter', lang='vi') cashflow_df.head() ratio_df = stock.finance.ratio(period='quarter', lang='vi') ratio_df.head() # @title Instructions INSTRUCTION = """ - As a CFA-certified financial analyst with a deep understanding of fundamental analysis, you will help me evaluate companies in the Vietnam Stock Market. - Follow this structured guide for every analysis: 1. **Industry Overview**: - Identify the company’s industry and provide an overview of its key trends, opportunities, and challenges within the Vietnam market. 2. **Financial Statement Analysis**: - **Income Statement**: Analyze revenue growth, profitability (gross margin, operating margin, net income margin), and key expenses. - **Balance Sheet**: Evaluate the company’s assets, liabilities, equity, and overall financial health (liquidity, solvency). - **Cash Flow Statement**: Focus on operating cash flow, capital expenditures, and free cash flow trends. 3. **Key Ratios**: - **Profitability Ratios**: Return on Equity (ROE), Return on Assets (ROA), and Net Profit Margin. - **Liquidity Ratios**: Current Ratio, Quick Ratio. - **Solvency Ratios**: Debt to Equity, Interest Coverage. - **Valuation Ratios**: Price-to-Earnings (P/E), Price-to-Book (P/B), and Enterprise Value/EBITDA (EV/EBITDA). 4. **Valuation**: - Use Discounted Cash Flow (DCF) analysis or relative valuation methods (P/E, P/B, EV/EBITDA) to assess whether the company is fairly valued. 5. **Growth Potential**: - Examine the company’s historical growth trends and potential for future growth in revenue, profits, and market share. 6. **Risk Assessment**: - Identify major risks the company faces, including financial, operational, and market risks. 7. **Investment Recommendation**: - Provide a clear buy/hold/sell recommendation and justify it with your findings. - Always present your analysis in **Vietnamese**, regardless of the language used in my questions. - Keep your responses concise but thorough, following the above structure. """ gemini.start_chat(instruction=INSTRUCTION) REPORTS_FEEDING = f""" Please start your analysis step by step using the actual reports provide to you in markdown format. Each report data will be delimited with --- section --- BALANCE SHEET DATA: {balance_df} --- INCOME_STATEMENT DATA: {income_df} --- CASHFLOW DATA: {cashflow_df} --- RATIOS DATA: {ratio_df} --- """ gemini.send_message(prompt=REPORTS_FEEDING) gemini.send_message('How key metrics in the financial reports of VCI perform over time? Refer to actual data I provided to you. Explain in comprehensive, cohisive manner') gemini.send_message(f'Phân tích chi tiết các chỉ tiêu trong bảng cân đối kế toán được cung cấp, dẫn chứng với số liệu cụ thể. Dữ liệu bảng cân đối kế toán được cung cấp dưới dạng markdown dưới đây, lưu ý dữ liệu được cung cấp theo quý với thông tin Năm và Kỳ tức Quý trong trường hợp này: {balance_df}') gemini.send_message('Dữ liệu bạn cung cấp không khớp với dữ liệu tôi gửi cho bạn') gemini.send_message(f'Hãy dùng dữ liệu được cung cấp dưới dạng văn bản thuần dưới đây: {balance_df.to_string()}') balance_df[['Năm', 'Kỳ', 'Tài sản lưu động khác']] from vnstock3 import Vnstock stock = Vnstock().stock(symbol='VNINDEX', source='VCI') VNINDEX = stock.quote.history(start='2023-10-16', end='2024-10-16', interval='1D') HNXINDEX= stock.quote.history(symbol='HNXINDEX', start='2023-10-16', end='2024-10-16', interval='1D')