| | |
| | | import threading |
| | | import time |
| | | |
| | | import alert_util |
| | | import client_manager |
| | | import code_nature_analyse |
| | | import code_volumn_manager |
| | | from utils import alert_util, data_process, global_util, ths_industry_util, tool, import_util |
| | | from code_attribute import code_volumn_manager, code_nature_analyse, global_data_loader, gpcode_manager, \ |
| | | gpcode_first_screen_manager |
| | | import constant |
| | | import data_process |
| | | import global_data_loader |
| | | import global_util |
| | | import gpcode_first_screen_manager |
| | | import gpcode_manager |
| | | import authority |
| | | import init |
| | | from user import authority |
| | | 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 |
| | | import l2.l2_data_util |
| | | |
| | | import ths_industry_util |
| | | import ths_util |
| | | import tool |
| | | from output import code_info_output |
| | | from third_data import hot_block_data_process, block_info, kpl_api |
| | | from third_data.code_plate_key_manager import CodesHisReasonAndBlocksManager |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | | from third_data.kpl_data_manager import KPLCodeLimitUpReasonManager, KPLLimitUpDataRecordManager |
| | | from ths import l2_listen_pos_health_manager, l2_code_operate |
| | | from trade import trade_gui, trade_data_manager, trade_manager, l2_trade_util, deal_big_money_manager, \ |
| | | from ths import l2_listen_pos_health_manager, l2_code_operate, client_manager |
| | | from trade import trade_data_manager, trade_manager, l2_trade_util, deal_big_money_manager, \ |
| | | current_price_process_manager, trade_juejin |
| | | from code_data_util import ZYLTGBUtil |
| | | from code_attribute.code_data_util import ZYLTGBUtil |
| | | import l2.transaction_progress |
| | | |
| | | from log import logger_l2_error, logger_device, logger_trade_delegate, logger_buy_1_volumn_record, \ |
| | | from logs.log import logger_l2_error, logger_device, logger_trade_delegate, logger_buy_1_volumn_record, \ |
| | | logger_l2_trade_queue, logger_l2_latest_data, logger_l2_trade_buy_queue, logger_first_code_record, logger_debug |
| | | from trade.huaxin import huaxin_trade_record_manager |
| | | from trade.trade_manager import TradeTargetCodeModeManager |
| | | from trade.trade_queue_manager import THSBuy1VolumnManager, thsl2tradequeuemanager |
| | | |
| | | ths_util = import_util.import_lib("ths.ths_util") |
| | | trade_gui = import_util.import_lib("trade.trade_gui") |
| | | |
| | | class MyTCPServer(socketserver.TCPServer): |
| | | def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True, pipe_juejin=None, pipe_ui=None): |
| | |
| | | # 获取涨停价 |
| | | _limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if not _limit_up_price: |
| | | init.re_set_price_pres([code], True) |
| | | inited_data.re_set_price_pres([code], True) |
| | | # 再次获取涨停价 |
| | | _limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if _limit_up_price: |
| | |
| | | for code in codes: |
| | | # 如果涨停价是空值就需要设置昨日收盘价格 |
| | | if gpcode_manager.get_limit_up_price(code) is None: |
| | | init.re_set_price_pres([code], True) |
| | | inited_data.re_set_price_pres([code], True) |
| | | |
| | | # 板块关键字准备 |
| | | for code in codes: |
| | |
| | | code) is None: |
| | | need_get_volumn = True |
| | | if need_get_volumn: |
| | | volumes_data = init.get_volumns_by_code(code, 150) |
| | | volumes = init.parse_max_volume(volumes_data[:90], code_nature_analyse.is_new_top( |
| | | gpcode_manager.get_limit_up_price(code), volumes_data[:90])) |
| | | volumes_data = inited_data.get_volumns_by_code(code, 150) |
| | | volumes = inited_data.parse_max_volume(volumes_data[:90], |
| | | code_nature_analyse.is_new_top( |
| | | gpcode_manager.get_limit_up_price(code), |
| | | volumes_data[:90])) |
| | | logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes) |
| | | code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) |
| | | # 判断K线形态 |
| | |
| | | # 获取涨停价 |
| | | if temp_codes: |
| | | # 获取涨停价 |
| | | init.re_set_price_pres(temp_codes) |
| | | inited_data.re_set_price_pres(temp_codes) |
| | | # 重新获取涨停价 |
| | | for code in temp_codes: |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | |
| | | gpcode_manager.FirstCodeManager.add_limited_up_record([code]) |
| | | pricePre = gpcode_manager.get_price_pre(code) |
| | | if pricePre is None: |
| | | init.re_set_price_pres([code]) |
| | | inited_data.re_set_price_pres([code]) |
| | | |
| | | rate = round((float(price) - pricePre) * 100 / pricePre, 1) |
| | | prices.append( |
| | |
| | | logging.exception(e) |
| | | trade_manager.save_trade_delegate_data(dataList) |
| | | # 刷新交易界面 |
| | | trade_gui.THSGuiTrade().refresh_data() |
| | | if trade_gui is not None: |
| | | trade_gui.THSGuiTrade().refresh_data() |
| | | finally: |
| | | pass |
| | | |
| | |
| | | thsDead = data.get("thsDead") |
| | | logger_device.info("({})客户端信息:{}".format(client_id, json.dumps(data))) |
| | | client_manager.saveClientActive(int(client_id), host, thsDead) |
| | | if ths_util.is_ths_dead(client_id): |
| | | # TODO 重启同花顺 |
| | | # 报警 |
| | | l2_clients = authority.get_l2_clients() |
| | | if client_id in l2_clients: |
| | | alert_util.alarm() |
| | | if constant.is_windows(): |
| | | # 动态导入 |
| | | |
| | | if ths_util.is_ths_dead(client_id): |
| | | # TODO 重启同花顺 |
| | | # 报警 |
| | | l2_clients = authority.get_l2_clients() |
| | | if client_id in l2_clients: |
| | | alert_util.alarm() |
| | | elif type == 60: |
| | | # L2自启动成功 |
| | | data = data_process.parse(_str)["data"] |
| | |
| | | return_str = json.dumps({"code": 1, "msg": "未处于可撤单状态"}) |
| | | else: |
| | | return_str = json.dumps({"code": 1, "msg": "请上传代码"}) |
| | | |
| | | elif type == 82: |
| | | # 获取委托列表 |
| | | data = json.loads(_str) |
| | | update_time = data["data"]["update_time"] |
| | | results, update_time = huaxin_trade_record_manager.DelegateRecordManager.list_by_day( |
| | | tool.get_now_date_str("%Y%m%d"), update_time) |
| | | return_str = json.dumps( |
| | | {"code": 0, "data": {"list": results, "updateTime": update_time}, "msg": "请上传代码"}) |
| | | |
| | | elif type == 201: |
| | | # 加入黑名单 |
| | | data = json.loads(_str) |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | |
| | | |
| | | # 交易成功无法读取时备用 |
| | | while True: |
| | | while False: |
| | | try: |
| | | datas = trade_juejin.get_execution_reports() |
| | | # 上传数据 |
| | |
| | | try: |
| | | global_data_loader.load_zyltgb() |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | volumes_data = init.get_volumns_by_code(code, 150) |
| | | volumes_data = inited_data.get_volumns_by_code(code, 150) |
| | | volumes_data = volumes_data[1:] |
| | | volumes = init.parse_max_volume(volumes_data[:60], |
| | | code_nature_analyse.is_new_top(limit_up_price, |
| | | volumes_data[:60])) |
| | | volumes = inited_data.parse_max_volume(volumes_data[:60], |
| | | code_nature_analyse.is_new_top(limit_up_price, |
| | | volumes_data[:60])) |
| | | logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes) |
| | | code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) |
| | | # 判断K线形态 |