コード例 #1
0
ファイル: getCurrentPrice.py プロジェクト: nk5jp/stockchecker
def main():
    dt_now =  datetime.datetime.now()
    now = dt_now.strftime('%Y年%m月%d日 %H:%M:%S')
    print(f'{now}: getCurrentPrice start')
    stocks = dao.selectAllStock()
    watchByCode = dao.selectAllWatchByCode()
    for stock in stocks:
        try:
            code = stock[0]
            stockInfo = minkabuParser.getStockInfo(code)
            if code == stockInfo[0]:
                dao.insertDaily(code, stockInfo[2], stockInfo[3])
                if (code in watchByCode):
                    if (float(stockInfo[3]) < watchByCode[code][0]):
                        print (f'{code}: {stockInfo[3]} is lower than {watchByCode[code][0]}')
                        notification.sendMessage({'date': stockInfo[2], 'message': "{0}の価格が{1}でした.".format(code, stockInfo[3])})
                    if (float(stockInfo[3]) > watchByCode[code][1]):
                        print (f'{code}: {stockInfo[3]} is upper than {watchByCode[code][1]}')
                        notification.sendMessage({'date': stockInfo[2], 'message': "{0}の価格が{1}でした.".format(code, stockInfo[3])})
        except:
            print(f'{code}: some error has been occered and skipped.')
            continue
    dt_now =  datetime.datetime.now()
    now = dt_now.strftime('%Y年%m月%d日 %H:%M:%S')
    print(f'{now}: getCurrentPrice end')
コード例 #2
0
ファイル: stine.py プロジェクト: 6merkl/klausur-notifications
def handleChange(old, new, gradedict):
    difference_set = set(new) - set(old)
    verb = "ist"
    message = ""

    for x in difference_set:
        gradestring = f" ({gradedict[x]})" if SEND_GRADES else ""
        gradestring = f" ({bestandenstring(gradedict[x])})" if not SEND_GRADES and SEND_BESTANDEN else gradestring
        message += f"{x}{gradestring}, "
    message = message[:-2]

    if len(difference_set) > 1:
        verb = "sind"
        message = rreplace(message, ", ", " und ", 1)

    message += f" {verb} jetzt online!"
    notification.sendMessage(message)
コード例 #3
0
ファイル: kiwoom.py プロジェクト: haedong2/haedong_db
    def get_next_subject_data(self):
        try:
            start_date = self.start_date
            if len(self.subject_codes) > 0:
                subject_code = self.subject_codes.pop(0)
                # print(subject_code)
                # if subject_code =='FDAXM18':
                #     subject_code = self.subject_codes.pop(0)
                self.data = []
                self.last_working_day = self.db_manager.get_last_working_day(
                    subject_code)
                self.log.info("%s 종목 last_working_day : %s" %
                              (subject_code, self.last_working_day))

                if start_date > self.last_working_day:
                    self.log.info("입력일이 마지막 저장된 영업일 이후입니다. (%s)" %
                                  subject_code)
                    self.get_next_subject_data()
                else:
                    self.log.info("%s 종목 start_date : %s" %
                                  (subject_code, start_date))
                    if start_date == "":
                        self.tmp_start_date = get_next_date(
                            self.last_working_day)
                    self.log.info("%s 종목 tmp_start_date : %s" %
                                  (subject_code, self.tmp_start_date))
                    self.request_tick_info(subject_code, "1", "")
            elif len(self.subject_codes) <= 0:
                notification.sendMessage('DB검증을 시작합니다.', self.account)
                db_subect_code = self.db_manager.get_subject_code()
                #db에 있는 모든 2018년도 월물 찾아서 그중 금,유로,크루드,mini-S&P,엔화를 찾아서 DB검증실시
                for db_sub_code in db_subect_code:
                    self.last_working_day = self.db_manager.get_last_working_day(
                        db_sub_code[0])
                    # print(datetime.datetime.strptime(self.last_working_day,"%Y-%m-%d").date())
                    # print(datetime.date.today())
                    # print(datetime.datetime.strptime(self.last_working_day,"%Y-%m-%d").date()==datetime.date.today())
                    # 당일데이터 삭제
                    if (datetime.datetime.strptime(
                            self.last_working_day,
                            "%Y-%m-%d").date() == datetime.date.today()):
                        self.log.info("%s 종목의 데이터 중 당일 데이터 삭제" %
                                      db_sub_code[0])
                        self.log.info(
                            self.db_manager.del_err_data(
                                db_sub_code[0], datetime.date.today()))
                    if (self.db_manager.check_subject_code(
                            db_sub_code[0], self.last_working_day) == None):
                        pass
                    else:
                        if (db_sub_code[0].find('GC') == 0
                                or db_sub_code[0].find('6E') == 0
                                or db_sub_code[0].find('CL') == 0
                                or db_sub_code[0].find('ES') == 0
                                or db_sub_code[0].find('6J') == 0):
                            d = self.db_manager.check_first_input(
                                db_sub_code[0], self.last_working_day)
                            l = self.db_manager.check_last_input(
                                db_sub_code[0], self.last_working_day)
                            if (d == 'err' or l == 'err'):
                                notification.sendMessage(
                                    '틀렸다...%s' % db_sub_code[0], self.account)
                            elif ((l[0] - d[0]) > datetime.timedelta(
                                    hours=22, minutes=59, seconds=30)):
                                self.log.info(
                                    "%s종목 정상데이터 시작 %s - 끝 %s" %
                                    (db_sub_code[0], d[0].isoformat(),
                                     l[0].isoformat()))
                            else:
                                self.log.info("%s 종목의 입력갑의 spread가 틀렸다...%s" %
                                              (db_sub_code[0], (l[0] - d[0])))
                                notification.sendMessage(
                                    '%s 종목의 입력갑의 spread가 틀렸다...%s' %
                                    (db_sub_code[0], (l[0] - d[0])),
                                    self.account)
                        #항생은 시작시간과 마감시간이 다름
                        elif (db_sub_code[0].find('HSI') == 0):
                            d = self.db_manager.check_first_input(
                                db_sub_code[0], self.last_working_day)
                            l = self.db_manager.check_last_input(
                                db_sub_code[0], self.last_working_day)
                            if (d == 'err' or l == 'err'):
                                notification.sendMessage(
                                    '틀렸다...%s' % db_sub_code[0], self.account)
                            elif ((l[0] - d[0]) > datetime.timedelta(
                                    hours=23, minutes=14)):
                                self.log.info(
                                    "%s종목 정상데이터 시작 %s - 끝 %s" %
                                    (db_sub_code[0], d[0].isoformat(),
                                     l[0].isoformat()))
                            else:
                                self.log.info("%s 종목의 입력갑의 spread가 틀렸다...%s" %
                                              (db_sub_code[0], (l[0] - d[0])))
                                notification.sendMessage(
                                    '%s 종목의 입력갑의 spread가 틀렸다...%s' %
                                    (db_sub_code[0], (l[0] - d[0])),
                                    self.account)
                notification.sendMessage('DB정상입력확인완료', self.account)
        except Exception as err:
            self.log.error(get_error_msg(err))
コード例 #4
0
ファイル: main.py プロジェクト: gui2524/ProjetoFinalMicro
def notifySensor(comodo, imagePath):
    notification.sendMessage("Comodo: " + str(comodo) + " sob invasao")
    notification.sendPhoto(imagePath)
    log.eventLog("Notificacao enviada")