{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# StockInsightAgent — 智能股票分析助手\n", "\n", "基于 Hello-Agents 教程 + akshare 实时数据,从技术面、基本面、消息面三维度综合分析 A 股。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. 环境准备" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from framework_agent import FrameworkStockAgent\n", "\n", "agent = FrameworkStockAgent()\n", "print('StockInsightAgent 已就绪')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. 快速分析 (ReAct)\n", "\n", "获取实时行情,约 30 秒完成。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "result = agent.react(\"贵州茅台600519现在什么价格?\")\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. 深度分析 (PlanSolve)\n", "\n", "从基本面、技术面、估值等多维度全面评估,约 2-3 分钟。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "result = agent.plan_solve(\"全面分析中国平安601318的投资价值\")\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. 批判分析 (Reflection)\n", "\n", "生成报告后再自我审查改进,约 3-5 分钟。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "result = agent.reflect(\"宁德时代300750目前是否值得买入?\")\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. 记忆系统\n", "\n", "持久化关注列表、分析历史和用户偏好。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from memory import memory_add_watchlist, memory_get_watchlist, memory_get_history\n", "\n", "# 添加关注\n", "memory_add_watchlist(\"600519|贵州茅台\")\n", "memory_add_watchlist(\"000858|五粮液\")\n", "\n", "# 查看关注列表\n", "print(memory_get_watchlist())\n", "print()\n", "print(memory_get_history())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 6. 知识库检索\n", "\n", "查询投资知识库中的估值方法和风控原则。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from rag import rag_search, rag_stats\n", "\n", "print(rag_stats())\n", "print()\n", "print(rag_search(\"PE估值方法\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 7. 技术指标自主计算\n", "\n", "直接调用工具函数获取 MA/MACD/RSI/布林带。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tools import get_realtime_quote, calc_indicators, get_news\n", "\n", "print(\"=== 实时行情 ===\")\n", "print(get_realtime_quote(\"600519\"))\n", "\n", "print()\n", "print(\"=== 技术指标 ===\")\n", "print(calc_indicators(\"600519|daily|60\"))\n", "\n", "print()\n", "print(\"=== 最新新闻 ===\")\n", "print(get_news(\"600519\"))" ] } ], "metadata": { "kernelspec": { "display_name": "Robot", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12.0" } }, "nbformat": 4, "nbformat_minor": 4 }