| | |
| | | import inited_data |
| | | from l2 import l2_data_manager_new, l2_data_manager, l2_data_log, l2_log, code_price_manager |
| | | import l2_data_util |
| | | from l2.cancel_buy_strategy import HourCancelBigNumComputer, L2LimitUpMoneyStatisticUtil, LCancelBigNumComputer |
| | | from l2.cancel_buy_strategy import HourCancelBigNumComputer, LCancelBigNumComputer |
| | | import l2.l2_data_util |
| | | |
| | | from output import code_info_output |
| | |
| | | apply_time = item["apply_time"] |
| | | if apply_time and len(apply_time) >= 8: |
| | | code = item["code"] |
| | | trade_state = trade_manager.get_trade_state(code) |
| | | trade_state = trade_manager.CodesTradeStateManager().get_trade_state(code) |
| | | # 设置下单状态的代码为已委托 |
| | | if trade_state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER: |
| | | origin_apply_time = apply_time |
| | |
| | | client = datas["client"] |
| | | money = datas["money"] |
| | | # TODO存入缓存文件 |
| | | trade_manager.set_available_money(client, money) |
| | | trade_manager.AccountAvailableMoneyManager().set_available_money(client, money) |
| | | # l2交易队列 |
| | | elif type == 10: |
| | | # 可用金额 |
| | |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | |
| | | if limit_up_price is not None: |
| | | code_price_manager.Buy1PriceManager.process(code, buy_one_price, buy_time, limit_up_price, |
| | | sell_one_price, sell_one_volumn) |
| | | code_price_manager.Buy1PriceManager().process(code, buy_one_price, buy_time, limit_up_price, |
| | | sell_one_price, sell_one_volumn) |
| | | _start_time = time.time() |
| | | msg += "买1价格处理:" + f"{_start_time - __start_time} " |
| | | |
| | |
| | | decimal.Decimal("0.00")) |
| | | # 获取执行位时间 |
| | | |
| | | buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data( |
| | | buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager().get_buy_compute_start_data( |
| | | code) |
| | | if True: |
| | | # 只有下单过后才获取交易进度 |
| | |
| | | buy_queue_result_list, |
| | | exec_time) |
| | | if buy_progress_index is not None: |
| | | HourCancelBigNumComputer.set_trade_progress(code, buy_time, buy_exec_index, |
| | | buy_progress_index, |
| | | l2.l2_data_util.local_today_datas.get( |
| | | code), |
| | | l2.l2_data_util.local_today_num_operate_map.get( |
| | | code)) |
| | | LCancelBigNumComputer.set_trade_progress(code, buy_progress_index, |
| | | l2.l2_data_util.local_today_datas.get( |
| | | code)) |
| | | HourCancelBigNumComputer().set_trade_progress(code, buy_time, |
| | | buy_exec_index, |
| | | buy_progress_index, |
| | | l2.l2_data_util.local_today_datas.get( |
| | | code), |
| | | l2.l2_data_util.local_today_num_operate_map.get( |
| | | code)) |
| | | LCancelBigNumComputer().set_trade_progress(code, buy_progress_index, |
| | | l2.l2_data_util.local_today_datas.get( |
| | | code)) |
| | | |
| | | logger_l2_trade_buy_queue.info("获取成交位置成功: code-{} index-{} 数据-{}", code, |
| | | buy_progress_index, |
| | |
| | | price) |
| | | # if need_cancel: |
| | | # l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, cancel_msg, "trade_queue") |
| | | if need_sync: |
| | | # 同步数据 |
| | | L2LimitUpMoneyStatisticUtil.verify_num(code, volumn, time_) |
| | | # if need_sync: |
| | | # # 同步数据 |
| | | # L2LimitUpMoneyStatisticUtil.verify_num(code, volumn, time_) |
| | | elif type == 30: |
| | | # 心跳信息 |
| | | data = data_process.parse(_str)["data"] |
| | |
| | | data = json.loads(_str) |
| | | code = data["data"]["code"] |
| | | if code: |
| | | state = trade_manager.get_trade_state(code) |
| | | state = trade_manager.CodesTradeStateManager().get_trade_state(code) |
| | | if state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER or state == trade_manager.TRADE_STATE_BUY_DELEGATED or state == trade_manager.TRADE_STATE_BUY_CANCEL_ING: |
| | | try: |
| | | l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "手动撤销") |
| | |
| | | data = json.loads(_str) |
| | | codes = data["data"]["codes"] |
| | | code = codes[0] |
| | | state = trade_manager.get_trade_state(code) |
| | | state = trade_manager.CodesTradeStateManager().get_trade_state(code) |
| | | if state != trade_manager.TRADE_STATE_BUY_CANCEL_SUCCESS and state != trade_manager.TRADE_STATE_BUY_SUCCESS: |
| | | return_str = json.dumps({"code": 0, "msg": "可以取消"}) |
| | | else: |