| | |
| | | import base64 |
| | | import concurrent.futures |
| | | import copy |
| | | import json |
| | |
| | | logger_real_place_order_position, logger_device |
| | | from output import l2_output_util |
| | | from third_data import kpl_util, history_k_data_manager, huaxin_l1_data_manager, third_blocks_manager, kpl_data_manager |
| | | from third_data.code_plate_key_manager import CodePlateKeyBuyManager, KPLCodeJXBlockManager, RealTimeKplMarketData, \ |
| | | from third_data.code_plate_key_manager import KPLCodeJXBlockManager, \ |
| | | RadicalBuyBlockManager |
| | | from third_data.history_k_data_manager import HistoryKDataManager |
| | | from third_data.history_k_data_util import JueJinApi, HistoryKDatasUtils |
| | |
| | | from third_data.third_blocks_manager import CodeThirdBlocksManager, SOURCE_TYPE_KPL, BlockMapManager |
| | | from trade import trade_manager, l2_trade_util, trade_data_manager, trade_constant |
| | | import l2_data_util as l2_data_util_old |
| | | from trade.buy_money_count_setting import BuyMoneyAndCountSetting |
| | | from trade.buy_money_count_setting import BuyMoneyAndCountSetting, RadicalBuyBlockCodeCountManager |
| | | |
| | | from trade.huaxin import huaxin_trade_api, huaxin_trade_data_update, \ |
| | | huaxin_trade_record_manager, huaxin_trade_order_processor, huaxin_sell_util |
| | |
| | | elif code_list_type == outside_api_command_manager.CODE_LIST_GREEN: |
| | | if operate == outside_api_command_manager.OPERRATE_SET: |
| | | gpcode_manager.GreenListCodeManager().add_code(code) |
| | | gpcode_manager.WantBuyCodesManager().add_code(code) |
| | | name = gpcode_manager.get_code_name(code) |
| | | if not name: |
| | | results = HistoryKDatasUtils.get_gp_codes_names([code]) |
| | |
| | | gpcode_manager.CodesNameManager.add_first_code_name(code, results[code]) |
| | | elif operate == outside_api_command_manager.OPERRATE_DELETE: |
| | | gpcode_manager.GreenListCodeManager().remove_code(code) |
| | | gpcode_manager.WantBuyCodesManager().remove_code(code) |
| | | elif operate == outside_api_command_manager.OPERRATE_GET: |
| | | codes = gpcode_manager.GreenListCodeManager().list_codes_cache() |
| | | datas = [] |
| | |
| | | desc_list.append("【红名单】") |
| | | if green: |
| | | desc_list.append("【绿名单】") |
| | | |
| | | |
| | | result = {"code": 0, "data": {"code_info": (code, code_name), "desc": "".join(desc_list)}} |
| | | self.send_response(result, client_id, request_id) |
| | |
| | | order_begin_pos = OrderBeginPosInfo(buy_single_index=0, buy_exec_index=0) |
| | | l2_data_util.load_l2_data(code) |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | if not total_datas: |
| | | continue |
| | | trade_index, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code) |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | |
| | | real_place_order_after_num += val["num"] |
| | | |
| | | # 获取当日的量比 |
| | | volume_rate = code_volumn_manager.get_volume_rate(code) |
| | | volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate(code) |
| | | |
| | | # 是否需要注意 |
| | | need_pay_attention = (total_left_count <= 10 or total_left_num * float( |
| | |
| | | except: |
| | | pass |
| | | |
| | | try: |
| | | if order_begin_pos: |
| | | fdata['mode'] = order_begin_pos.mode |
| | | else: |
| | | fdata['mode'] = -1 |
| | | except: |
| | | pass |
| | | |
| | | fdatas.append(fdata) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | |
| | | elif ctype == "set_per_code_buy_money": |
| | | # 设置单只票的买入金额 |
| | | money = data["money"] |
| | | if money > 30000: |
| | | raise Exception("最多只能设置3w") |
| | | if money > 50000: |
| | | raise Exception("最多只能设置5w") |
| | | constant.BUY_MONEY_PER_CODE = money |
| | | self.send_response({"code": 0, "data": {"money": constant.BUY_MONEY_PER_CODE}}, client_id, request_id) |
| | | elif ctype == "get_per_code_buy_money": |
| | |
| | | kpl_data_manager.PullTask.repaire_pull_task() |
| | | # 修复数据服务 |
| | | server_util.repaire_data_server() |
| | | # 任务修复 |
| | | huaxin_trade_data_update.repaire_task() |
| | | self.send_response({"code": 0, "data": {}}, client_id, request_id) |
| | | elif ctype == "get_trade_queue": |
| | | code = data["code"] |
| | |
| | | # 设置买入金额和数量 |
| | | normal = data["normal"] |
| | | radical = data["radical"] |
| | | default_buy_money = data["default_buy_money"] |
| | | if int(default_buy_money) not in constant.AVAILABLE_BUY_MONEYS: |
| | | raise Exception("默认金额不在预设金额内") |
| | | constant.BUY_MONEY_PER_CODE = default_buy_money |
| | | BuyMoneyAndCountSetting().set_normal_buy_data(normal[0], json.loads(normal[1])) |
| | | BuyMoneyAndCountSetting().set_radical_buy_data(radical[0], json.loads(radical[1])) |
| | | data = { |
| | |
| | | data = { |
| | | "normal": BuyMoneyAndCountSetting().get_normal_buy_setting(), |
| | | "radical": BuyMoneyAndCountSetting().get_radical_buy_setting(), |
| | | "moneys":constant.AVAILABLE_BUY_MONEYS |
| | | "moneys": constant.AVAILABLE_BUY_MONEYS, |
| | | "default_buy_money": constant.BUY_MONEY_PER_CODE |
| | | } |
| | | self.send_response({"code": 0, "data": data, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "set_radical_buy_block_count_setting": |
| | | # 设置买入金额和数量 |
| | | data_str = data["data"] |
| | | data_str = base64.b64decode(data_str).decode('utf-8') |
| | | setting = json.loads(data_str) |
| | | RadicalBuyBlockCodeCountManager().set_block_code_count(setting) |
| | | self.send_response({"code": 0, "data": setting, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "get_radical_buy_block_count_setting": |
| | | # 设置买入金额和数量 |
| | | data = RadicalBuyBlockCodeCountManager().get_block_code_count_settings() |
| | | self.send_response({"code": 0, "data": data, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "get_place_order_settings": |
| | | # 获取买入下单设置 |
| | | data = { |
| | | "radical_buy": {"price": (constant.MIN_CODE_RADICAL_BUY_PRICE, constant.MAX_CODE_RADICAL_BUY_PRICE), |
| | | "zyltgb": constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES}} |
| | | self.send_response({"code": 0, "data": data, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "set_place_order_settings": |
| | | radical_buy = data.get("radical_buy") |
| | | if radical_buy: |
| | | radical_buy = json.loads(radical_buy) |
| | | constant.MIN_CODE_RADICAL_BUY_PRICE = radical_buy["price"][0] |
| | | constant.MAX_CODE_RADICAL_BUY_PRICE = radical_buy["price"][1] |
| | | constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES = radical_buy["zyltgb"] |
| | | self.send_response({"code": 0, "data": {}, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "get_buy_open_limit_up_codes": |
| | | # 获取隔夜单排1的代码 |
| | | codes = gpcode_manager.BuyOpenLimitUpCodeManager().get_codes() |
| | | if not codes: |
| | | codes = set() |
| | | self.send_response({"code": 0, "data": list(codes), "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | |
| | | elif ctype == "set_buy_open_limit_up_codes": |
| | | # 设置隔夜单排1的代码 |
| | | codes = data.get("codes") |
| | | codes = json.loads(codes) |
| | | gpcode_manager.BuyOpenLimitUpCodeManager().set_codes(set(codes)) |
| | | self.send_response({"code": 0, "data": list(codes), "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | logger_debug.exception(e) |