| | |
| | | |
| | | import trade_gui |
| | | from l2_code_operate import L2CodeOperate |
| | | from l2_data_manager import L2LimitUpMoneyStatisticUtil, L2DataUtil |
| | | import l2_data_manager_new |
| | | from log import logger_juejin_tick, logger_system |
| | | from trade_data_manager import CodeActualPriceProcessor |
| | | from trade_queue_manager import JueJinBuy1VolumnManager |
| | |
| | | |
| | | |
| | | def init_data(): |
| | | # 删除之前的分钟级大单撤单数据 |
| | | l2_data_manager_new.SecondAverageBigNumComputer.clear_data() |
| | | l2_data_manager_new.AverageBigNumComputer.clear_data() |
| | | # 删除所有的涨停卖数据 |
| | | l2_data_manager_new.L2LimitUpSellStatisticUtil.clear() |
| | | # 重置所有的大单数据 |
| | | big_money_num_manager.reset_all() |
| | | # 清除水下捞数据 |
| | | __actualPriceProcessor.clear_under_water_data() |
| | | # 载入行业股票代码 |
| | | global_data_loader.load_industry() |
| | | # 载入代码自由流通市值 |
| | |
| | | |
| | | # 每日初始化 |
| | | def everyday_init(): |
| | | # 交易時間不能做初始化 |
| | | if not tool.is_init_time(): |
| | | raise Exception("交易时间不能初始化") |
| | | |
| | | codes = gpcode_manager.get_gp_list() |
| | | logger_system.info("每日初始化") |
| | | |
| | |
| | | # 初始化同花顺主站 |
| | | l2_clients = client_manager.getValidL2Clients() |
| | | for client in l2_clients: |
| | | server.repair_ths_main_site(client) |
| | | try: |
| | | server.repair_ths_main_site(client) |
| | | except Exception as e: |
| | | pass |
| | | |
| | | |
| | | def __run_schedule(): |
| | |
| | | data_ = (symbol, time_, tick["quotes"][0]["bid_v"], tick["quotes"][0]["bid_p"]) |
| | | logger_juejin_tick.info("买1量 {},{},{},{}", data_[1], data_[0], data_[2], |
| | | data_[3]) |
| | | need_sync = __jueJinBuy1VolumnManager.save(data_[0], data_[1], data_[2], data_[3]) |
| | | if need_sync: |
| | | # 同步数据 |
| | | L2LimitUpMoneyStatisticUtil.verify_num(data_[0], data_[2], data_[1]) |
| | | # 暂时不采用 |
| | | # need_sync = __jueJinBuy1VolumnManager.save(data_[0], data_[1], data_[2], data_[3]) |
| | | # if need_sync: |
| | | # # 同步数据 |
| | | # L2LimitUpMoneyStatisticUtil.verify_num(data_[0], data_[2], data_[1]) |
| | | |
| | | # print(tick["created_at"],tick["quotes"][0]["bid_v"]) |
| | | |
| | |
| | | rate = round((price - pricePre) * 100 / pricePre, 1) |
| | | if rate >= 7: |
| | | logger_juejin_tick.info("{}-{}-{}", code, price, rate) |
| | | if not gpcode_manager.is_listen(code) and not gpcode_manager.is_operate( |
| | | if not gpcode_manager.is_listen_old(code) and not gpcode_manager.is_operate( |
| | | code) and not gpcode_manager.is_listen_full(): |
| | | L2CodeOperate.get_instance().add_operate(1, code, "现价变化,rate-{} from-{}".format(rate, price_from)) |
| | | # 进入监控 |
| | | elif rate < 5: |
| | | # 移除监控 |
| | | if gpcode_manager.is_listen(code) and not gpcode_manager.is_operate(code): |
| | | if gpcode_manager.is_listen_old(code) and not gpcode_manager.is_operate(code): |
| | | L2CodeOperate.get_instance().add_operate(0, code, "现价变化,rate-{} from-{}".format(rate, price_from)) |
| | | |
| | | |
| | | # 获取到现价 |
| | | def accpt_prices(prices): |
| | | print("价格代码数量:", len(prices)) |
| | | __actualPriceProcessor.save_current_price_codes_count(len(prices)) |
| | | # 采集的代码数量不对 |
| | | if len(gpcode_manager.get_gp_list()) - len(prices) > 2: |
| | | return |
| | | now_str = datetime.datetime.now().strftime("%H:%M:%S") |
| | | now_strs = now_str.split(":") |
| | | now_second = int(now_strs[0]) * 60 * 60 + int(now_strs[1]) * 60 + int(now_strs[2]) |
| | |
| | | logging.exception(e) |
| | | |
| | | try: |
| | | __actualPriceProcessor.save_current_price(code, price, gpcode_manager.get_limit_up_price_by_preprice(pricePre) == tool.to_price(decimal.Decimal(d["price"]))) |
| | | __actualPriceProcessor.save_current_price(code, price, |
| | | gpcode_manager.get_limit_up_price_by_preprice( |
| | | pricePre) == tool.to_price( |
| | | decimal.Decimal(d["price"]))) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | |
| | |
| | | # 后面的代码数量 |
| | | # 先删除应该删除的代码 |
| | | for code in del_list: |
| | | if gpcode_manager.is_listen(code): |
| | | if gpcode_manager.is_listen_old(code): |
| | | # 判断是否在监听里面 |
| | | L2CodeOperate.get_instance().add_operate(0, code, "现价变化") |
| | | # 增加应该增加的代码 |
| | | for code in add_code_list: |
| | | if not gpcode_manager.is_listen(code): |
| | | if not gpcode_manager.is_listen_old(code): |
| | | if not l2_trade_util.is_in_forbidden_trade_codes(code): |
| | | L2CodeOperate.get_instance().add_operate(1, code, "现价变化") |
| | | else: |