def trade_hkcc_test():
    """
    A股通交易测试
    :return:
    """
    trd_ctx = OpenHKCCTradeContext(host='127.0.0.1', port=11111)
    trd_ctx.set_handler(TradeOrderTest())
    trd_ctx.set_handler(TradeDealTest())
    trd_ctx.start()

    # 交易请求必须先解锁 !!!
    pwd_unlock = '979899'
    print("* unlock_trade : {}\n".format(trd_ctx.unlock_trade(pwd_unlock)))

    print("* accinfo_query : {}\n".format(trd_ctx.accinfo_query()))
    print("* position_list_query : {}\n".format(trd_ctx.position_list_query(pl_ratio_min=-50, pl_ratio_max=50)))
    print("* order_list_query : {}\n".format(trd_ctx.order_list_query(status_filter_list=[OrderStatus.DISABLED])))
    print("* get_acc_list : {}\n".format(trd_ctx.get_acc_list()))
    print("* order_list_query : {}\n".format(trd_ctx.order_list_query(status_filter_list=[OrderStatus.SUBMITTED])))

    ret_code, ret_data = trd_ctx.place_order(0.1, 100, "SZ.000979", TrdSide.BUY)
    print("* place_order : {}\n".format(ret_data))
    if ret_code == RET_OK:
        order_id = ret_data['order_id'][0]
        print("* modify_order : {}\n".format(trd_ctx.modify_order(ModifyOrderOp.CANCEL, order_id, 0, 0)))

    print("* deal_list_query : {}\n".format(trd_ctx.deal_list_query(code="000979")))
    print("* history_order_list_query : {}\n".format(trd_ctx.history_order_list_query(status_filter_list=[OrderStatus.FILLED_ALL, OrderStatus.FILLED_PART],
                                           code="512310", start="", end="2018-2-1")))

    print("* history_deal_list_query : {}\n".format(trd_ctx.history_deal_list_query(code="", start="", end="2018-6-1")))

    sleep(10)
    trd_ctx.close()
def trade_hkcc_test ( ) : trd_ctx = OpenHKCCTradeContext ( host = '127.0.0.1' , port = 11111 ) trd_ctx . set_handler ( TradeOrderTest ( ) ) trd_ctx . set_handler ( TradeDealTest ( ) ) trd_ctx . start ( ) pwd_unlock = '979899' print ( "* unlock_trade : {}\n" . format ( trd_ctx . unlock_trade ( pwd_unlock ) ) ) print ( "* accinfo_query : {}\n" . format ( trd_ctx . accinfo_query ( ) ) ) print ( "* position_list_query : {}\n" . format ( trd_ctx . position_list_query ( pl_ratio_min = - 50 , pl_ratio_max = 50 ) ) ) print ( "* order_list_query : {}\n" . format ( trd_ctx . order_list_query ( status_filter_list = [ OrderStatus . DISABLED ] ) ) ) print ( "* get_acc_list : {}\n" . format ( trd_ctx . get_acc_list ( ) ) ) print ( "* order_list_query : {}\n" . format ( trd_ctx . order_list_query ( status_filter_list = [ OrderStatus . SUBMITTED ] ) ) ) ret_code , ret_data = trd_ctx . place_order ( 0.1 , 100 , "SZ.000979" , TrdSide . BUY ) print ( "* place_order : {}\n" . format ( ret_data ) ) if ret_code == RET_OK : order_id = ret_data [ 'order_id' ] [ 0 ] print ( "* modify_order : {}\n" . format ( trd_ctx . modify_order ( ModifyOrderOp . CANCEL , order_id , 0 , 0 ) ) ) print ( "* deal_list_query : {}\n" . format ( trd_ctx . deal_list_query ( code = "000979" ) ) ) print ( "* history_order_list_query : {}\n" . format ( trd_ctx . history_order_list_query ( status_filter_list = [ OrderStatus . FILLED_ALL , OrderStatus . FILLED_PART ] , code = "512310" , start = "" , end = "2018-2-1" ) ) ) print ( "* history_deal_list_query : {}\n" . format ( trd_ctx . history_deal_list_query ( code = "" , start = "" , end = "2018-6-1" ) ) ) sleep ( 10 ) trd_ctx . close ( )
A股通交易测试
    :return: