コード例 #1
0
ファイル: Test-04.py プロジェクト: zuongthaotn/algo-stocks
    def next(self):
        if len(self.data.Volume) > LOOK_BACK:
            prices = self.data.Close
            hasBuySignal = jModel.hasBuySignal(
                self.data.Open, self.data.Close, self.data.High, self.data.Low,
                self.data.Body, self.data.Height, self.data.UpShadow,
                self.data.LowerShadow, self.data.Volume, self.data.Date)
            hasSellSignal = jModel.hasSellSignal(
                self.data.Open, self.data.Close, self.data.High, self.data.Low,
                self.data.Body, self.data.Height, self.data.UpShadow,
                self.data.LowerShadow, self.data.Volume, self.data.Date)
            # if np.datetime64(self.data.Date[-1]) == np.datetime64('2021-01-29T00:00:00.000000000'):
            #     t4 = jModel.isBullishEngulfing(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 - isBullishEngulfing - ' + str(t4))
            #     print('today - isDoji - ' + str(jModel.isDoji(self.data.Body[-2], self.data.Height[-2])))
            #     print('today - isWhiteCandlestick - ' + str(jModel.isWhiteCandlestick(self.data.Open[-1], self.data.Close[-1])))
            #     print('today - isDownTrendV1 - ' + str(jModel.isDownTrendV1(self.data.Open, self.data.Close, self.data.High, self.data.Low, self.data.Body, self.data.Height, self.data.UpShadow, self.data.LowerShadow)))
            #     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: " + 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: " + hasSellSignal)
                self.orderPending = False
コード例 #2
0
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:

DATA_PATH = os.path.abspath('../../vn-stock-data/VNX/')
hold_tickers = [
    'ABB', 'ACB', 'BSR', 'FPT', 'GMD', 'OCB', 'PVS', 'PVT', 'STB', 'TPB',
    'VCI', 'VHG', 'VND', 'VGT'
]
printedDate = False
for ticker_id in hold_tickers:
    ticker_data = _af.get_pricing_by_path(DATA_PATH + '/' + ticker_id + '.csv',
                                          '2021-07-01')
    if printedDate == False:
        print(ticker_data.Date[-1])
        printedDate = True
    _1hit_data = ticker_data.tail(10)
    new_data = jModel.convertToJapanCandle(_1hit_data)

    hasSellSignal = jModel.hasSellSignal(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)

    if hasSellSignal is not False:
        print(ticker_id + ' -- ' + str(hasSellSignal))