def test_hband2(self): target = 'upper_band' result = keltner_channel_hband(**self._params) pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)
def squeeze(history, sqz, symbol, t): bbh = ta.bollinger_hband(history[symbol]['close'].dropna(), n=20, ndev=2) bbl = ta.bollinger_lband(history[symbol]['close'].dropna(), n=20, ndev=2) bba = ta.bollinger_mavg(history[symbol]['close'].dropna(), n=20) kca = ta.keltner_channel_central(history[symbol]['high'], history[symbol]['low'], history[symbol]['close'], n=20) kcl = ta.keltner_channel_lband(history[symbol]['high'], history[symbol]['low'], history[symbol]['close'], n=20) kch = ta.keltner_channel_hband(history[symbol]['high'], history[symbol]['low'], history[symbol]['close'], n=20) mom = momentum.ao(history[symbol]['high'], history[symbol]['low']) #print(bbl[-1], kcl[-1], bbh[-1], kch[-1]) sqzon = (bbl[-1] > kcl[-1]) and (bbh[-1] < kch[-1]) sqzoff = bbl[-1] < kcl[-1] and bbh[-1] > kch[-1] nosqz = sqzon == False and sqzoff == False """ value = (Highest[lengthKC](high)+Lowest[lengthKC](low)+average[lengthKC](close))/3 val = linearregression[lengthKC](close-value) val = (max(history[symbol]['high'][-20:-1]) + min(history[symbol]['low'][-20:-1]) + history[symbol]['close'].mean())/3.0 v = lr(history[symbol]['close'] - val) """ flag = -1 #print("hi") if sqz[symbol][0] and sqzon: pass if sqz[symbol][0] and sqzoff: sqz[symbol][0] = False sqz[symbol][1] = True flag = 0 if sqz[symbol][1] and sqzoff: pass if sqz[symbol][1] and sqzon: sqz[symbol][1] = False sqz[symbol][0] = True flag = 1 if sqz[symbol][2] and sqzon: sqz[symbol][2] = False sqz[symbol][0] = True flag = 1 if sqz[symbol][2] and sqzoff: sqz[symbol][2] = False sqz[symbol][1] = True #print("sqeeze is OFF") #print(time.time()) flag = -1 if flag == -1: #print('No Change') pass if flag == 0: send_message(symbol, t + " pop : " + str(mom[-1])) if flag == 1: send_message(symbol, "Squeeze On " + t)