原创内容第992篇,专注AGI+,AI量化投资、个人成长与财富自由。from engine import Task, Engine
def ranking_ETFs(): t = Task() t.name = '基于ETF历史评分的轮动策略' t.period = 'RunDaily' t.weight = 'WeighEqually' t.order_by_signal = 'trend_score(close,25)' t.start_date = '20180101'
t.symbols = [ '518880.SH', '513100.SH', '159915.SZ', '510180.SH', ] t.benchmark = '510300.SH' return t
res = Engine().run(ranking_ETFs())import matplotlib.pyplot as pltprint(res.stats)from matplotlib import rcParams
rcParams['font.family'] = 'SimHei'res.prices.plot()print(res.get_transactions())df = (res.prices.pct_change()+1).cumprod()print(df.iloc[-1])plt.show()
from engine import Task, Engine
def strategy(): t = Task() t.name = '标普500ETF的RSRS择时' # 排序 t.period = 'RunDaily' t.weight = 'WeighEqually' t.select_buy = ['RSRS(high,low,18)>1.0'] t.select_sell = ['RSRS(high,low,18)<0.8'] t.start_date = '20100101' t.end_date = '20171231'
t.symbols = [ '510300.SH', # 标普500
]
t.benchmark = '510300.SH' return t
res = Engine().run(strategy())import matplotlib.pyplot as pltprint(res.stats)from matplotlib import rcParams
rcParams['font.family'] = 'SimHei'#res.plot_weights()res.prices.plot()print(res.get_transactions())df = (res.prices.pct_change()+1).cumprod()print(df.iloc[-1])plt.show()
代码和数据下载:AI量化实验室——2025量化投资的星辰大海AI量化实验室 星球,已经运行三年多,1800+会员。
aitrader代码,因子表达式引擎、遗传算法(Deap)因子挖掘引擎等,支持vnpy,qlib,backtrader和bt引擎,内置多个年化30%+的策略,每周五迭代一次,代码和数据在星球全部开源。
点击 “查看原文”,直接访问策略集合。