股票中的定期经济公告效应
登录后收藏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 中安装依赖后运行;实盘前请自行验证。
学术论文
How Much Do Investors Care About Macroeconomic Risk? Evidence from Scheduled Economic Announcements
投资者对宏观经济风险有多关注?来自预定经济公告的证据 [点击查看论文]
- DePaul University
- ?DePaul University - Kellstadt Graduate School of Business
- ?affiliation not provided to SSRN
- University of Oxford
- ?University of Oxford - Said Business School
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1312091


策略概要
该策略利用差价合约(CFDs)、交易所交易基金(ETFs)或期货,在关键经济数据发布日(如消费者价格指数(CPI)、生产者价格指数(PPI)、就业数据或联邦公开市场委员会(FOMC)决议)时,在股票市场建立多头头寸。在非公告日,投资者持有现金。该方法旨在利用重大经济事件引发的潜在市场波动,提供对股票市场的定向敞口,同时在信息流较低的时期避免不必要的风险。
II. 策略合理性
学术研究表明,尽管投资者无法在公告日预测具体的新闻内容,但他们预期会有更多影响市场的信息发布。这种不确定性的增加提高了在此期间持有证券的风险。风险厌恶型投资者意识到这种风险的增加,因此要求更高的预期超额回报作为补偿。因此,公告日的股票回报率可预见地更高,因为市场通过定价这一额外的风险溢价来吸引愿意在风险升高期间持有资产的投资者。这一模式凸显了经济公告在影响市场行为和回报预期方面的重要性。