private void ParseCommon(AddOrderRelationCommandBase command) { var constructParams = command.ConstructParams; var dataRowOrderRelation = command.DataRowOrderRelation; constructParams.CloseOrder = command.CloseOrder; constructParams.OpenOrder = command.Account.GetOrder((Guid)dataRowOrderRelation["OpenOrderID"]); if (constructParams.OpenOrder == null) { throw new OpenOrderNotFoundException((Guid)dataRowOrderRelation["OpenOrderID"], constructParams.CloseOrder.Id); } constructParams.ClosedLot = (decimal)dataRowOrderRelation["ClosedLot"]; if (dataRowOrderRelation["CloseTime"] != DBNull.Value) { constructParams.CloseTime = (DateTime)dataRowOrderRelation["CloseTime"]; constructParams.Commission = (decimal)dataRowOrderRelation["Commission"]; constructParams.Levy = (decimal)dataRowOrderRelation["Levy"]; constructParams.OtherFee = (decimal)dataRowOrderRelation["OtherFee"]; constructParams.InterestPL = (decimal)dataRowOrderRelation["InterestPL"]; constructParams.StoragePL = (decimal)dataRowOrderRelation["StoragePL"]; constructParams.TradePL = (decimal)dataRowOrderRelation["TradePL"]; if (dataRowOrderRelation["ValueTime"] != DBNull.Value) { constructParams.ValueTime = (DateTime)dataRowOrderRelation["ValueTime"]; constructParams.Decimals = (byte)dataRowOrderRelation["TargetDecimals"]; constructParams.RateIn = (decimal)(double)dataRowOrderRelation["RateIn"]; constructParams.RateOut = (decimal)(double)dataRowOrderRelation["RateOut"]; } } constructParams.OperationType = Framework.OperationType.None; }
private void VisitCommon(AddOrderRelationCommandBase command) { this.ValidateCommon(command); this.ValidateLotBalanceCommon(command); this.ParseCommon(command); command.CreateOrderRelation(); }
private void ParseCommon(AddOrderRelationCommandBase command) { var constructParams = command.ConstructParams; constructParams.OpenOrder = command.OpenOrder; constructParams.CloseOrder = command.CloseOrder; constructParams.ClosedLot = command.ClosedLot; constructParams.OperationType = Framework.OperationType.AsNewRecord; }
private void ValidateLotBalanceCommon(AddOrderRelationCommandBase command) { var openOrder = this.ParseOpenOrder(command); var closedLot = this.ParseClosedLot(command); if (openOrder.LotBalance < closedLot) { throw new TransactionServerException(TransactionError.ExceedOpenLotBalance); } }
private void ParseCommon(AddOrderRelationCommandBase command) { var constructParams = command.ConstructParams; constructParams.Id = Guid.NewGuid(); constructParams.OpenOrder = command.Account.GetOrder(command.OrderRelaitonData.OpenOrderId); constructParams.ClosedLot = command.OrderRelaitonData.ClosedLot; constructParams.CloseOrder = command.CloseOrder; constructParams.OperationType = Framework.OperationType.AsNewRecord; }
private void ValidateLotBalanceCommon(AddOrderRelationCommandBase command) { var openOrder = command.Account.GetOrder(command.OrderRelaitonData.OpenOrderId); var closedLot = command.OrderRelaitonData.ClosedLot; if (openOrder.LotBalance < closedLot) { throw new TransactionServerException(TransactionError.ExceedOpenLotBalance); } }
private void ParseCommon(AddOrderRelationCommandBase command) { var constructParams = command.ConstructParams; constructParams.OpenOrder = this.ParseOpenOrder(command); constructParams.ClosedLot = this.ParseClosedLot(command); constructParams.CloseOrder = command.CloseOrder; if (command.XmlOrderRelation.HasAttribute("CloseTime")) { constructParams.CloseTime = XmlConvert.ToDateTime(command.XmlOrderRelation.Attribute("CloseTime").Value, DateTimeFormat.Xml); } constructParams.OperationType = Framework.OperationType.AsNewRecord; }
private void ValidateCommon(AddOrderRelationCommandBase command) { var openOrder = this.ParseOpenOrder(command); if (openOrder == null) { throw new TransactionServerException(TransactionError.OpenOrderNotExists); } bool isSameAccount = command.Account == openOrder.Owner.Owner; bool isSameInstrument = command.CloseOrder.Owner.SettingInstrument == openOrder.Owner.SettingInstrument; bool isSameDirection = command.CloseOrder.IsBuy == openOrder.IsBuy; if (!isSameAccount || !isSameInstrument || !openOrder.IsOpen || isSameDirection) { throw new TransactionServerException(TransactionError.InvalidOrderRelation); } }
private void ValidatePhysicalLotBalance(AddOrderRelationCommandBase command) { var openOrder = this.ParseOpenOrder(command); var closedLot = this.ParseClosedLot(command); var physicalOpenOrder = (PhysicalOrder)openOrder; if (physicalOpenOrder.PhysicalTradeSide == PhysicalTradeSide.Delivery) { if (physicalOpenOrder.DeliveryLockLot < closedLot) { throw new TransactionServerException(TransactionError.ExceedOpenLotBalance); } } else { if (physicalOpenOrder.LotBalance < closedLot) { throw new TransactionServerException(TransactionError.ExceedOpenLotBalance); } } }
private void ValidateCommon(AddOrderRelationCommandBase command) { var openOrder = command.Account.GetOrder(command.OrderRelaitonData.OpenOrderId); if (openOrder == null) { throw new TransactionServerException(TransactionError.OpenOrderNotExists); } bool isSameAccount = command.Account == openOrder.Owner.Owner; bool isSameInstrument = command.CloseOrder.Owner.SettingInstrument == openOrder.Owner.SettingInstrument; bool isSameDirection = command.CloseOrder.IsBuy == openOrder.IsBuy; if (!isSameAccount || !isSameInstrument || !openOrder.IsOpen || isSameDirection) { StringBuilder sb = new StringBuilder(); if (!isSameAccount) { sb.AppendFormat("is not the same account, close order account id = {0}, open order account id = {1}", command.Account.Id, openOrder.Owner.Owner.Id); } if (!isSameInstrument) { var closeInstrument = command.CloseOrder.Owner.SettingInstrument; var openInstrument = openOrder.Owner.SettingInstrument; sb.AppendFormat("is not the same instrument, close order instrument id = {0}, open order instrument id = {1}", closeInstrument.Id, openInstrument.Id); } if (!openOrder.IsOpen) { sb.AppendFormat("open order is not open id = {0}", openOrder.Id); } if (isSameDirection) { sb.AppendFormat("open order and close order is in the same directory isbuy = {0}", openOrder.IsBuy); } throw new TransactionServerException(TransactionError.InvalidOrderRelation, sb.ToString()); } }
private void ParsePhysical(AddOrderRelationCommandBase command) { this.ParseCommon(command); var physicalConstructParams = (PhysicalOrderRelationConstructParams)command.ConstructParams; var dataRowOrderRelation = command.DataRowOrderRelation; if (physicalConstructParams.CloseTime != null) { if (dataRowOrderRelation["PhysicalValueMatureDate"] != DBNull.Value) { physicalConstructParams.PhysicalValueMatureDay = (DateTime)dataRowOrderRelation["PhysicalValueMatureDate"]; } if (dataRowOrderRelation["RealPhysicalValueMatureDate"] != DBNull.Value) { physicalConstructParams.PhysicalValueMatureDay = null;//means the value is unfrozen } physicalConstructParams.OverdueCutPenalty = (decimal)dataRowOrderRelation["OverdueCutPenalty"]; physicalConstructParams.ClosePenalty = (decimal)dataRowOrderRelation["ClosePenalty"]; physicalConstructParams.PayBackPledge = (decimal)dataRowOrderRelation["PayBackPledge"]; physicalConstructParams.PhysicalValue = (decimal)dataRowOrderRelation["PhysicalValue"]; physicalConstructParams.ClosedPhysicalValue = (decimal)dataRowOrderRelation["ClosedPhysicalValue"]; } }
private void ParseOrderRelationCommon(AddOrderRelationCommandBase command) { this.ParseCommon(command); command.CreateOrderRelation(); }
private decimal ParseClosedLot(AddOrderRelationCommandBase command) { return(command.XmlOrderRelation.AttrToDecimal("ClosedLot")); }
private Order ParseOpenOrder(AddOrderRelationCommandBase command) { var openOrderId = command.XmlOrderRelation.AttrToGuid("OpenOrderID"); return(command.Account.GetOrder(openOrderId)); }