| | |
| | | import json |
| | | |
| | | from db import redis_manager |
| | | from utils import tool |
| | | |
| | | redisManager = redis_manager.RedisManager(0) |
| | | |
| | |
| | | |
| | | |
| | | __L2_CODE_KEY = "huaxin_l2_code_list" |
| | | |
| | | __SUBSCRIPT_KEY = "huaxin_subscript_codes" |
| | | |
| | | |
| | | def clear(): |
| | |
| | | if val: |
| | | return json.loads(val) |
| | | return val |
| | | |
| | | |
| | | # 设置订阅代码 |
| | | def save_subscript_codes(codes): |
| | | __get_redis().setex(__SUBSCRIPT_KEY, tool.get_expire(), json.dumps(codes)) |
| | | |
| | | |
| | | # 获取订阅的代码 |
| | | def get_subscript_codes(): |
| | | val = __get_redis().get(__SUBSCRIPT_KEY) |
| | | if not val: |
| | | return [] |
| | | return json.loads(val) |
| | |
| | | import time |
| | | |
| | | import constant |
| | | from code_attribute import gpcode_manager |
| | | from l2 import l2_data_manager_new |
| | | from l2.huaxin import huaxin_target_codes_manager |
| | | from log_module.log import hx_logger_l2_upload, hx_logger_contact_debug, hx_logger_trade_callback, \ |
| | |
| | | trade_data_request_queue.put_nowait({"type": "position_list"}) |
| | | return_str = json.dumps( |
| | | {"code": 0, "data": {}, "msg": ""}) |
| | | elif type_ == "get_huaxin_subscript_codes": |
| | | # 获取华鑫订阅的代码 |
| | | codes = huaxin_target_codes_manager.get_subscript_codes() |
| | | fresults = [] |
| | | if codes: |
| | | for code in codes: |
| | | code_name = gpcode_manager.get_code_name(code) |
| | | fresults.append((code, code_name)) |
| | | return_str = json.dumps( |
| | | {"code": 0, "data": {"count": len(fresults), "list": fresults}, "msg": ""}) |
| | | # 查询委托列表 |
| | | elif type_ == 'test': |
| | | # 卖出 |
| | |
| | | from code_attribute import gpcode_manager |
| | | from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, l2_data_manager |
| | | from l2.cancel_buy_strategy import HourCancelBigNumComputer, LCancelBigNumComputer |
| | | from l2.huaxin import huaxin_target_codes_manager |
| | | from log_module.log import hx_logger_l2_upload, hx_logger_contact_debug, hx_logger_trade_callback, \ |
| | | hx_logger_l2_orderdetail, hx_logger_l2_transaction, hx_logger_l2_market_data, logger_l2_trade_buy_queue |
| | | from trade import deal_big_money_manager |
| | |
| | | sell_1_price, sell_1_volume // 100) |
| | | hx_logger_l2_market_data.info(f"{code}#{data}") |
| | | sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8')) |
| | | elif data_json["type"] == "l2_subscript_codes": |
| | | data = data_json["data"] |
| | | datas = data["data"] |
| | | # 订阅的代码 |
| | | huaxin_target_codes_manager.save_subscript_codes(datas) |
| | | else: |
| | | # 断开连接 |
| | | break |