免责声明:本文所有内容仅用于交流学习,不构成任何投资建议!投资有风险,入市需谨慎!
策略介绍
R-Breaker是一种经典的日内量化交易策略,以结合趋势跟踪与反转交易为特点,自1994年由Richard Saidenberg公布后,曾连续十多年被美国《Futures Truth》杂志评为前十大最赚钱的策略之一。
📊 核心原理:六个关键价位
策略的核心是基于前一交易日的最高价、最低价和收盘价,计算出六个关键价位,作为当日交易的决策依据。这些价位从高到低通常包括:
一套常见的经典计算公式如下:
中心价 = (昨日最高价 + 昨日收盘价 + 昨日最低价) / 3
突破买入价 = 昨日最高价 + 2 × (中心价 - 昨日最低价)
突破卖出价 = 昨日最低价 - 2 × (昨日最高价 - 中心价)
🔄 独特的交易逻辑
R-Breaker的交易逻辑根据持仓状态分为两部分:
⚙️ 应用与注意事项
R-Breaker主要应用于期货市场的日内短线交易,通常在收盘前平仓,不持有隔夜头寸。其在波动性较大的市场中表现往往更好。
需要注意的是,作为一个经典策略,它也存在一些局限性:
对市场波动依赖大:在趋势不明显、整日震荡的行情中,策略可能频繁交易导致亏损。
存在过时风险:随着市场成熟,其简单逻辑的盈利空间可能被压缩。
参数敏感:策略的表现对计算公式中的参数较为敏感,过度优化存在过拟合风险。
因此,在实际使用中,交易者通常会对其进行改进,例如加入止损机制、设置波动率过滤器以规避震荡市,或与其他策略结合使用。
如果你想深入了解,我可以为你进一步解释R-Breaker策略中六个价位的具体计算方法,或者提供其交易逻辑的流程图。
'''backteststart: 2019-01-01 00:00:00end: 2021-01-01 00:00:00period: 1hbasePeriod: 1hexchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]'''def onTick(): exchange.SetContractType('rb000') bars_arr =exchange.GetRecords(PERIOD_D1) if len(bars_arr) 2: return yesterday_open = bars_arr[-2]['Open'] yesterday_high = bars_arr[-2]['High'] yesterday_low = bars_arr[-2]['Low'] yesterday_close = bars_arr[-2]['Close'] pivot = (yesterday_high+yesterday_close+yesterday_low) / 3*num r1 = 2 * pivot - yesterday_low r2 = pivot + (yesterday_high - yesterday_low) r3 = yesterday_high + 2 * (pivot - yesterday_low) s1 = 2 * pivot - yesterday_high s2 = pivot - (yesterday_high - yesterday_low) s3 = yesterday_low - 2 * (yesterday_high - pivot) today_high = bars_arr[-1]['High'
] today_low = bars_arr[-1]['Low'] current_price = _C(exchange.GetTicker).Last position_arr = _C(exchange.GetPosition) if len(position_arr) > 0: for i in position_arr: if i['ContractType'][:2] == 'rb': if i['Type'] % 2 == 0: position = i['Amount'] else: position = -i['Amount'] profit = i['Profit'] else: position = 0 profit = 0 if position == 0: if current_price > r3: exchange.SetDirection("buy") exchange.Buy(current_price + 1, 1) if current_price < s3: exchange.SetDirection("sell") exchange.Sell(current_price - 1, 1) if position > 0: if today_high > r2 and current_price < r1 or current_price < s3: exchange.SetDirection("closebuy") exchange.Sell(current_price - 1, 1) exchange.SetDirection("sell") exchange.Sell(current_price - 1, 1) if position 0: if today_low < s2 and current_price > s1 or current_price > r3: exchange.SetDirection("closesell") exchange.Buy(current_price + 1, 1) exchange.SetDirection("buy") exchange.Buy(current_price + 1, 1)
def main(): while True: onTick() Sleep(1000)
策略参数

我们致力于人工智能、量化交易领域前沿研究,分享前沿论文、模型代码、策略实现。如有相关需求,请私信与我们联系。
请加微信“LingDuTech163”,或公众号后台私信“联系方式”。
关注【灵度智能】公众号,获取更多AI资讯。