Boll布林带突破策略
生活随笔
收集整理的這篇文章主要介紹了
Boll布林带突破策略
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.策略原理
一個(gè)很簡(jiǎn)單的策略
突破上軌,且Rsi沒(méi)有超賣(mài)時(shí)做多,價(jià)格回歸中軌時(shí)平倉(cāng)
代碼:
seting = {'name': 'BB', 'symbol': 'ETHUSDT', 'kTime': '15m', 'bb_len': 129, 'bb_mult': 2.259, 'rsi_len': 22, 'rsi_long_min': 15, 'rsi_long_max': 76, 'rsi_short_min': 12, 'rsi_short_max': 74, 'buy': 1, 'buyZhiying': 13.037, 'buyZhisun': 8.014, 'sell': 1, 'sellZhiying': 5.084, 'sellZhisun': 13.086}""" 布林帶策略 """ def BB(r, df, seting):df['ma'] = SMA(r, seting['bb_len'], 'Close')df['mult'] = seting['bb_mult'] * talib.STDDEV(df['Close'].values, timeperiod=seting['bb_len'])df['upper'] = df['ma'] + df['mult']df['lower'] = df['ma'] - df['mult']df['rsi'] = talib.RSI(df['Close'].values, timeperiod=14)c = len(df)for i in range(c):if i > seting['bb_len'] and i+1 < c:if df['Close'][i] > df['upper'][i] and df['Close'][i-1] < df['upper'][i-1] and\df['rsi'][i] >= seting['rsi_long_min'] and df['rsi'][i] <= seting['rsi_long_max']:df['side'].values[i] = 'BUY'if df['Close'][i] < df['ma'][i] and df['Close'][i-1] > df['ma'][i-1]:df['close'].values[i] = 'BUY'if df['Close'][i] < df['lower'][i] and df['Close'][i-1] > df['lower'][i-1] and\df['rsi'][i] >= seting['rsi_short_min'] and df['rsi'][i] <= seting['rsi_short_max']:df['side'].values[i] = 'SELL'if df['Close'][i] > df['ma'][i] and df['Close'][i-1] < df['ma'][i-1]:df['close'].values[i] = 'SELL'return df2.回測(cè)結(jié)果
?
原文地址:Boll布林帶突破策略 - 蘇慕白的博客?
總結(jié)
以上是生活随笔為你收集整理的Boll布林带突破策略的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: R语言怎么写积分_手记(4):定积分
- 下一篇: 渲染流水线