Ejemplo n.º 1
0
def getHqDailyMetas(hqConf, day, ticker, nDays=50):
    csvFolder = CsvFolder.format(hqConf['repo'], day)
    csvFile = CsvFileName.format(csvFolder, ticker)
    hqMeta = HqMeta(ticker, csvFile)
    hqMetas = []
    for dayIdx in range(nDays):
        hqMetas.append(hqMeta.collect(dayIdx))
    return hqMetas
Ejemplo n.º 2
0
def run(hqConf, hqDate):
    result = ""
    csvFolder = CsvFolder.format(hqConf['repo'], hqDate)
    for group in ['etf', 'idx', 'tickers', 'covid19']:
        for ticker in hqConf[group]:
            result += csvHqDay0(ticker, csvFolder)
            # break
    hqDay0FileName = HqDay0FileNameFormatter.format(hqConf['repo'], hqDate)
    hqutil.writeTextFile(hqDay0FileName, HqDay0Header + result)
Ejemplo n.º 3
0
def hqPatternHistory():
    _hqConf = templateMeta['hqConf']
    csvFolder = CsvFolder.format(_hqConf['repo'], templateMeta['day'])
    ticker = request.args.get('ticker')
    return render_template('hqPatternHistory.html',
                           title='{} Pattern History'.format(ticker),
                           templateMeta=templateMeta,
                           ticker=ticker,
                           hqPatterns=hqTickerScan(ticker, csvFolder, 0, 50),
                           len=len,
                           round=round)
Ejemplo n.º 4
0
def hqScan():
    _hqConf = templateMeta['hqConf']
    csvFolder = CsvFolder.format(_hqConf['repo'], templateMeta['day'])
    tickers = _hqConf['tickers'] + _hqConf['etf']
    return render_template('hqScan.html',
                           title='HQ Scan',
                           templateMeta=templateMeta,
                           hqPatterns=hqStartScan(tickers,
                                                  csvFolder,
                                                  startDayIdx=0),
                           len=len,
                           round=round)
Ejemplo n.º 5
0
def getHqMetas(hqConf, day, tickerList, startDayIdx=0):
    tickers = hqConf[tickerList]
    csvFolder = CsvFolder.format(hqConf['repo'], day)
    hqMetas = []
    for ticker in tickers:
        hqFile = CsvFileName.format(csvFolder, ticker)
        if os.path.exists(hqFile):
            hqMeta = HqMeta(ticker, hqFile)
            hqMetas.append(hqMeta.collect(startDayIdx))
    # hqMetas = sorted(hqMetas, key=lambda x: x['LP'])
    hqMetas = sorted(hqMetas,
                     key=lambda x: (x['change'] - x['LP']),
                     reverse=True)
    return hqMetas
Ejemplo n.º 6
0
def getHqCsv(hqConf, ticker, day):
    csvFolder = CsvFolder.format(hqConf['repo'], day)
    csvFile = CsvFileName.format(csvFolder, ticker)
    return HqCsv(ticker, csvFile)
Ejemplo n.º 7
0
    @property
    def df(self):
        return self.dataFrame

    @property
    def rows(self):
        return self.dataFrame.iloc


if __name__ == "__main__":
    import json
    from datetime import datetime, timedelta
    from hqrobot import CsvFolder, CsvFileName
    ticker = 'ATHX'
    day = (datetime.now() + timedelta(days=-2)).strftime("%Y%m%d")
    hqConf = json.load(open('hqrobot.json'))
    csvFolder = CsvFolder.format(hqConf['repo'], day)
    csvFile = CsvFileName.format(csvFolder, ticker)
    hqCsv = HqCsv(ticker, csvFile)

    idx0 = hqCsv.df.index[0]
    print(idx0)
    df4 = hqCsv.df[0:4].Close.sort_values(ascending=False)
    # df4 = hqCsv.df[0:4].sort_values(by='Close', ascending=True)
    df4['No'] = range(len(df4.index))
    print(df4)
    print(df4.loc[idx0])
    # for row in hqCsv.rows:
    #     print(row.index)
    #     break