예제 #1
0
        public ResponseInfo <CancelOrderDatamap> Cancel(string orderid, string memberid)
        {
            CancelOrderInfo info = new CancelOrderInfo()
            {
                memberId = memberid, orderId = orderid
            };
            ApiSetting setting  = new ApiSetting(null);
            var        response = SecurityHttpClient.Post <CancelOrderInfo, CancelOrderDatamap>(setting.JavaOrder_Uri + "cancel", info);

            if (response.respCode != "0")
            {
                throw new ApplicationException(response.respMsg);
            }
            return(response);
        }
예제 #2
0
 public static void ChangePosition(this TradingPosition tradingPosition, CancelOrderInfo marketInfo)
 {
     tradingPosition.OpenPositionOrder.OrderStateType = OrderStateType.Cancelled;
 }
예제 #3
0
        public CancelOrderResponse Cancel(string orderid, string memberid)
        {
            CancelOrderInfo info = new CancelOrderInfo()
            {
                memberId = memberid, orderId = orderid
            };
            string mid = memberid;

            if (string.IsNullOrWhiteSpace(mid))
            {
                mid = DefaultMemberId;
            }
            info.memberId = mid;
            var password = GetPassword(mid);
            var datetime = DateTime.Now;
            var request  = new CancelOrderRequest
            {
                dataMap = info,
                sign    = BuildSign(info, datetime, password),
                reqTime = datetime.ToString(DateTimeFormat)
            };

            var jSetting = new JsonSerializerSettings();

            jSetting.NullValueHandling = NullValueHandling.Ignore;
            var content = JsonConvert.SerializeObject(request, jSetting);

            _log.Debug("Post data:" + content);
            var config = new CommonConfig(null);

            var req = (HttpWebRequest)WebRequest.Create(config.JavaOrder_Uri + "cancel");

            req.Method      = "POST";
            req.ContentType = "Application/Json";
            req.Credentials = CredentialCache.DefaultCredentials;
            req.Timeout     = 300000;
            // 如果服务器返回错误,他还会继续再去请求,不会使用之前的错误数据,做返回数据
            //req.ServicePoint.Expect100Continue = false;
            WriteRequestData(req, content);
            var response = req.GetResponse();

            if (response == null)
            {
                throw new Exception("请求失败!");
            }
            var stream = response.GetResponseStream();

            if (stream == null)
            {
                throw new Exception("请求Stream为空!");
            }
            var sr     = new StreamReader(stream, Encoding.UTF8);
            var retXml = sr.ReadToEnd();

            sr.Close();
            _log.Debug(retXml);
            var obj = JsonConvert.DeserializeObject <CancelOrderResponse>(retXml);

            if (obj.respCode != "0")
            {
                throw new ApplicationException(obj.respMsg);
            }
            return(obj);
        }