Administrator
2023-07-11 19a3a25a0145c13966288c70817925ca5528fbbe
华鑫适配
3个文件已修改
37 ■■■■■ 已修改文件
trade/huaxin/huaxin_trade_api.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_api_server.py 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_huaxin.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_api.py
@@ -231,6 +231,8 @@
def parseResponse(data_str):
    if not data_str:
        raise Exception("反馈内容为空")
    res = data_str
    if type(res) == str:
    res = json.loads(data_str)
    res = res['data']
    if res['code'] != 0:
trade/huaxin/trade_api_server.py
@@ -14,7 +14,7 @@
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_trade_debug
from third_data.history_k_data_util import HistoryKDatasUtils
from trade import trade_manager
from trade import trade_manager, trade_huaxin
from trade.huaxin import huaxin_trade_api as trade_api, huaxin_trade_api, huaxin_trade_record_manager
from utils import socket_util, tool, huaxin_util
@@ -97,12 +97,21 @@
                            if result:
                                resultJSON = result
                                print("下单结果:", resultJSON)
                                if resultJSON['code'] == 0:
                                    # TODO 下单成功保存下单结果数据
                                    return_str = json.dumps({"code": 0})
                                #
                                # {'code': 0, 'data': {'sinfo': 'b_600480_1689060343812', 'securityId': '600480',
                                # 'orderLocalId': '0190000809', 'orderStatus': '7', 'statusMsg':
                                # '10932:产品状态资源访问授权不足', 'orderSysID': '110010190000809', 'accountId':
                                # '38800001334901'}}
                                resultJSON = trade_api.parseResponse(resultJSON)
                                statusCode = resultJSON['orderStatus']
                                if statusCode == huaxin_util.TORA_TSTP_OST_Rejected:
                                    # 交易所拒绝
                                    raise Exception(resultJSON['statusMsg'])
                                else:
                                    # 返回下单失败
                                    raise Exception(resultJSON['msg'])
                                    trade_huaxin.order_success(resultJSON['securityId'], resultJSON['accountId'],
                                                               resultJSON['orderSysID'])
                                    return_str = json.dumps({"code": 0})
                        except Exception as e:
                            raise e
                    elif type_ == 'cancel_order':
trade/trade_huaxin.py
@@ -4,12 +4,11 @@
import json
import time
import constant
from db.redis_manager import RedisManager
from log_module.log import logger_juejin_trade
from trade.huaxin import huaxin_trade_api
from utils import  tool
from utils import tool, huaxin_util
__context_dict = {}
@@ -72,15 +71,19 @@
        print("下单结果", result)
        result = huaxin_trade_api.parseResponse(result)
        if result["orderStatus"] < 0:
            logger_juejin_trade.info(f"{code}:下单失败:{result['orderStatusMsg']}")
            raise Exception(result["orderStatusMsg"])
        if result["orderStatus"] == huaxin_util.TORA_TSTP_OST_Rejected:
            logger_juejin_trade.info(f"{code}:下单失败:{result['statusMsg']}")
            raise Exception(result["statusMsg"])
        else:
            TradeOrderIdManager.add_order_id(code, result["accountId"], result["orderSysID"])
            logger_juejin_trade.info(f"{code}:下单成功 orderSysID:{result['orderSysID']}")
            return result["securityId"], result["accountId"], result["orderSysID"]
    else:
        raise Exception("下单失败,无返回")
def order_success(code, accountId, orderSysID):
    TradeOrderIdManager.add_order_id(code, accountId, orderSysID)
# 撤单
@@ -97,7 +100,6 @@
        for order in orders:
            huaxin_trade_api.cancel_order(1, code, order["orderSysID"])
            TradeOrderIdManager.remove_order_id(code, order["accountId"], order["orderSysID"])
if __name__ == "__main__":