| | |
| | | global_util.max60_volumn[code] = (max60, max60_day) |
| | | global_util.yesterday_volumn[code] = yesterday |
| | | try: |
| | | RedisUtils.setex(redis, "volumn_max60-{}".format(code), tool.get_expire(), json.dumps((max60, max60_day)), auto_free=False) |
| | | RedisUtils.setex(redis, "volumn_max60-{}".format(code), tool.get_expire(), json.dumps((max60, max60_day)), |
| | | auto_free=False) |
| | | RedisUtils.setex(redis, "volumn_yes-{}".format(code), tool.get_expire(), yesterday, auto_free=False) |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | |
| | | RedisUtils.setex( __redis_manager.getRedis(), "volumn_today-{}".format(code), tool.get_expire(), volumn) |
| | | |
| | | |
| | | # datas:[(code, volumn)] |
| | | def set_today_volumns(datas): |
| | | pipe = __redis_manager.getRedis().pipeline() |
| | | for d in datas: |
| | | code, volumn = d |
| | | logger_day_volumn.info("code:{} volumn:{}".format(code, volumn)) |
| | | global_util.today_volumn[code] = volumn |
| | | # 有1000手的变化才保存 |
| | | if code in __today_volumn_cache and volumn - __today_volumn_cache[code] < 100000: |
| | | continue |
| | | __today_volumn_cache[code] = volumn |
| | | RedisUtils.setex(pipe, "volumn_today-{}".format(code), tool.get_expire(), volumn) |
| | | pipe.execute() |
| | | |
| | | |
| | | # 获取今日量 |
| | | def get_today_volumn(code): |
| | | _volumn = global_util.today_volumn.get(code) |
| | |
| | | redis管理器 |
| | | """ |
| | | import time |
| | | from threading import Thread |
| | | |
| | | import redis |
| | | |
| | | import constant |
| | | from log_module.log import logger_redis_debug |
| | | from utils import tool |
| | | |
| | | config = constant.REDIS_CONFIG |
| | | |
| | |
| | | |
| | | @classmethod |
| | | def setex(cls, redis_, key, expire, val, auto_free=True): |
| | | time.sleep(1) |
| | | __start_time = time.time() |
| | | try: |
| | | return redis_.setex(key, expire, val) |
| | |
| | | if auto_free: |
| | | # redis_.connection_pool.disconnect() |
| | | pass |
| | | |
| | | @classmethod |
| | | def setex_async(cls, redis_, key, expire, val, auto_free=True): |
| | | Thread(target=lambda: cls.setex(redis_, key, expire, val, auto_free)).start() |
| | | |
| | | @classmethod |
| | | def setnx(cls, redis_, key, val, auto_free=True): |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | redisManager = RedisManager(0) |
| | | for i in range(0, 50): |
| | | print(i) |
| | | redis = redisManager.getRedis() |
| | | redis |
| | | time1 = time.time() |
| | | RedisUtils.setex_async(RedisManager(0).getRedis(), "test123123", tool.get_expire(), "123213") |
| | | print(time.time() - time1) |
| | | input() |
| | |
| | | yesterday_codes = kpl_data_manager.get_yesterday_limit_up_codes() |
| | | # 订阅的代码 |
| | | flist = [] |
| | | temp_volumns = [] |
| | | for d in datas: |
| | | code = d[0] |
| | | # 格式 (代码,现价,涨幅,量,更新时间) |
| | |
| | | ZYLTGBUtil.save(code, zylt // 10000, 1) |
| | | global_util.zyltgb_map[code] = int(zylt) |
| | | # 保存今日实时量 |
| | | code_volumn_manager.set_today_volumn(code, d[3]) |
| | | temp_volumns.append((code, d[3])) |
| | | |
| | | |
| | | zyltgb = 0 |
| | | if code in global_util.zyltgb_map: |
| | |
| | | fitem = {"code": code, "price": d[1], "volume": d[3] // (10000 * 100), "volumeUnit": 1, "time": "00:00:00", |
| | | "zyltgb": zyltgb // 10000, "zyltgbUnit": 1} |
| | | flist.append(fitem) |
| | | code_volumn_manager.set_today_volumns(temp_volumns) |
| | | print("首板代码数量", len(flist)) |
| | | try: |
| | | tick_datas = first_target_code_data_processor.process_first_codes_datas(flist) |
| | |
| | | can_buy_blocks = [] |
| | | for block in keys: |
| | | is_top_8_record, top_8_record = kpl_block_util.is_record_top_block(code, block, limit_up_record_datas, |
| | | yesterday_current_limit_up_codes, 20) |
| | | yesterday_current_limit_up_codes, 50) |
| | | is_top_4_current, top_4_current = kpl_block_util.is_current_top_block(code, block, current_limit_up_datas, |
| | | yesterday_current_limit_up_codes, 10) |
| | | yesterday_current_limit_up_codes, 50) |
| | | is_top_4 = is_top_8_record and is_top_4_current |
| | | msg_list.append(f"\n实时top10(涨停数量:{len(current_limit_up_datas)})") |
| | | msg_list.append(f"历史top20(涨停数量:{top_8_record})") |