public BrokerErrorCode CancelEquityOrder(string source, string orderRef, EquityOrderType productType, OrderDirection side) { var errCode = broker.CancelEquityOrder(orderRef, productType); Trace(string.Format(orderCancelTraceFormat, source, stockCode, side + " order cancel", ", OrderRef = " + orderRef, errCode)); return(errCode); }
public BrokerErrorCode CancelEquityOrder(string source, ref string orderRef, EquityOrderType productType, OrderDirection side) { var errCode = CancelEquityOrder(source, orderRef, productType, side); if (errCode == BrokerErrorCode.Success) { orderRef = ""; } return(errCode); }
public BrokerErrorCode ModifyEquityOrder(string stockCode, int quantity, string price, OrderPriceType orderPriceType, OrderDirection orderDirection, EquityOrderType orderType, Exchange exchange, string settlementNumber, out string orderRef) { orderRef = null; return(BrokerErrorCode.Success); }
public BrokerErrorCode PlaceEquityOrder(string stockCode, OrderPositionTypeEnum holdingType, int availableQty, int quantity, string price, OrderPriceType orderPriceType, OrderDirection orderDirection, EquityOrderType orderType, Exchange exchange, string settlementNumber, out string orderRef) { BrokerErrorCode errCode = BrokerErrorCode.Unknown; orderRef = ""; // Only OrderPositionTypeEnum.Margin is Buy/Sell, rest all others are only sell orders if (holdingType == OrderPositionTypeEnum.Btst) // only a sell order { errCode = broker.PlaceEquityDeliveryBTSTOrder(stockCode, quantity, price, orderPriceType, orderDirection, orderType, exchange, settlementNumber, out orderRef); } else if (holdingType == OrderPositionTypeEnum.Demat || holdingType == OrderPositionTypeEnum.Margin) { errCode = broker.PlaceEquityMarginDeliveryFBSOrder(stockCode, quantity, price, orderPriceType, orderDirection, orderType, exchange, out orderRef); } else if (holdingType == OrderPositionTypeEnum.OpenPendingDelivery) // only square off sell order { errCode = broker.PlaceEquityMarginSquareOffOrder(stockCode, availableQty, quantity, price, orderPriceType, orderDirection, orderType, settlementNumber, exchange, out orderRef); } var orderTypeStr = orderType == EquityOrderType.DELIVERY ? ("CASH " + holdingType) : "MARGIN"; Trace(string.Format(orderTraceFormat, stockCode, orderDirection, quantity, price, orderTypeStr, errCode, orderPriceType, settlementNumber)); if (errCode == BrokerErrorCode.Success && orderDirection == OrderDirection.BUY) { todayBuyOrderCount++; if (todayBuyOrderCount >= maxBuyOrdersAllowedInADay) { Trace(string.Format("Buy order count reached is: {0}. Max buy orders allowed: {1}", todayBuyOrderCount, maxBuyOrdersAllowedInADay)); } } return(errCode); }
public EquityOrder(String StockCode, int Quantity, String Price, OrderPriceType orderPriceType, OrderDirection orderDirection, Exchange exchange, EquityOrderType eqOrderType, String stopLossPrice, String limitPrice) { this.StockCode = StockCode; this.Quantity = Quantity; this.Price = Price; this.OrderPriceType = orderPriceType; this.OrderDirection = orderDirection; this.Exchange = exchange; this.EqOrderType = eqOrderType; this.StopLossPrice = stopLossPrice; this.LimitPrice = limitPrice; }
public BrokerErrorCode PlaceEquityOrder(string stockCode, int quantity, string price, OrderPriceType orderPriceType, OrderDirection orderDirection, EquityOrderType orderType, Exchange exchange, out string orderRef) { var errCode = broker.PlaceEquityMarginDeliveryFBSOrder(stockCode, quantity, price, orderPriceType, orderDirection, orderType, exchange, out orderRef); Trace(string.Format(orderTraceFormat, stockCode, orderDirection, quantity, price, orderType == EquityOrderType.DELIVERY ? "CASH" : "MARGIN", errCode, orderPriceType)); if (orderDirection == OrderDirection.BUY) { buyOrderCount++; if (buyOrderCount >= maxBuyOrders) { Trace(string.Format("Buy order count reached is: {0}. Max buy orders allowed: {1}", buyOrderCount, maxBuyOrders)); } } return(errCode); }
// place deliver order public BrokerErrorCode PlaceEquityMarginDeliveryFBSOrder(string stockCode, int quantity, string price, OrderPriceType orderPriceType, OrderDirection orderDirection, EquityOrderType orderType, Exchange exchange) { // Login If needed BrokerErrorCode errorCode = CheckAndLogInIfNeeded(false); if (errorCode != BrokerErrorCode.Success) { return(errorCode); } string FML_ORD_ORDR_FLW_value = null; if (orderDirection == OrderDirection.BUY) { FML_ORD_ORDR_FLW_value = "B"; } else if (orderDirection == OrderDirection.SELL) { FML_ORD_ORDR_FLW_value = "S"; } string FML_ORD_TYP_value = null, FML_ORD_LMT_RT_value = String.Empty; if (orderPriceType == OrderPriceType.MARKET) { FML_ORD_TYP_value = "M"; } else if (orderPriceType == OrderPriceType.LIMIT) { FML_ORD_TYP_value = "L"; FML_ORD_LMT_RT_value = price; } string FML_ORD_TRD_DT_value = null; string squareOffMode = "S"; string FML_ORD_XCHNG_CD_value = null; if (exchange == Exchange.BSE) { FML_ORD_TRD_DT_value = FML_ORD_TRD_DT_BSE_value; FML_ORD_XCHNG_CD_value = "BSE"; squareOffMode = "S"; } else if (exchange == Exchange.NSE) { FML_ORD_TRD_DT_value = FML_ORD_TRD_DT_NSE_value; FML_ORD_XCHNG_CD_value = "NSE"; squareOffMode = "M"; } string prdctType = orderType == EquityOrderType.DELIVERY ? "CASH" : "MARGIN"; string query = "FML_ORD_ORDR_FLW=" + FML_ORD_ORDR_FLW_value + "&FML_ACCOUNT=" + FML_ACCOUNT_value + "&TEMP=" + FML_ORD_XCHNG_CD_value + "&FML_ORD_PRDCT_TYP=" + prdctType + (orderType == EquityOrderType.MARGIN ? "&FML_SQ_FLAG=" + squareOffMode : "") + //Squareoff mode: M (for client) S (for broker), for BSE only S "&FML_STCK_CD=" + stockCode + "&FML_QTY=" + quantity.ToString() + "&FML_DOTNET_FLG=Y&FML_URL_FLG=http%3A%2F%2Fgetquote.icicidirect.com%2Ftrading%2Fequity%2Ftrading_stock_quote.asp " + "&FML_ORD_TYP=" + FML_ORD_TYP_value + "&FML_ORD_LMT_RT=" + FML_ORD_LMT_RT_value + "&FML_ORD_DSCLSD_QTY=&FML_ORD_STP_LSS=" + "&FML_ORD_TRD_DT_BSE=" + FML_ORD_TRD_DT_BSE_value + "&FML_ORD_TRD_DT_NSE=" + FML_ORD_TRD_DT_NSE_value + "&FML_ORD_TRD_DT=" + FML_ORD_TRD_DT_value + "&FML_PRODUCT_INDEX=0" + "&FML_ORD_PRD_HIDDEN=" + prdctType + "&FML_ORD_CLM_MTCH_ACCNT=" + "&FML_TRADING_LIMIT_NSE=" + FML_TRADING_LIMIT_NSE_value + "&FML_TRADING_LIMIT_BSE=" + FML_TRADING_LIMIT_BSE_value + "&FML_ORD_DP_CLNT_ID=&FML_ORD_DP_ID=&FML_TRN_PRDT_TYP=" + "&FML_ORD_XCHNG_CD=" + FML_ORD_XCHNG_CD_value + "&FML_ORD_XCHNG_CD_CHECK=" + (exchange == Exchange.BSE ? "NSE" : "") + "&FML_PRCNTG_CHECK=3.0&FML_ARRAY_BOUND=1&FML_ARRAY_ELEMENT=&NicValue=&BrowserBack_Xchang=NSE&PWD_ENABLED=N&FML_LAS=Y" + "&m_FML_AC_ACTIVATED_FROM=BSE&m_FML_USR_ZIP_CD=B3&m_FML_AC_ACTIVATED_FROM=NSE&m_FML_USR_ZIP_CD=N9"; string orderPlacePageData = IciciGetWebPageResponse(URL_ICICI_EQT_FBS_CASHMARGIN_ORDER, query, URL_ICICI_REFERRER, mCookieContainer, out errorCode); if (errorCode.Equals(BrokerErrorCode.Success)) { errorCode = GetEQTOrderPlacementCode(orderPlacePageData, EquityOrderType.DELIVERY); if (BrokerErrorCode.Success == errorCode) { // ********** Get exchange reference number (primary key for an order) *********** // add the record to DB GetOrderConfirmationData(orderPlacePageData, orderType); } } return(errorCode); }
// Get equity order placed return code public BrokerErrorCode GetEQTOrderPlacementCode(string orderResponse, EquityOrderType eqOrderType) { BrokerErrorCode code = BrokerErrorCode.Unknown; //Margin trading temporarily suspended if (null == orderResponse) { return(BrokerErrorCode.NullResponse); } if (orderResponse.IndexOf("rder placed successfully", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.Success); } if (orderResponse.IndexOf("Resource not available", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.ResourceNotAvailable); } if (orderResponse.IndexOf("not enabled for trading", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.ContractNotEnabled); } if (orderResponse.IndexOf("for the stock not available", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.ContractNotEnabled); } if (orderResponse.IndexOf("Immediate or Cancel Orders can be placed", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.ExchangeClosed); } if (orderResponse.IndexOf("have faced some technical or connectivity", StringComparison.OrdinalIgnoreCase) > -1) { return(BrokerErrorCode.TechnicalReason); } if (orderResponse.IndexOf("close your browser and try again", StringComparison.OrdinalIgnoreCase) > -1) { return(BrokerErrorCode.TechnicalReason); } if (orderResponse.IndexOf("insufficient to cover the trade value", StringComparison.OrdinalIgnoreCase) > -1) { return(BrokerErrorCode.InsufficientLimit); } if (orderResponse.IndexOf("Multiples of Contract Lot size", StringComparison.OrdinalIgnoreCase) > -1) { return(BrokerErrorCode.InvalidLotSize); } if (orderResponse.IndexOf("beyond the price range permitted by exchange", StringComparison.OrdinalIgnoreCase) > -1) { return(BrokerErrorCode.OutsidePriceRange); } if (orderResponse.IndexOf("expiry is underway", StringComparison.OrdinalIgnoreCase) > -1) { return(BrokerErrorCode.ExchangeClosed); } if (orderResponse.IndexOf("server error", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.ServerError); } if (orderResponse.IndexOf("order not allowed when exchange is closed", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.ExchangeClosed); } if (orderResponse.IndexOf("outside price range", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.OutsidePriceRange); } if (orderResponse.IndexOf("nsufficient stock", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.InsufficientStock); } if (orderResponse.IndexOf("nsufficient limit", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.InsufficientLimit); } if (orderResponse.IndexOf("Invalid User", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.NotLoggedIn); } if (orderResponse.IndexOf("The Login Id entered is not valid", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.NotLoggedIn); } if (orderResponse.IndexOf("Invalid Login Id", StringComparison.OrdinalIgnoreCase) >= 0) { return(BrokerErrorCode.NotLoggedIn); } if (orderResponse.IndexOf("Session has Timed Out", StringComparison.OrdinalIgnoreCase) >= 0) { return(BrokerErrorCode.NotLoggedIn); } if (orderResponse.IndexOf("Please Login again", StringComparison.OrdinalIgnoreCase) >= 0) { return(BrokerErrorCode.NotLoggedIn); } if (orderResponse.Length < 2000 && orderResponse.IndexOf("location.href=chttps + \"/customer/logon.asp\"", StringComparison.OrdinalIgnoreCase) >= 0) { return(BrokerErrorCode.NotLoggedIn); } if (orderResponse.IndexOf("Check stock code", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.InValidStockCode); } if (orderResponse.IndexOf("Stock may not be traded on the exchange selected or stock code may not be valid", StringComparison.OrdinalIgnoreCase) > 0) { return(BrokerErrorCode.InValidStockCode); } return(BrokerErrorCode.Unknown); }
public BrokerErrorCode PlaceEquityOrder( ref OrderUpdateEventArgs latestOrderUpdatedInfo, AutoResetEvent orderUpdatedEvent, string exchange, string stockCode, OrderDirection orderDirection, OrderPriceType orderPriceType, int quantity, EquityOrderType orderType, double price, out string orderId, out OrderStatus orderStatus) { //lock (lockSingleThreadedUpstoxCall) { BrokerErrorCode errorCode = BrokerErrorCode.Unknown; orderStatus = OrderStatus.UNKNOWN; orderId = ""; if (quantity == 0) { Trace("Not placing order as quantity is 0"); Trace(string.Format("Not placing order: {0} {1} {2} {3}@{4} {5}, as quantity is 0", orderType, stockCode, orderDirection, quantity, price, orderPriceType)); return(errorCode); } if (price == 0 && orderPriceType == OrderPriceType.LIMIT) { Trace(string.Format("Not placing order: {0} {1} {2} {3}@{4} {5}, as price is 0 for limit order", orderType, stockCode, orderDirection, quantity, price, orderPriceType)); return(errorCode); } var transType = orderDirection == OrderDirection.BUY ? "B" : "S"; var ordType = orderPriceType == OrderPriceType.LIMIT ? "L" : "M"; var prodType = orderType == EquityOrderType.DELIVERY ? "D" : "I"; try { orderId = upstox.PlaceSimpleOrder(exchange, stockCode, transType, ordType, quantity, prodType, price); Thread.Sleep(1000); // let the order status update at server errorCode = GetOrderStatus(orderId, stockCode, out orderStatus); mOrderIds[stockCode].Add(orderId); // For unsuccessful placeorder dont send orderId if (orderStatus == OrderStatus.EXPIRED || orderStatus == OrderStatus.CANCELLED || orderStatus == OrderStatus.NOTFOUND || orderStatus == OrderStatus.REJECTED || orderStatus == OrderStatus.UNKNOWN) { orderId = ""; } } catch (Exception ex) { Trace(string.Format(genericErrorLogFormat, stockCode, GeneralUtils.GetCurrentMethod(), ex.Message, ex.StackTrace)); // wait for orderupdate event signal var orderUpdateWait = orderUpdatedEvent.WaitOne(20 * 1000); lock (lockSingleThreadedUpstoxCall) { if (orderUpdateWait) { if (latestOrderUpdatedInfo != null) { // match the order if (latestOrderUpdatedInfo.Price == price && latestOrderUpdatedInfo.Quantity == quantity && latestOrderUpdatedInfo.Product == prodType && transType == latestOrderUpdatedInfo.TransType) { orderStatus = ParseOrderStatus(latestOrderUpdatedInfo.Status); orderId = latestOrderUpdatedInfo.OrderId; if (!string.IsNullOrEmpty(orderId) && !mOrderIds[stockCode].Contains(orderId)) { mOrderIds[stockCode].Add(orderId); } Trace(string.Format("{0} PlaceSimpleOrder Reconciliation completed. ErrCode={1}, OrderStatus={2}, OrderId={3}", stockCode, errorCode, orderStatus, orderId)); } else { Trace(string.Format("{0} PlaceSimpleOrder Reconciliation failed OrderNotMatched. ErrCode={1}, OrderStatus={2}, OrderId={2}", stockCode, errorCode, orderStatus, orderId)); } } else { Trace(string.Format("{0} PlaceSimpleOrder LatestOrderUpdateInfo is null . ErrCode={1}, OrderStatus={2}, OrderId={3}", stockCode, errorCode, orderStatus, orderId)); } } else { Trace(string.Format("{0} PlaceSimpleOrder Reconciliation failed NoOrderUpdate. ErrCode={1}, OrderStatus={2}, OrderId={2}", stockCode, errorCode, orderStatus, orderId)); } } } return(errorCode); } }
// place margin or delivery order public BrokerErrorCode PlaceEquityMarginDeliveryFBSOrder(string stockCode, int quantity, string price, OrderPriceType orderPriceType, OrderDirection orderDirection, EquityOrderType orderType, Exchange exchange, out string orderRef) { orderRef = ""; // Login If needed BrokerErrorCode errorCode = CheckAndLogInIfNeeded(false); if (errorCode != BrokerErrorCode.Success) { return(errorCode); } string FML_ORD_ORDR_FLW_value = orderDirection == OrderDirection.BUY ? "B" : "S"; string FML_ORD_TYP_value = null, FML_ORD_LMT_RT_value = String.Empty; if (orderPriceType == OrderPriceType.MARKET) { FML_ORD_TYP_value = "M"; } else if (orderPriceType == OrderPriceType.LIMIT) { FML_ORD_TYP_value = "L"; FML_ORD_LMT_RT_value = price; } string FML_ORD_TRD_DT_value = null; string squareOffMode = orderDirection == OrderDirection.SELL ? "S" : "M"; string FML_ORD_XCHNG_CD_value = null; if (exchange == Exchange.BSE) { FML_ORD_TRD_DT_value = FML_ORD_TRD_DT_BSE_value; FML_ORD_XCHNG_CD_value = "BSE"; } else if (exchange == Exchange.NSE) { FML_ORD_TRD_DT_value = FML_ORD_TRD_DT_NSE_value; FML_ORD_XCHNG_CD_value = "NSE"; } string prdctType = orderType == EquityOrderType.DELIVERY ? "C" : "M"; string query = "&FML_SQ_FLAG=" + (orderType == EquityOrderType.MARGIN ? squareOffMode : "") + //Squareoff mode: M (for client) S (for broker), for BSE only S "&ORD_XCHNG_CD=" + FML_ORD_XCHNG_CD_value + "&FML_STCK_CD=" + stockCode + "&FML_QTY=" + quantity.ToString() + "&FML_ORD_DSCLSD_QTY=" + "&FML_POINT_TYPE=T" + ">CDate7=" + GTCDate7 + ">CDate=" + GTCDate + ">CDateHidden7=" + GTCDateHidden7 + "&FML_ORD_TYP=" + FML_ORD_TYP_value + "&FML_ORD_LMT_RT=" + FML_ORD_LMT_RT_value + "&FML_GMS_CSH_PRDCT_PRCNTG=" + "&FML_ORD_STP_LSS=" + "&FML_TRADING_PASSWD=" + "&Submit=Buy+Now" + "&FML_ORD_TRD_DT_BSE=" + FML_ORD_TRD_DT_BSE_value + "&FML_ORD_TRD_DT_NSE=" + FML_ORD_TRD_DT_NSE_value + "&FML_ORD_XCHNG_CD=" + FML_ORD_XCHNG_CD_value + "&NSEStatus=" + NSEStatus + "&BSEStatus=" + BSEStatus + "&FML_PRCNTG_CHECK=" + FML_PRCNTG_CHECK + "&FML_ORD_TRD_DT=" + FML_ORD_TRD_DT_value + "&FML_XCHNG_ST=" + NSEStatus + // O or C (open or closed) "&NicValue=" + "&FML_LAS=" + "&FML_ACCOUNT=" + "&FML_URQ_USR_RD_FLG=" + "&FML_ORD_PRDCT_TYP=" + prdctType + "&FML_ORD_ORDR_FLW=" + FML_ORD_ORDR_FLW_value + "&pgname=eqfastbuy&ismethodcall=1&mthname=DoFinalSubmit"; string orderPlacePageData = IciciGetWebPageResponse(URL_ICICI_EQT_FASTBUYSELL, query, URL_ICICI_REFERRER, mCookieContainer, out errorCode); if (errorCode.Equals(BrokerErrorCode.Success)) { errorCode = GetEQTOrderPlacementCode(orderPlacePageData); if (BrokerErrorCode.Success == errorCode) { orderRef = ExtractOrderReferenceNumber(orderPlacePageData); } } return(errorCode); }
// place margin pending delivery square off order public BrokerErrorCode PlaceEquityMarginSquareOffOrder(string stockCode, int quantity, string price, OrderPriceType orderPriceType, OrderDirection orderDirection, EquityOrderType orderType, Exchange exchange, out string orderRef) { orderRef = ""; // Login If needed BrokerErrorCode errorCode = CheckAndLogInIfNeeded(false); if (errorCode != BrokerErrorCode.Success) { return(errorCode); } string FML_ORD_ORDR_FLW_value = orderDirection == OrderDirection.BUY ? "B" : "S"; string FML_XCHNG_SGMNT_CD = ""; string FML_ORD_TYP_value = null, FML_ORD_LMT_RT_value = String.Empty; if (orderPriceType == OrderPriceType.MARKET) { FML_ORD_TYP_value = "M"; } else if (orderPriceType == OrderPriceType.LIMIT) { FML_ORD_TYP_value = "L"; FML_ORD_LMT_RT_value = price; } string FML_ORD_TRD_DT_value = null; string squareOffMode = orderDirection == OrderDirection.SELL ? "S" : "M"; string FML_ORD_XCHNG_CD_value = null; if (exchange == Exchange.BSE) { FML_XCHNG_SGMNT_CD = "B"; FML_ORD_TRD_DT_value = FML_ORD_TRD_DT_BSE_value; FML_ORD_XCHNG_CD_value = "BSE"; } else if (exchange == Exchange.NSE) { FML_XCHNG_SGMNT_CD = "N"; FML_ORD_TRD_DT_value = FML_ORD_TRD_DT_NSE_value; FML_ORD_XCHNG_CD_value = "NSE"; } string prdctType = orderType == EquityOrderType.DELIVERY ? "C" : "M"; string query = "&FML_ORD_XCHNG_CD=" + FML_ORD_XCHNG_CD_value + "&FML_STCK_CD=" + stockCode + "&FML_QTY=" + quantity.ToString() + "&FML_XCHNG_SGMNT_CD=" + FML_XCHNG_SGMNT_CD + "&FML_STTLMNT_NMBR=" + "&AvgPrc=" + "&FML_ORD_TRD_DT=" + FML_ORD_TRD_DT_NSE_value + "&FML_XCHNG_ST=" + NSEStatus + "&NicValue=" + "&m_IntPass=1" + "&FML_URQ_USR_RD_FLG=" + "&FML_ORD_ORDR_FLW=" + FML_ORD_ORDR_FLW_value + "&FML_ORD_DSCLSD_QTY=" + "&FML_SQROFF=" + quantity.ToString() + "&FML_POINT_TYPE=T" + "&FML_ORD_TYP=" + FML_ORD_TYP_value + "&FML_LM_RT=" + FML_ORD_LMT_RT_value + "&FML_GMS_CSH_PRDCT_PRCNTG=" + "&FML_ORD_STP_LSS=" + "&Submit1=Square Off" + "&Submit2=Clear" + "&FML_ORD_XCHNG_SGMNT_STTLMNT=" + "&FML_QUOTE=" + "&FML_QUOTE_TIME=" + "&FML_TRDNG_PSSWRD_FLG=N" + "&FML_RT=" + "&FML_ISIN_NMBR=" + "&FML_STK_STCK_NM=" + "&FML_TM=" + "&FML_QTY_OTH=" + quantity.ToString() + "&pgname=EquityPendingForDeliverySquareOff" + "&ismethodcall=1" + "&mthname=ValidateFormData"; string orderPlacePageData = IciciGetWebPageResponse(URL_ICICI_BASE_ACTION, query, URL_ICICI_REFERRER, mCookieContainer, out errorCode); if (errorCode.Equals(BrokerErrorCode.Success)) { errorCode = GetEQTOrderPlacementCode(orderPlacePageData); if (BrokerErrorCode.Success == errorCode) { orderRef = ExtractOrderReferenceNumberMarginSqOffOrder(orderPlacePageData); } } return(errorCode); }