def monitor(self): while market_status(): ret = self.get() if not ret: time.sleep(5) continue for body_dict in ret.get('rows', []): item = body_dict.get('cell', {}) bond_nm = item.get('bond_nm', '').strip() bond_id = item.get('bond_id', '').strip() full_price = item.get('full_price') premium_rt = self.__convert__(item.get('premium_rt')) sincrease_rt = item.get('sincrease_rt') sincrease_rt = self.__convert__(sincrease_rt) increase_rt = item.get('increase_rt') curr_iss_amt = self.__convert__( item.get('curr_iss_amt')) # 剩余规模 if abs(sincrease_rt ) >= config.MONITOR_PERCENT and self.history.is_expire( bond_id): ''' 发送消息 t = threading.Thread(target=show_box, args=(bond_nm,)) t.start() ''' str_content = '负' + increase_rt if float( increase_rt.replace('%', '')) < 0 else increase_rt str_content = str_content.replace('%', '') text = f'{bond_nm[:2]}-债{str_content}-股{sincrease_rt}-规模{curr_iss_amt}-溢{premium_rt}' t = threading.Thread(target=self.send_msg, args=(text, )) t.start() self.logger.info(f'{bond_nm} 涨停') self.history.add(bond_id) time.sleep(config.ACCESS_INTERVAL)
def monitor(self): while market_status(): ret = self.get() if not ret: time.sleep(5) continue for body_dict in ret.get('rows', []): item = body_dict.get('cell', {}) bond_nm = item.get('bond_nm', '').strip() bond_id = item.get('bond_id', '').strip() full_price = item.get('full_price') remium_rt = item.get('premium_rt') sincrease_rt = item.get('sincrease_rt') sincrease_rt = self.__convert__(sincrease_rt) increase_rt = item.get('increase_rt') if abs(sincrease_rt ) >= config.MONITOR_PERCENT and self.history.is_expire( bond_id): ''' 发送消息 t = threading.Thread(target=show_box, args=(bond_nm,)) t.start() ''' text = f'{bond_id}{bond_nm} 异动,转债涨幅:{increase_rt}' t = threading.Thread(target=self.send_msg, args=(text, )) t.start() self.logger.info(f'{bond_nm} 涨停') self.history.add(bond_id) time.sleep(config.ACCESS_INTERVAL)