id: e70ed6fa753c4898a70fbcd5392fd78a
parent_id: 
item_type: 1
item_id: 9776c42cb4954b25b788ccec0de88350
item_updated_time: 1764345620949
title_diff: "[{\"diffs\":[[1,\"使用ollama完成股票技术指标的评价\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":19}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>使用ollama完成股票技术指标的评价</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <meta name=\\\"content-class\\\" content=\\\"yinxiang.peso.superNote\\\"/>\\\r\\\n  <meta name=\\\"application-data:yinxiang.noteLayout\\\" content=\\\"{\\\"lineSpace\\\":\\\"recommend\\\",\\\"paragraphSpace\\\":\\\"recommend\\\"}\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"37340\\\"></a>\\\r\\\n<h1>使用ollama完成股票技术指标的评价</h1>\\\r\\\n\\\r\\\n<div><span style=\\\"margin:0px;\\\"><div style=\\\"padding:8px 0px;margin:8px auto;max-width:700px;\\\"> <div><span></span></div>\\\n<p></p>\\\n<div style=\\\"--en-blockquote:true;box-sizing: border-box; padding-left: 19px; padding-top: 6px; padding-bottom: 6px; border-left: 3px solid #b4c0cc; background-position: initial initial; background-repeat: initial initial; margin-top: 6px\\\"><div>原文链接: <a href=\\\"http://mp.weixin.qq.com/s?__biz=MzUyOTAzNDg2NA==&amp;mid=2247484694&amp;idx=1&amp;sn=0ee95de61317950f88d20d4f0556abca&amp;chksm=fbbf8d61423cd62d11d8a0efe6e46c157e448419aa8bc23cb884ea04270c222d051e3d0ae280&amp;mpshare=1&amp;scene=1&amp;srcid=0120QRLuU9CCHznSw33e6gIf&amp;sharer_shareinfo=fcaf83833c38a37754df1b457fbc99f4&amp;sharer_shareinfo_first=fcaf83833c38a37754df1b457fbc99f4#rd\\\"><span>http://mp.weixin.qq.com/s?__biz=MzUyOTAzNDg2NA==&amp;mid=2247484...</span></a></div></div>\\\n<p></p>\\\n<div><span></span></div>\\\n<div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><h1 style=\\\"-webkit-tap-highlight-color:transparent;margin:0\\\"> 使用ollama完成股票技术指标的评价 </h1><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;position:relative\\\">原创</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;position:relative\\\">fintechhaibin</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><a style=\\\"-webkit-tap-highlight-color:transparent;position:relative\\\"> FinTechHi </a></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><em style=\\\"-webkit-tap-highlight-color:transparent\\\"></em></span></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">本篇文章有几个有意思的点：</span></span></div><ul style=\\\"-webkit-tap-highlight-color:transparent;margin:0;list-style-type:disc\\\"><li style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">1.使用streamlit可视化。</span></span></div></li><li style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">2.计算滚动平均值和动量等指标来了解市场趋势。</span></span></div></li><li style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">3.使用Llama 3对数据做解释。</span></span></div></li></ul><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">提前安装并导入如下包：</span></span></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">import</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> yfinance </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">as</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> yf</span></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">import</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> pandas </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">as</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> pd</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">import</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> schedule</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">import</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> time</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">import</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> ollama</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">from</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> datetime </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">import</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> datetime, timedelta</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;color:rgba(0,0,0,0.9);font-size:17px;font-family:&quot;mp-quote&quot;,-apple-system-font,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;PingFang SC&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;line-height:1.6;letter-spacing:0.034em;font-style:normal;font-weight:normal\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\"># Fetching historical data for Apple (AAPL) and Dow Jones (DJI) for yesterday (1-minute intervals)</span></span></code><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">stock </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> yf.Ticker(&quot;AAPL&quot;)</span></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">dow_jones </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> yf.Ticker(&quot;^DJI&quot;)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">data </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> stock.history(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">period</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;1d&quot;, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">interval</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;1m&quot;)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">dow_data </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> dow_jones.history(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">period</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;1d&quot;, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">interval</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;1m&quot;)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">data.head()</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;text-align:center;\\\"><img src=\\\":/b1d0c75c4dcb40d18a286271a699f7b8\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;-webkit-tap-highlight-color:transparent\\\"/></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">Global</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> variables </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">to</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> store rolling data </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">for</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> analysis</span></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">rolling_window = pd.DataFrame()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">dow_rolling_window = pd.DataFrame()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"># Variables to track daily context</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">daily_high = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">float</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'-inf'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">daily_low = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">float</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'inf'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">buying_momentum = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">selling_momentum = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span></span></div></div></pre></div><p style=\\\"-webkit-tap-highlight-color:transparent;margin:0\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">这段代码定义了一些全局变量，用于存储滚动数据和跟踪每日的市场情况。  </span></span></p><ul style=\\\"-webkit-tap-highlight-color:transparent;margin:0;list-style-type:disc\\\"><li style=\\\"-webkit-tap-highlight-color:transparent\\\"><p style=\\\"-webkit-tap-highlight-color:transparent;margin:0\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">rolling_window和dow_rolling_window用于存储苹果公司和道琼斯指数的滚动数据。然后定义了几个变量来跟踪每日的市场情况。  </span></span></p></li><li style=\\\"-webkit-tap-highlight-color:transparent\\\"><p style=\\\"-webkit-tap-highlight-color:transparent;margin:0\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">daily_high和 daily_low分别初始化为负无穷大和正无穷大，用于记录当天的最高价和最低价。通过将它们初始化为极端值，可以确保在实际数据更新时，这些变量会被正确地设置为当天的实际最高价和最低价。  </span></span></p></li><li style=\\\"-webkit-tap-highlight-color:transparent\\\"><p style=\\\"-webkit-tap-highlight-color:transparent;margin:0\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">buying_momentum和selling_momentum变量初始化为0，用于跟踪当天的买入和卖出动量。这些变量可以帮助分析市场情绪和趋势，判断市场是处于买入还是卖出状态。</span></span></p></li></ul><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;color:rgba(0,0,0,0.9);font-size:17px;font-family:&quot;mp-quote&quot;,-apple-system-font,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;PingFang SC&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;line-height:1.6;letter-spacing:0.034em;font-style:normal;font-weight:normal\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></code><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;color:rgba(0,0,0,0.9);font-size:17px;font-family:&quot;mp-quote&quot;,-apple-system-font,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;PingFang SC&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;line-height:1.6;letter-spacing:0.034em;font-style:normal;font-weight:normal\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px;font-weight:bold\\\">get_market_open_duration</span><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">：Extract current time from the last element of the window</span></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">def</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">get_market_open_duration</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">window</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">):</span></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"># Extract current time from the last element of the window</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    current_time = window.index[-1].time()  # Returns a datetime.time object</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    # Get the previous trading day's date</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    previous_trading_day = datetime.today() - timedelta(days=1)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    # Combine the previous trading day with the current time</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    current_datetime = datetime.combine(previous_trading_day, current_time)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    # Define the market opening time as 09:30:00 on the previous trading day</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    market_start_time = datetime.combine(previous_trading_day, datetime.strptime(&quot;09:30:00&quot;, &quot;%H:%M:%S&quot;).time())</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    # Calculate the duration the market has been open in minutes</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    market_open_duration = (current_datetime - market_start_time).total_seconds() / 60  # in minutes</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    return market_open_duration</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;color:rgba(0,0,0,0.9);font-size:17px;font-family:&quot;mp-quote&quot;,-apple-system-font,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;PingFang SC&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;line-height:1.6;letter-spacing:0.034em;font-style:normal;font-weight:normal\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">get_natural_language_insights</span><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">：generate natural language insights using Ollama（******重点这里，可以换成其他模型。）</span></span></code><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">def</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">get_natural_language_insights</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    rolling_avg, ema, rsi, bollinger_upper, bollinger_lower,</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    price_change, volume_change, dow_rolling_avg, market_open_duration, dow_price_change, dow_volume_change, daily_high, daily_low, buying_momentum, selling_momentum</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">):</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    prompt = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f&quot;&quot;&quot;</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    You are a professional stock broker. Apple's stock has a 5-minute rolling average of </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{rolling_avg:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The Exponential Moving Average (EMA) is </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{ema:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, and the Relative Strength Index (RSI) is </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{rsi:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The Bollinger Bands are set with an upper band of </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{bollinger_upper:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> and a lower band of </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{bollinger_lower:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The price has changed by </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{price_change:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, and the volume has shifted by </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{volume_change}</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The DOW price has changed by </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{dow_price_change:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, and the volume has shifted by </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{dow_volume_change}</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    Meanwhile, the Dow Jones index has a 5-minute rolling average of </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{dow_rolling_avg:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The market has been open for </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{market_open_duration:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> minutes.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    Today's high was </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{daily_high:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> and low was </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{daily_low:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The buying momentum is </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{buying_momentum:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> and selling momentum is </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">{selling_momentum:</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.2</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">f}</span></span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    Based on this data, provide insights into the current stock trend and the general market sentiment.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    The insights should not be longer than 100 words and should not have an introduction.</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    &quot;&quot;&quot;</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    response = ollama.chat(</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            model=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;llama3&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">,</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            messages=[{</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;role&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">: </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;user&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;content&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">: prompt}]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        )</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    response_text = response[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'message'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">][</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'content'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].strip()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"># Print the natural language insight</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    print(&quot;Natural Language Insight:&quot;, response_text)</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">calculate_insights</span><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px;font-weight:bold\\\">：</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">moving averages and trends</span></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">def calculate_insights(window, dow_window):</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">len</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window) &gt;= </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">-minute rolling average of the </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> prices</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        rolling_avg = window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">rolling</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">).</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">mean</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">().iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate price change and volume change</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        price_change = window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] - window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">len</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window) &gt;= </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> else </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        volume_change = window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Volume'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] - window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Volume'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">len</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window) &gt;= </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> else </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate DOW price change and volume change</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        dow_price_change = dow_window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] - dow_window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">len</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(dow_window) &gt;= </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> else </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        dow_volume_change = dow_window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Volume'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] - dow_window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Volume'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">len</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(dow_window) &gt;= </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> else </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate Exponential Moving Average (EMA) and Bollinger Bands (with a </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">-period window)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        ema = window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">ewm</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(span=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, adjust=False).</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">mean</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">().iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        std = window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">rolling</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">).</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">std</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">().iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        bollinger_upper = rolling_avg + (</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> * std)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        bollinger_lower = rolling_avg - (</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> * std)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate Relative Strength Index (RSI) if there are enough periods (</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">14</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> is typical)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        delta = window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">diff</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        gain = delta.</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">where</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(delta &gt; </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        loss = -delta.</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">where</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(delta &lt; </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        avg_gain = gain.</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">rolling</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">14</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, min_periods=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">).</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">mean</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">().iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        avg_loss = loss.</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">rolling</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">14</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">, min_periods=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">).</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">mean</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">().iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        rs = avg_gain / avg_loss if avg_loss != </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> else </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">float</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'nan'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        rsi = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">100</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> - (</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">100</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> / (</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> + rs))</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate Dow Jones index rolling average</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        dow_rolling_avg = dow_window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">rolling</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">).</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">mean</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">().iloc[-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        market_open_duration = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">get_market_open_duration</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(window)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Print the calculated insights</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;5-minute Rolling Average: {rolling_avg:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;EMA: {ema:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;RSI: {rsi:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Bollinger Upper Band: {bollinger_upper:.2f}, Lower Band: {bollinger_lower:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Price Change: {price_change:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Volume Change: {volume_change}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;DOW Price Change: {dow_price_change:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;DOW Volume Change: {dow_volume_change}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Dow Jones 5-minute Rolling Average: {dow_rolling_avg:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Daily High: {daily_high:.2f}, Daily Low: {daily_low:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Buying Momentum: {buying_momentum:.2f}, Selling Momentum: {selling_momentum:.2f}&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(f</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Market has been open for {market_open_duration:.2f} minutes&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">int</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(market_open_duration) % </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> == </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:  # Trigger LLM every </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> minutes</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">get_natural_language_insights</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">                rolling_avg, ema, rsi, bollinger_upper, bollinger_lower,</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">                price_change, volume_change, dow_rolling_avg, market_open_duration, dow_price_change, dow_volume_change, daily_high, daily_low, buying_momentum, selling_momentum</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            )</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;color:rgba(0,0,0,0.9);font-size:17px;font-family:&quot;mp-quote&quot;,-apple-system-font,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;PingFang SC&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;line-height:1.6;letter-spacing:0.034em;font-style:normal;font-weight:normal\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px;font-weight:bold\\\">process_stock_update</span><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">：process a new stock update every minute</span></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">def process_stock_update():</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">global</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> rolling_window, data, dow_rolling_window, dow_data</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">global</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> daily_high, daily_low, buying_momentum, selling_momentum</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    if </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">not</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> data.empty </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">and</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">not</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> dow_data.empty:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Simulate receiving a </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">new</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> data point </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">for</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> AAPL </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">and</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> Dow Jones</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">update</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> data.iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].to_frame().T</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        time_str </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> update.index[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">time</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        print(time_str)  # Output: [</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'09:30:00'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        dow_update </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> dow_data.iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].to_frame().T</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        data </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> data.iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:]  # Safely remove the </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">first</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">row</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">without</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> causing index issues</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        dow_data </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> dow_data.iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Append the </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">new</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> data points </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">to</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> the rolling windows</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        rolling_window </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> pd.concat([rolling_window, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">update</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">], ignore_index</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">False</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        dow_rolling_window </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> pd.concat([dow_rolling_window, dow_update], ignore_index</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">False</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">Update</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> daily high </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">and</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> low</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        daily_high </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">max</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(daily_high, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">update</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">values</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">])</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        daily_low </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">min</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(daily_low, </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">update</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">values</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">])</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate momentum based </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">on</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> price changes</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        if len(rolling_window) </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&gt;=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            price_change </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">update</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">values</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">] </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">-</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> rolling_window[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'Close'</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">].iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">-2</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            if price_change </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&gt;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">0</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">                buying_momentum </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">+=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> price_change</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">else</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">                selling_momentum </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">+=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">abs</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(price_change)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">                </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Limit the rolling </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">window</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">to</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> minutes </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">for</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> moving average</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        if len(rolling_window) </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&gt;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            rolling_window </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> rolling_window.iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        if len(dow_rolling_window) </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&gt;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">5</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">            dow_rolling_window </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">=</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\"> dow_rolling_window.iloc[</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">1</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">:]</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        # Calculate insights (moving averages, Bollinger Bands, RSI, etc.)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">        calculate_insights(rolling_window, dow_rolling_window)</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><code style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;color:rgba(0,0,0,0.9);font-size:17px;font-family:&quot;mp-quote&quot;,-apple-system-font,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;PingFang SC&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;line-height:1.6;letter-spacing:0.034em;font-style:normal;font-weight:normal\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">Schedule job to simulate receiving updates every minute：</span></span></code></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">schedule.</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">every</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">10</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">).seconds.</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">do</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">(process_stock_update)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"># Run the scheduled jobs</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">print(&quot;Starting real-time simulation for AAPL stock updates...&quot;)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">while True:</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    schedule.run_pending()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">    time.sleep(1)</span></span></div></div></pre></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">运行日志：</span></span></div><div style=\\\"-webkit-tap-highlight-color:transparent;text-align:center;\\\"><img src=\\\":/cacd177eddae4b2fa8e272f38dc5e042\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;-webkit-tap-highlight-color:transparent\\\"/></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">通过Llama 3给出的数据分析：</span></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">Natural Language Insight: Apple's price is consolidating within the Bollinger Bands, with a slight dip to 226.39. The EMA and rolling average are slightly higher, indicating a short-term uptrend. </span></span></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">The RSI of 37.54 suggests the stock may be oversold, potentially leading to a bounce. The buying momentum is higher than selling momentum, implying investors are still cautiously optimistic. With the Dow Jones index also experiencing a slight decline, it's possible Apple's strength could lead it outperforming the broader market in the short term.</span></span></div><p style=\\\"-webkit-tap-highlight-color:transparent;margin:0;text-align:justify;line-height:1.6;margin-top:15.05pt;margin-bottom:-7.35pt;margin-left:0;margin-right:0\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:15pt;font-family:微软雅黑;font-weight:normal;font-style:normal;color:#242424;background:#FFF;letter-spacing:-0.05pt;mso-font-width:100%;vertical-align:baseline\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:17px;font-weight:normal\\\">使用</span></span></span><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:15pt;font-family:微软雅黑;font-weight:bold;font-style:normal;color:#242424;background:#FFF;letter-spacing:-0.05pt;mso-font-width:100%;vertical-align:baseline\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:17px;font-weight:normal\\\">Streamlit设计一个界面：</span></span></span></p><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><pre style=\\\"-webkit-tap-highlight-color:transparent\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"># Streamlit UI</span></span><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">st.title(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;AI Stock Advisor&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">logtxtbox = st.empty()</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">logtxt = </span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">'09:30:00'</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">logtxtbox.caption(logtxt)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">message = st.chat_message(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;assistant&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)</span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\">message.write(</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">&quot;Starting real-time simulation for AAPL stock updates. First update will be processed in 5 minutes...&quot;</span><span style=\\\"-webkit-tap-highlight-color:transparent\\\">)    </span></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></div><div><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></div></div></pre></div><p style=\\\"-webkit-tap-highlight-color:transparent;margin:0;text-align:justify;line-height:1.6;margin-top:15.05pt;margin-bottom:-7.35pt;margin-left:0;margin-right:0\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:15pt;font-family:微软雅黑;font-weight:bold;font-style:normal;color:#242424;background:#FFF;letter-spacing:-0.05pt;mso-font-width:100%;vertical-align:baseline\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></span></p><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><span style=\\\"-webkit-tap-highlight-color:transparent;font-size:14px\\\">需要完整代码私我即可。</span></span></div><div style=\\\"-webkit-tap-highlight-color:transparent;\\\"><span style=\\\"-webkit-tap-highlight-color:transparent\\\"><br style=\\\"-webkit-tap-highlight-color:transparent\\\"/></span></div></div></div></div></div></div></span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":83693}]"
metadata_diff: {"new":{"id":"9776c42cb4954b25b788ccec0de88350","parent_id":"f67288c3a0be4374b5d532b5dcc3aabc","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764348835527,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":0},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T21:04:08.222Z
created_time: 2025-11-28T21:04:08.222Z
type_: 13