大盘股中的价值溢价
登录后收藏Onsite backtest IDE
Quant Buffet 原生回测 IDEEdit and run Quant Buffet Python for 大盘股中的价值溢价 in the browser. Results update live with equity, drawdown, and metrics charts. Allowed: backtest.data, backtest.engine, backtest.metrics, numpy, pandas. Define ASSETS and make_on_day(prices). Shortcut: Ctrl+Enter. API docs →
Quant Buffet syntax cheat sheet (copy / insert)
Paste these fragments into the editor. The sandbox rejects QuantConnect, os, and network libraries.
from __future__ import annotations
import numpy as np
import pandas as pd
from backtest.data import load_daily_prices
from backtest.engine import EngineConfig, PortfolioEngine
from backtest.metrics import compute_metricsASSETS = ["SPY", "QQQ", "TLT", "GLD", "BIL"]def make_on_day(prices: pd.DataFrame):
cols = [c for c in ASSETS if c in prices.columns]
sma = prices[cols].rolling(200, min_periods=200).mean()
state = {"last": None}
def on_day(engine: PortfolioEngine, dt: pd.Timestamp) -> None:
if sma.loc[dt].isna().all():
return
key = (dt.year, dt.month)
if state["last"] == key:
return
state["last"] = key
long = [
s for s in cols
if pd.notna(prices.at[dt, s]) and pd.notna(sma.at[dt, s])
and prices.at[dt, s] > sma.at[dt, s]
]
weights = {} if not long else {s: 1.0 / len(long) for s in long}
engine.set_target_weights(dt, weights)
ready = sma.dropna(how="all").index.min() if sma.notna().any().any() else None
return on_day, readyengine.set_target_weights(dt, {"SPY": 0.60, "BIL": 0.40})Live backtest performance
Export to your platform
Transform Quant Buffet lab code (ASSETS + make_on_day / PortfolioEngine) into native classes for a third-party IDE — then copy and paste.
# Generated from Quant Buffet → QuantConnect LEAN
# Strategy: 大盘股中的价值溢价
# Detected pattern: Absolute momentum
# Source uses Quant Buffet lab APIs (ASSETS + make_on_day / PortfolioEngine).
# Review fees, data, and risk before live trading — educational export only.
from AlgorithmImports import *
class QuantBuffetExport(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010, 1, 1)
self.SetCash(100000)
tickers = ["SPY", "TLT", "GLD", "BIL"]
self.symbols = []
for t in tickers:
if "-" in t: # crypto proxy e.g. BTC-USD
self.symbols.append(self.AddCrypto(t.replace("-USD", ""), Resolution.Daily).Symbol)
else:
self.symbols.append(self.AddEquity(t, Resolution.Daily).Symbol)
self.Schedule.On(
self.DateRules.MonthStart(self.symbols[0]),
self.TimeRules.AfterMarketOpen(self.symbols[0], 30),
self.Rebalance,
)
# Logic: Long assets with positive 252-day return; equal-weight; monthly.
def Rebalance(self):
# Pattern: abs_momentum — Long assets with positive 252-day return; equal-weight; monthly.
# Default: equal-weight. Port your make_on_day weights here via SetHoldings.
w = 1.0 / len(self.symbols) if self.symbols else 0.0
for symbol in self.symbols:
self.SetHoldings(symbol, w)
导出代码使用目标平台的原生类与库。请在第三方 IDE 中安装依赖后运行;实盘前请自行验证。
学术论文
Adding Value to Value: Is There a Value Premium Among Large Stocks?
Is There a Value Premium Among Large Stocks? [点击查看论文]
- University of Miami
- ?University of Miami - Department of Finance
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2096310


策略概要
该策略投资于发达市场股票(北美、欧盟、亚太地区),每月根据市值和收益率将其分为六个投资组合。收益率的计算方法是将每股收益(使用I/B/E/S的预测数据,分别针对年份t、t+1、t+2)除以股价。排除了负面收益预测和收益率超过100%的股票。每年根据纽约证券交易所的中位数断点,将股票按市值分为“大”股和“小”股。在每个市值范围内,股票进一步按“低”(底部30%)、“中”(中间40%)和“高”(顶部30%)的收益率分组。投资者在高收益的大市值股票上做多,在低收益的大市值股票上做空,且每月重新平衡投资组合,使用市值加权。
II. 策略合理性
价值异常现象有很好的文献记录。最常见的解释是,投资者对成长股的增长潜力反应过度,因此,价值股被低估。对于大市值股票,更准确地计算市盈率有助于增强这一效应。市场价格往往与基于分析师预测的未来收益计算出的收益率比与基于历史收益计算的收益率更为一致。每月对股票进行排序也有助于使用更准确的信息。