def next(self): if len(self.data.Volume) > LOOK_BACK: prices = self.data.Close hasBuySignal = jModel.hasCustomBuySignal( self.data.Open, self.data.Close, self.data.High, self.data.Low, self.data.Body, self.data.Height, self.data.UpShadow, self.data.LowerShadow) hasSellSignal = jModel.hasCustomSellSignal( self.data.Open, self.data.Close, self.data.High, self.data.Low, self.data.Body, self.data.Height, self.data.UpShadow, self.data.LowerShadow) # if np.datetime64(self.data.Date[-1]) == np.datetime64('2018-01-29T00:00:00.000000000'): # t4 = jModel.isBearishEngulfing(self.data.Open, self.data.Close, self.data.High, self.data.Low, self.data.Body, self.data.Height, self.data.UpShadow, self.data.LowerShadow) # print('today - isBearishEngulfing - ' + str(t4)) # exit() if hasBuySignal is not False and self.orderPending is False: self.buy() self.orderIndex = self.orderIndex + 1 print( str(self.orderIndex) + ". Buy at " + str(self.data.Date[-1]) + " by signal: " + str(hasBuySignal)) self.orderPending = True if hasSellSignal is not False and self.orderPending is True: self.position.close() print("----------- Sell at " + str(self.data.Date[-1]) + " by signal: " + str(hasSellSignal)) self.orderPending = False
def next(self): if len(self.data.Volume) > LOOK_BACK: prices = self.data.Close # if np.datetime64(self.data.Date[-1]) == np.datetime64('2020-04-03T00:00:00.000000000'): # print('yesterday - isShavenBottom - ' + str(jModel.isShavenBottom(self.data.Height[-2], self.data.LowerShadow[-2]))) # print('today - isShavenHead - ' + str(jModel.isShavenHead(self.data.Height[-1], self.data.UpShadow[-1]))) # print('today - isWhiteCandlestick - ' + str(jModel.isWhiteCandlestick(self.data.Open[-1], self.data.Close[-1]))) # exit() hasBuySignal = jModel.hasCustomBuySignal(self.data.Open, self.data.Close, self.data.High, self.data.Low, self.data.Body, self.data.Height, self.data.UpShadow, self.data.LowerShadow, 3) if hasBuySignal is not False: self.buy(sl=0.9 * prices[-1], tp=1.2 * prices[-1])
DATA_PATH = os.path.abspath('../../vn-stock-data/VNX/') vn30_ticker = _af.getListVN30() # vnx_file = os.path.abspath('../../vn-stock-data/VNX.csv') # hose_ticker = _af.getHOSETickers(vnx_file) # for ticker_id in all_ticker: vnx_file = os.path.abspath('../../vn-stock-data/Tickers.csv') all_ticker = pd.read_csv(vnx_file, usecols=["ticker"]) for index, ticker_id in all_ticker.ticker.iteritems(): if ticker_id == 'ticker' or ticker_id == '': continue ticker_data = _af.get_pricing_by_path(DATA_PATH + '/' + ticker_id + '.csv', '2021-07-01') if ticker_data.Volume[-1] < 500000: continue _1hit_data = ticker_data.tail(10) new_data = jModel.convertToJapanCandle(_1hit_data) # hasBuySignal = jModel.hasBuySignal(new_data.Open, new_data.Close, new_data.High, new_data.Low, # new_data.Body, new_data.Height, new_data.UpShadow, # new_data.LowerShadow, new_data.Date) hasBuySignal = jModel.hasCustomBuySignal(new_data.Open, new_data.Close, new_data.High, new_data.Low, new_data.Body, new_data.Height, new_data.UpShadow, new_data.LowerShadow, 1) if hasBuySignal is not False: print(ticker_id)