当前位置:首页>python>用 Python 和 Streamlit 求解马科维茨有效前沿

用 Python 和 Streamlit 求解马科维茨有效前沿

  • 2026-02-28 19:33:24
用 Python 和 Streamlit 求解马科维茨有效前沿

用 Python 和 Streamlit 求解

马科维茨有效前沿

在本篇文章,我们将探讨每位经济学专业学生在大学毕业前都应掌握的技能。

这篇文章将带你一步步使用 Python 和 Streamlit 求解马科维茨(Markowitz)的有效前沿(Efficient Frontier)。

第一部分,我们将探索如何通过模拟来优化投资组合配置;第二部分,我们将涵盖交易策略的回测,以评估马科维茨理论的实际适用性。我们的主要目标是判断是否因风险变化而需要对投资组合进行再平衡。

有效前沿

有效前沿(Efficient Frontier, EF)理论由诺贝尔奖得主哈里·马科维茨(Harry Markowitz)于1952年提出,是现代投资组合理论(Modern Portfolio Theory, MPT)的核心概念。复合年增长率(CAGR)代表收益,而年化标准差则表示风险。相关的基本概念在大学金融学专业本科核心课程金融学、投资学、投资组合管理中会学到。

有效前沿以图形方式展示那些在给定风险水平下能实现最大收益的投资组合。投资者的目标是构建高收益、低整体风险的投资组合。该理论依赖于资产之间的协方差。

均值-方差优化(Mean-Variance Optimization, MVO)

MVO 是一种优化技术,用于确定投资组合中各资产的权重,以在更低风险下实现更高收益。它依赖历史数据来估计预期收益和协方差矩阵。MVO 假设投资者仅基于预期收益和风险做出决策,忽略了税收、交易成本、流动性、技术分析和基本面分析等其他因素。因此,它也忽视了诸如内幕交易之类的非对称信息。

MVO 不区分正向风险与负向风险。由于投资者通常具有风险厌恶倾向,他们可能更关注避免负收益,而非捕捉潜在的正收益。这也是我们应用这个理论需要特别注意的一点。正如牛市冲顶、熊市下探,投资者更倾向于担忧市场回调,而非享受收益上涨。

夏普比率(Sharpe Ratio)

为了获得最优配置的投资组合,我们必须定义三个基本变量:

Rp  = 投资组合的预期收益Rf  = 无风险收益率StdDev(Rp) = 投资组合收益的标准差

预期投资组合收益通常通过历史经验数据计算得出,一般采用每日对数收益率的平均值。为将其年化,通常按 252 个交易日进行换算。

由于预期收益和标准差均由历史市场数据决定,因此假设它们在未来保持不变是一个重大前提。这正是现代投资组合理论(MPT)的一个关键弱点,因为大多数时间序列都被认为是非平稳的随机过程。

我们利用上述变量计算夏普比率,夏普比率为 1 表示风险与预期收益达到均衡:

投资组合通常以最大化夏普比率为优化目标。

配置 Streamlit

streamlit有session的概念,如何使用参见streamlit文档。举个简单例子:

import streamlit as stimport pandas as pdclass SessionState:    def __init__(self, **kwargs):        for key, val in kwargs.items():            setattr(self, key, val)@st.cache(allow_output_mutation=True)def get_session():    return SessionState(df=pd.DataFrame())session_state = get_session()# Creating a dictionary with some datadata = {    'Name': ['John', 'Anna', 'Peter', 'Linda'],    'Age': [28, 35, 40, 25]}# Creating a DataFrame with the datadf = pd.DataFrame(data)# Assigning this DataFrame to session_statesession_state.df = df

这段代码定义了 SessionState 类,使我们能够将 Python 对象存储在其中。通过调用 get_session 函数,我们可以检索会话状态中保存的任何 Python 对象。

在行动之前你需要安装这些包:

import streamlit as st  # library for building interactive web appsimport pandas as pdimport numpy as npfrom datetime import dateimport requestsfrom io import BytesIOimport yfinance as yfimport base64  # Encoding and decoding binary data to/from ASCIIimport plotly.express as pximport plotly.graph_objects as go 

如果你想从git ub加载一些代码过来,可以这样:

def load_data_from_github(url):    response = requests.get(url)    content = BytesIO(response.content)    data = pd.read_pickle(content)    return data

为方便起见,我们使用 yfinance 库从股票市场获取数据。

def download_data(data, period='1y'):    dfs = []    if isinstance(data, dict):        for name, ticker in data.items():            ticker_obj = yf.Ticker(ticker)            hist = ticker_obj.history(period=period) # timeframe            hist.columns = [f"{name}_{col}" for col in hist.columns]  # Add prefix to the name            hist.index = pd.to_datetime(hist.index.map(lambda x: x.strftime('%Y-%m-%d')))            dfs.append(hist)    elif isinstance(data, list):        for ticker in data:            ticker_obj = yf.Ticker(ticker)            hist = ticker_obj.history(period=period)            hist.columns = [f'{ticker}_{col}' for col in hist.columns]  # Add prefix to the name            hist.index = pd.to_datetime(hist.index.map(lambda x: x.strftime('%Y-%m-%d')))            dfs.append(hist)      combined_df = pd.concat(dfs, axis=1, join='outer')  # Use join='outer' to handle different data indices    return combined_df

用于选择资产的 Streamlit 代码假设你已经定义并存储了一个包含股票代码组合的DataFrame。

这些数据包括开盘价、收盘价、最高价、最低价以及调整后价格。我们使用“调整后收盘价”这一列。

我们构建了四个字典,分别包含 B3 BOVESPA、标普500(S&P500)、纳斯达克、大宗商品、加密货币以及美元(USD)货币对的股票代码。

允许用户选择数据的时间范围,重采样(resampling)、缺失值处理(missing values treatment)和滚动平均值(rolling average),这些功能没有写明具体代码,你keyi根据自己的需求实现。

# select box widget to choose timeframesselected_timeframes = st.selectbox('Select Timeframe:', ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max'], index=7)# creating a dictionary of dictionaries with all available tickersassets_list = {'CURRENCIES': currencies_dict, 'CRYPTO': crypto_dict, 'B3_STOCKS': b3_stocks, 'SP500': sp500_dict, 'NASDAQ100': nasdaq_dict, 'indexes': indexes_dict}# combining dictionaries when the user selects one or more in assets_listselected_dict_names = st.multiselect('Select dictionaries to combine', list(assets_list.keys()))combined_dict = {}for name in selected_dict_names:    dictionary = assets_list.get(name)    if dictionary:        combined_dict.update(dictionary)# dictionary to actually store retrieved dataselected_ticker_dict = {}# looping through the chosen tickersif selected_dict_names:    # the list to iterate over tickers    tickers = st.multiselect('Asset Selection', list(combined_dict.keys()))    if tickers and st.button("Download data"):        for key in tickers:            if key in combined_dict:                selected_ticker_dict[key] = combined_dict[key]        # Assigning data object as the result of the function download_data        session_state.data = download_data(selected_ticker_dict, selected_timeframes)# Handle tickers entered manuallytype_tickers = st.text_input('Enter Tickers (comma-separated):')if type_tickers and st.button("Download data"):    tickers = [ticker.strip() for ticker in type_tickers.split(',')]    # doing the same for tickers separated by commas    session_state.data = download_data(tickers, selected_timeframes)

如果这些代码成功运行,你将获得一个交互的界面(图传不上去),可以选择股票并下载他们的数据。

生成有效前沿

你也可以用 pyportfolioopt 来完成这项任务。参考Damian Boh, Easily Optimize a Stock Portfolio using PyPortfolioOpt in Python这篇文章。

from pypfopt.efficient_frontier import EfficientFrontierfrom pypfopt import risk_modelsfrom pypfopt import expected_returnsimport pandas as pd# Sample stock data (replace it with Close prices downloaded from yahoo finance)stock_data = {    "AAPL": [0.1, 0.05, 0.08, 0.12, 0.07],    "GOOG": [0.05, 0.06, 0.07, 0.08, 0.09],    "MSFT": [0.06, 0.04, 0.08, 0.07, 0.05]}stocks_df = pd.DataFrame(stock_data)# Calculate expected returns and sample covariance matrixmu = expected_returns.mean_historical_return(stocks_df)S = risk_models.sample_cov(stocks_df)# Create the Efficient Frontier objectef = EfficientFrontier(mu, S)# Optimize for maximum Sharpe ratioweights = ef.max_sharpe()# Clean the weights (optional)cleaned_weights = ef.clean_weights()# Print the cleaned weightsprint(cleaned_weights)# Plot the efficient frontieref.portfolio_performance(verbose=True)

也可以使用求解器(solver)实现最小化(minimize)。这节省大量时间:

  • • 估算资产的年化收益率;
  • • 计算投资组合的方差;
  • • 计算投资组合中每对资产之间的协方差;
  • • 计算夏普比率,并确定使该比率最大化的各资产最优权重。
  • • 至少需要满足以下约束条件:权重之和必须等于 1,且每个权重必须大于 0(不允许做空)。
import numpy as npimport cvxpy as cp# Risk-free raterisk_free_rate = 0.05# Number of assetsn_assets = len(expected_returns)# Define variablesweights = cp.Variable(n_assets)# Portfolio expected returnportfolio_return = expected_returns @ weights# Portfolio volatility (standard deviation)portfolio_volatility = cp.sqrt(cp.quad_form(weights, covariance_matrix))# Portfolio Sharpe Ratioportfolio_sharpe_ratio = (portfolio_return - risk_free_rate) / portfolio_volatility# Define objective function (maximize Sharpe Ratio)objective = cp.Maximize(portfolio_sharpe_ratio)# Define constraintsconstraints = [    cp.sum(weights) == 1,  # sum of weights equals 1 (fully invested)    weights >= 0  # weights are non-negative]# You can add more constraints here, such as minimum and maximum weights,# target return, etc.# Solve the optimization problemproblem = cp.Problem(objective, constraints)problem.solve()

我们将收益率定义为:明日调整后收盘价与今日调整后收盘价之比的对数。

def logreturns(df):    # Separating the close price in this case    df.columns = df.columns.str.split('_').str[0]    log_returns = np.log(df)    log_returns = df.iloc[:, 0:].pct_change()    fig = px.line(log_returns, x=log_returns.index, y=log_returns.columns[0:].split('_')[0],                  labels={'value': 'log'},                  title='Log Returns')    fig.update_layout(legend_title_text='Assets')    st.plotly_chart(fig)    return log_returns

对数变换使时间序列更平稳。我们可以通过应用增强型迪基-富勒检验(Augmented Dickey-Fuller test)来验证。

仅凭对数收益率本身,很难判断这些资产究竟呈现正收益还是负收益。我们可以从初始日期开始绘制累计收益:将第一个日期设为基准点,迭代计算。

def return_over_time(df):    return_df = pd.DataFrame()    df.columns = df.columns.str.split('_').str[0]    for col in df.columns:        return_df[col] = df[col] / df[col].iloc[0] -1    fig = px.line(return_df, x=return_df.index, y=return_df.columns[0:],                  labels={'value': 'Returns to Date'},                  title='returns')    fig.update_layout(legend_title_text='Assets')    st.plotly_chart(fig) # for streamlit plots

投资组合的收益

计算投资组合收益需要将权重与平均对数收益率相乘。尽管每次模拟中权重是随机生成的,但平均对数收益率要求我们假设数据的均值。

在此情况下,我们遵循以下步骤:

  • • 根据所选时间范围对数据框进行重采样
  • • 计算这些收益率的平均值
  • • 乘以交易天数(通常为252天),以获得年化收益率
resampler = 'A'  # for annualtrading_days = 252  # usual trading year# Step 1. Resample keeping only the last values of each yearannualized_returns = df.resample(resampler).last()# Step 2. Calculate the log returns and take the average# Step 3. Multiply it by trading daysannualized_returns = df.pct_change().apply(lambda x: np.log(1 + x)).mean() * trading_dayssimple_returns = np.exp(annualized_returns) - 1

你可以根据需要对重采样后的投资组合进行年化处理。例如,如果你希望进行季度分析,只需将重采样参数改为 '3M' 。由于均值-方差优化(Mean-Variance Optimization, MVO)假设收益服从正态分布,因此年化收益是标准做法。

一种更为保守的方法是:不对原始数据框进行重采样,直接计算每日对数收益率的平均值,然后乘以交易天数。一般来讲,夏普比率确实对你计算平均收益的方式非常敏感,这意味着“截至今日的收益在未来可被复制”这一隐含假设不成立。

投资组合收益可以通过将每项资产的收益与其权重相乘后求和得到:

计算资产组合收益方差:

trading_days = 252var = cov_matrix.mul(weights, axis=0).mul(weights, axis=1).sum().sum()sd = np.sqrt(var) # obtain the risk ann_sd = sd*np.sqrt(trading_days) # to scale the risk for any timeframe

模拟有效前沿:

def efficient_frontier(df,                        trading_days,                        risk_free_rate,                       simulations= 1000                       resampler='A'):    # covariance matrix of the log returns    cov_matrix = df.pct_change().apply(lambda x: np.log(1+x)).cov()    # lists to store the results    portfolio_returns = []     portfolio_variance = []     portfolio_weights = []     num_assets = len(df.columns)    for _ in range(simulations):        # generating up to 1000 portfolio simulations        weights = np.random.random(num_assets)        weights = weights/np.sum(weights) # scaling weights to 1        portfolio_weights.append(weights)        # calculating the log returns        returns = df.resample(resampler).last()        returns = df.pct_change().apply(lambda x: np.log(1 + x)).mean() * trading_days        annualized_returns = np.dot(weights, returns)        portfolio_returns.append(annualized_returns)        # portfolio variance        var = cov_matrix.mul(weights, axis=0).mul(weights, axis=1).sum().sum()        sd = np.sqrt(var) # Daily standard deviation        ann_sd = sd*np.sqrt(trading_days)        portfolio_variance.append(ann_sd)        # storing returns and volatitly in a dataframe        data = {'Returns':portfolio_returns, 'Volatility':portfolio_variance}    for counter, symbol in enumerate(df.columns.tolist()):        data[symbol+' weight'] = [w[counter] for w in portfolio_weights]    simulated_portfolios  = pd.DataFrame(data)    simulated_portfolios['Sharpe_ratio'] = (simulated_portfolios['Returns'] - risk_free_rate) / simulated_portfolios['Volatility']    return simulated_portfolios    

画出有效前沿:

def plot_efficient_frontier(simulated_portfolios, expected_sharpe, expected_return, risk_taken):    simulated_portfolios = simulated_portfolios.sort_values(by='Volatility')    # concatenating weights so we can hover on them as we select data points    simulated_portfolios['Weights'] = simulated_portfolios.iloc[:, 2:-1].apply(        lambda row: ', '.join([f'{asset}: {weight:.4f}' for asset, weight in zip(simulated_portfolios.columns[2:-1], row)]),        axis=1    )    # creating the plot as a scatter graph    frontier = px.scatter(simulated_portfolios, x='Volatility', y='Returns', width=800, height=600                          title="Markowitz's Efficient Frontier", labels={'Volatility': 'Volatility', 'Returns': 'Return'},                          hover_name='Weights')    # getting the index of max Sharpe Ratio and painting in green    max_sharpe_ratio_portfolio = simulated_portfolios.loc[simulated_portfolios['Sharpe_ratio'].idxmax()]    frontier.add_trace(go.Scatter(x=[max_sharpe_ratio_portfolio['Volatility']],                                   y=[max_sharpe_ratio_portfolio['Returns']],                                  mode='markers',                                  marker=dict(color='green', size=10),                                  name='Max Sharpe Ratio',                                  text=max_sharpe_ratio_portfolio['Weights']))    # Getting portfolios where returns are above our expectations and below     # the amount of risk we aim to take    low_risk_portfolios = simulated_portfolios[        (simulated_portfolios['Returns'] >= expected_return) &         (simulated_portfolios['Volatility'] <= risk_taken)    ]    frontier.add_trace(go.Scatter(x=low_risk_portfolios['Volatility'],                                   y=low_risk_portfolios['Returns'],                                  mode='markers',                                  marker=dict(color='purple', size=5),                                  name='Expected Return & Risk Taken',                                  text=low_risk_portfolios['Weights']))    # Selecting portfolios with our initial Sharpe ratio expectations    # and paiting it orange    expected_portfolio = simulated_portfolios[        (simulated_portfolios['Sharpe_ratio'] >= expected_sharpe - 0.001) &         (simulated_portfolios['Sharpe_ratio'] <= expected_sharpe + 0.001)    ]    if not expected_portfolio.empty:        frontier.add_trace(go.Scatter(x=[expected_portfolio['Volatility'].values[0]],                                       y=[expected_portfolio['Returns'].values[0]],                                      mode='markers',                                      marker=dict(color='orange', size=10),                                      name='Expected Sharpe Ratio',                                      text=expected_portfolio['Weights']))    # selecting the portfolio with lowest risk and painting it red    frontier.add_trace(go.Scatter(x=[simulated_portfolios.iloc[0]['Volatility']],                                   y=[simulated_portfolios.iloc[0]['Returns']],                                  mode='markers',                                  marker=dict(color='red', size=10),                                  name='Min Volatility'                                  text=simulated_portfolios.iloc[0]['Weights']))    frontier.update_layout(legend=dict(                           orientation='h',                           yanchor='top',                           y=1.1,                           xanchor='center',                           x=0.5))    st.plotly_chart(frontier)

大概长这样:

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-01 01:09:26 HTTP/2.0 GET : https://f.mffb.com.cn/a/477199.html
  2. 运行时间 : 0.238199s [ 吞吐率:4.20req/s ] 内存消耗:5,296.01kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=c0e5fcdd711322b3c375c6e7fba6428b
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000945s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001652s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000781s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000825s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001710s ]
  6. SELECT * FROM `set` [ RunTime:0.000753s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001546s ]
  8. SELECT * FROM `article` WHERE `id` = 477199 LIMIT 1 [ RunTime:0.001463s ]
  9. UPDATE `article` SET `lasttime` = 1772298566 WHERE `id` = 477199 [ RunTime:0.001622s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000655s ]
  11. SELECT * FROM `article` WHERE `id` < 477199 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002101s ]
  12. SELECT * FROM `article` WHERE `id` > 477199 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001163s ]
  13. SELECT * FROM `article` WHERE `id` < 477199 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002385s ]
  14. SELECT * FROM `article` WHERE `id` < 477199 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003281s ]
  15. SELECT * FROM `article` WHERE `id` < 477199 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002906s ]
0.243755s