| | |
| | | # -*- coding: utf-8 -*- |
| | | import json |
| | | import logging |
| | | import os |
| | | import threading |
| | | import time |
| | | |
| | |
| | | import xmdapi |
| | | from huaxin_api import tool |
| | | from huaxin_api.client_network import SendResponseSkManager |
| | | from log_module.log import logger_system |
| | | |
| | | level1_data_dict = { |
| | | |
| | |
| | | |
| | | |
| | | def run_async(pipe_l2): |
| | | logger_system.info("L1进程ID:", os.getpid()) |
| | | t1 = threading.Thread(target=lambda: run(pipe_l2), daemon=True) |
| | | t1.start() |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | run(None) |
| | | pass |
| | |
| | | # -*- coding: utf-8 -*- |
| | | import json |
| | | import logging |
| | | import os |
| | | import queue |
| | | import threading |
| | | import time |
| | |
| | | from huaxin_api.command_manager import L2ActionCallback |
| | | from log_module import log |
| | | from log_module.log import logger_local_huaxin_l2_subscript, logger_local_huaxin_l2_orderdetail, \ |
| | | logger_local_huaxin_l2_transaction |
| | | logger_local_huaxin_l2_transaction, logger_system |
| | | |
| | | Front_Address = "tcp://10.0.1.101:6900" |
| | | Multicast_Address = "udp://224.224.2.19:7889" |
| | |
| | | |
| | | |
| | | def run(pipe_trade, pipe_strategy): |
| | | logger_system.info("L2进程ID:", os.getpid()) |
| | | log.close_print() |
| | | if pipe_trade is not None: |
| | | t1 = threading.Thread(target=lambda: __receive_from_pipe_trade(pipe_trade), daemon=True) |
| | |
| | | # -*- coding: utf-8 -*- |
| | | import json |
| | | import logging |
| | | import os |
| | | import threading |
| | | import time |
| | | |
| | |
| | | from huaxin_api.log import logger |
| | | |
| | | # 正式账号 |
| | | from log_module.log import logger_local_huaxin_trade_debug |
| | | from log_module.log import logger_local_huaxin_trade_debug, logger_system |
| | | |
| | | UserID = '388000013349' |
| | | # 登陆密码 |
| | |
| | | |
| | | |
| | | def run(pipe_l2=None, pipe_strategy=None): |
| | | logger_system.info("交易进程ID:", os.getpid()) |
| | | __init_trade_data_server() |
| | | global l2pipe |
| | | l2pipe = pipe_l2 |
| | |
| | | |
| | | from db import redis_manager_delegate as redis_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from log_module.log import logger_debug |
| | | from utils import tool |
| | | from utils.tool import CodeDataCacheUtil |
| | | |
| | |
| | | if buy_single_index is not None: |
| | | data_ = (buy_single_index, buy_exec_index, compute_index, nums, count, list(max_num_sets), |
| | | volume_rate) |
| | | |
| | | else: |
| | | _buy_single_index, _buy_exec_index, _compute_index, _nums, _count, _max_num_index, _volume_rate = self.get_buy_compute_start_data_cache( |
| | | code) |
| | | data_ = (_buy_single_index, buy_exec_index, compute_index, nums, count, list(max_num_sets), |
| | | volume_rate) |
| | | logger_debug.info(f"保存买入执行位置信息{code}:{data_}") |
| | | CodeDataCacheUtil.set_cache(self.__buy_compute_index_info_cache, code, data_) |
| | | RedisUtils.setex_async(self.__db, _key, expire, json.dumps(data_)) |
| | | |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | logger_l2_trade.info("测试") |
| | | print(os.getpid()) |
| | | input() |
| | |
| | | import huaxin_api.l2_client |
| | | import huaxin_api.l1_client |
| | | from log_module import log |
| | | from log_module.log import logger_l2_trade |
| | | from log_module.log import logger_l2_trade, logger_system |
| | | |
| | | from server import * |
| | | |
| | |
| | | |
| | | |
| | | def createTradeServer(pipe_server, pipe_trade, pipe_l1, pipe_l2): |
| | | logger_system.info("策略进程ID:", os.getpid()) |
| | | log.close_print() |
| | | # 初始化参数 |
| | | global_data_loader.init() |
| | |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | logger_l2_trade.info("test123123") |
| | | logger_l2_trade.info("启动程序") |
| | | log.close_print() |
| | | # 策略与server间的通信 |
| | | pss_server, pss_strategy = multiprocessing.Pipe() |
| | |
| | | # 托管环境下不创建 |
| | | # serverProcess = multiprocessing.Process(target=createServer, args=(pss_server,)) |
| | | # serverProcess.start() |
| | | logger_system.info("主进程ID:", os.getpid()) |
| | | |
| | | tradeServerProcess = multiprocessing.Process(target=createTradeServer, |
| | | args=(pss_strategy, pst_strategy, pl1t_strategy, psl2_strategy)) |