def check_choice_news(): db = connect_mongodb("SPIDER_MONGODB", "FinanceInfo") current_time = datetime.datetime.utcnow() start_time = current_time - datetime.timedelta(days=1) # print(start_ts) count = db.get_collection("choice_news").find({"date": {"$gt": start_time}}).count() d_check_result = {"create_time": datetime.datetime.now(), "24h_updated_amount": count} write_log_into_mongodb("choice_news_monitor", d_check_result)
def check_cailian_news(): db = connect_mongodb("SPIDER_MONGODB", "FinanceInfo") current_ts = int(time.time()) start_ts = current_ts - 24 * 60 * 60 # print(start_ts) count = db.get_collection("cailian_info").find({ "sort_score": { "$gt": start_ts } }).count() d_check_result = { "create_time": datetime.datetime.now(), "24h_updated_amount": count } write_log_into_mongodb("cailian_info_monitor", d_check_result)
def check_message_info(): db = connect_mongodb("QE_PRODUCT_MONGODB", "QuantEye") current_ts = int(time.time()) start_ts = current_ts - 1 * 60 * 60 # print(start_ts) count = db.get_collection("message_info").find({ "sort_score": { "$gt": start_ts } }).count() d_check_result = { "create_time": datetime.datetime.now(), "1h_updated_amount": count } write_log_into_mongodb("message_info_monitor", d_check_result)
def check_cn_info(source): db = connect_mongodb("SPIDER_MONGODB", "FinanceInfo") current_time = datetime.datetime.utcnow() start_time = current_time - datetime.timedelta(days=1) # print(start_ts) count = db.get_collection(source).find({ "time": { "$gt": start_time } }).count() d_check_result = { "create_time": datetime.datetime.now(), "24h_updated_amount": count } log_collection = source + "_monitor" write_log_into_mongodb(log_collection, d_check_result)
def check_sina_finance_info(): db = connect_mongodb("SPIDER_MONGODB", "FinanceInfo") current_ts = int(time.time()) start_ts = current_ts - 24 * 60 * 60 # print(start_ts) amount = 1000 sort_type = ("_id", DESCENDING) recent_news_time = [ int(new.get("created_at")) for new in db.get_collection( "sina_finance_info").find({}).sort([sort_type]).limit(amount) ] count = len([i for i in recent_news_time if i > start_ts]) d_check_result = { "create_time": datetime.datetime.now(), "24h_updated_amount": count } write_log_into_mongodb("sina_finance_info_monitor", d_check_result)
def intellectual_stock_chosen(): db = connect_mongodb("QE_PRODUCT_MONGODB", "QuantEye") current_time = datetime.datetime.now() current_time_with_12_o_clock = datetime.datetime(current_time.year, current_time.month, current_time.day, 0, 0, 0) start_time = current_time_with_12_o_clock - datetime.timedelta(days=1, hours=8) total_amount = db.get_collection("picking_strategies").find({}).count() refreshed_count = 0 for item in db.get_collection("picking_strategies").find({}): if item.get("state").get( "last_date_with_picked_targets") >= start_time: refreshed_count += 1 d_check_result = { "create_time": datetime.datetime.now(), "24h_updated_amount": refreshed_count, "total": total_amount } write_log_into_mongodb("intellectual_stock_chosen_monitor", d_check_result)