| | |
| | | """ |
| | | import json |
| | | |
| | | from code_attribute import gpcode_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from trade import l2_trade_util |
| | | from utils import tool |
| | | from db import redis_manager_delegate as redis_manager |
| | | from log_module.log import logger_trade_queue_price_info |
| | |
| | | self.__save_buy1_price_info(code, old_limit_up_time, time_str) |
| | | |
| | | if old_limit_up_time and not is_limit_up: |
| | | # 获取计算当前的涨幅 |
| | | pre_close_price = round(float(limit_up_price) / 1.1, 2) |
| | | if (float(buy_1_price) - pre_close_price) / pre_close_price < 0.05: |
| | | # 涨幅小于5% |
| | | l2_trade_util.add_to_forbidden_trade_codes(code) |
| | | logger_trade_queue_price_info.add(f"涨停炸开后现价涨幅小于5%之后不买:code-{code}") |
| | | # 之前涨停过且现在尚未涨停 |
| | | self.set_open_limit_up_lowest_price(code, buy_1_price) |
| | | |
| | |
| | | def close_print(): |
| | | pass |
| | | # logging.basicConfig(level=logging.ERROR) |
| | | if not constant.is_windows(): |
| | | os.close(1) |
| | | os.open('/dev/null', os.O_WRONLY) |
| | | # if not constant.is_windows(): |
| | | # os.close(1) |
| | | # os.open('/dev/null', os.O_WRONLY) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | |
| | | @classmethod |
| | | def __create_client(cls, client_type, rid): |
| | | client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 生成socket,连接server |
| | | client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, True) |
| | | # client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, True) |
| | | # client.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 60 * 1000, 30 * 1000)) |
| | | client.connect(cls.ip_port) |
| | | client.send(SendResponseSkManager.format_response( |
| | |
| | | json.dumps({"type": "heart", "client_id": client_id}).encode('utf-8'))) |
| | | # print("心跳信息发送成功", client_id) |
| | | except Exception as e: |
| | | logging.error("错误") |
| | | print("心跳信息发送失败", _type, client_id) |
| | | logging.exception(e) |
| | | if _type == CLIENT_TYPE_TRADE: |