| | |
| | | from db import redis_manager_delegate as redis_manager, mysql_data_delegate as mysql_data |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from log_module import log_export, async_log_util |
| | | from log_module.log import hx_logger_l2_transaction, logger_debug, logger_request_api |
| | | from log_module.log import hx_logger_l2_transaction, logger_debug, logger_request_api, logger_system |
| | | from strategy import data_cache |
| | | from strategy.kpl_data_manager import KPLMarketsSiftPlateLogManager, KPLMarketStockHeatLogManager |
| | | from strategy.trade_setting import TradeSetting |
| | |
| | | "auto_buy": TradeSetting().get_auto_buy()} |
| | | response_data = json.dumps({"code": 0, "data": fdata}) |
| | | |
| | | elif url.path == "/set_trade_settings": |
| | | running = params_dict.get("running") |
| | | auto_sell = params_dict.get("auto_sell") |
| | | auto_buy = params_dict.get("auto_buy") |
| | | if running is not None: |
| | | TradeSetting().set_running(int(running)) |
| | | if auto_sell is not None: |
| | | TradeSetting().set_auto_sell(int(auto_sell)) |
| | | if auto_buy is not None: |
| | | TradeSetting().set_auto_buy(int(auto_buy)) |
| | | response_data = json.dumps({"code": 0, "data": {}}) |
| | | |
| | | elif url.path == "/get_env": |
| | | request_id = params_dict.get("request_id") |
| | | use_time_list = [] |
| | |
| | | if use_time_list and use_time_list[-1][1] > 10: |
| | | logger_debug.warning(f"环境获取时间大于10s({request_id}):{use_time_list}") |
| | | # 获取板块强度数据 |
| | | elif url.path == "/load_get_kpl_market_sift_plate": |
| | | elif url.path == "/load_kpl_market_sift_plate": |
| | | # 加载数据 |
| | | KPLMarketsSiftPlateLogManager().load_data() |
| | | response_data = json.dumps({"code": 0, "msg": "暂无内容"}) |
| | |
| | | else: |
| | | huaxin_trade_api.add_trade_callback_data(body) |
| | | result_str = json.dumps({"code": 0}) |
| | | elif url.path == "/set_trade_settings": |
| | | params = self.__parse_request() |
| | | if not self.__is_sign_right(params): |
| | | result_str = json.dumps({"code": 1001, "msg": "签名错误"}) |
| | | return |
| | | logger_debug.info(f"set_trade_settings: {params}") |
| | | running = params.get("running") |
| | | auto_sell = params.get("auto_sell") |
| | | auto_buy = params.get("auto_buy") |
| | | if running is not None: |
| | | TradeSetting().set_running(int(running)) |
| | | if auto_sell is not None: |
| | | TradeSetting().set_auto_sell(int(auto_sell)) |
| | | if auto_buy is not None: |
| | | TradeSetting().set_auto_buy(int(auto_buy)) |
| | | result_str = json.dumps({"code": 0, "data": {}}) |
| | | |
| | | elif url.path == "/buy": |
| | | # 签名验证 |
| | | params = self.__parse_request() |
| | |
| | | print("HTTP server is at: http://%s:%d/" % (addr, port)) |
| | | httpd.serve_forever() |
| | | except Exception as e: |
| | | pass |
| | | logger_system.exception(e) |
| | | |
| | | |
| | | if __name__ == "__main__": |