Пример #1
0
import os
import sys
METHOD_MODULE_PATH = os.path.abspath('../..')
sys.path.insert(1, METHOD_MODULE_PATH)
import method.algofuncs as _af
import method.JavCan as jModel

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 hose_ticker:
    ticker_data = _af.get_pricing_by_path(DATA_PATH + '/' + ticker_id + '.csv',
                                          '2021-07-01')
    _1hit_data = ticker_data.tail(3)
    new_data = jModel.convertToJapanCandle(_1hit_data)
    prices = new_data.Close
    opens = new_data.Open
    bodies = new_data.Body
    ups = new_data.UpShadow
    lows = new_data.LowerShadow
    height = new_data.Height

    isUmbrellaCandlestick = jModel.isUmbrellaCandlestick(
        bodies[-2], height[-2], ups[-2], lows[-2])
    isWhiteCandlestick = jModel.isWhiteCandlestick(opens[-1], prices[-1])
    if isUmbrellaCandlestick is True and isWhiteCandlestick is True and prices[
            -1] > prices[-2]:
        print(ticker_id)
Пример #2
0
                self.data.LowerShadow)

            # if np.datetime64(self.data.Date[-1]) == np.datetime64('2018-07-12T00:00:00.000000000'):
            #     t4 = jModel.isMorningStarsPattern(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 - isMorningStarsPattern - ' + str(t4))
            #     print(jModel.isBlackCandlestick(self.data.Open[-3], self.data.Close[-3]))
            #     print(jModel.isBodyOver45(self.data.Body[-3], self.data.Height[-3]))
            #     print(jModel.isBodyLess35(self.data.Body[-2], self.data.Height[-2]))
            #     print(jModel.isWhiteCandlestick(self.data.Open[-1], self.data.Close[-1]))
            #     exit()

            if hasBuySignal is not False and self.orderPending is False:
                self.buy()
                self.orderPending = True

            if hasSellSignal is not False and self.orderPending is True:
                self.position.close()
                self.orderPending = False


DATA_PATH = os.path.abspath('../../vn-stock-data/VNX/')
ticker_id = 'VRE'
ticker_data = _af.get_pricing_by_path(DATA_PATH + '/' + ticker_id + '.csv',
                                      '2018-01-01')
new_data = jModel.convertToJapanCandle(ticker_data)
bt = Backtest(ticker_data, Harami, commission=.005, exclusive_orders=False)
stats = bt.run()
print(stats)
# print(stats['_trades'])
bt.plot()
Пример #3
0
    if len(ticker) != 3:
        continue
    _volume = ticker_data['nmTotalTradedQty']
    _minVol = getMinVolumeByTime()
    if type(_volume) is not int or _volume < _minVol:
        continue
    open = ticker_data['openPrice']
    close = ticker_data['matchedPrice']
    highest = ticker_data['highest']
    lowest = ticker_data['lowest']
    total_height = highest - lowest
    body = abs(close - open)
    head = _upf(close, open, highest)
    tail = _botf(close, open, lowest)

    condition1 = True if tail > 0.65 * total_height else False
    condition2 = True if total_height > 0.05 * close else False
    # today has a long tail
    if condition1 is True:
        # print(ticker)
        if condition2 is True:
            # print(ticker)
            history_ticker_data = stockHistory.getStockHistoryData(
                ticker)  # not include today data
            # # print(history_ticker_data)
            htd = jModel.convertToJapanCandle(history_ticker_data)
            _close = htd.Close.to_numpy()
            isDownTrend = jModel.isDownTrendV2ByRSI(_close)
            if isDownTrend is True:
                # print(ticker)
                sendTelegramMessage(ticker)