internal UsableMarginPrice GetRefPriceForUsableMargin(Guid instrumentId, Guid accountId, DateTime tradeDay) { lock (_mutex) { DataRow data = DBRepository.Default.GetRefPriceForUsableMargin(instrumentId, accountId, tradeDay); Price privateBid = PriceHelper.CreatePrice(data.GetColumn <string>("Bid_Private"), instrumentId, tradeDay); Price privateAsk = PriceHelper.CreatePrice(data.GetColumn <string>("Ask_Private"), instrumentId, tradeDay); Price publicBid = PriceHelper.CreatePrice(data.GetColumn <string>("Bid_Public"), instrumentId, tradeDay); Price publicAsk = PriceHelper.CreatePrice(data.GetColumn <string>("Ask_Public"), instrumentId, tradeDay); return(new UsableMarginPrice(privateBid, privateAsk, publicBid, publicAsk)); } }
internal virtual void FillOrderCommonData(Protocal.OrderCommonData orderData, Guid instrumentId, DateTime?tradeDay = null) { this.Id = orderData.Id; this.TradeOption = orderData.TradeOption; this.IsOpen = orderData.IsOpen; this.IsBuy = orderData.IsBuy; this.SetPrice = PriceHelper.CreatePrice(orderData.SetPrice, instrumentId, tradeDay); this.SetPrice2 = PriceHelper.CreatePrice(orderData.SetPrice2, instrumentId, tradeDay); this.SetPriceMaxMovePips = orderData.SetPriceMaxMovePips; this.DQMaxMove = orderData.DQMaxMove; this.Lot = orderData.Lot; this.OriginalLot = orderData.OriginalLot != null ? orderData.OriginalLot.Value : orderData.Lot; this.LotBalance = this.Lot; }
private void ParseCommon(Commands.AddCommunicationCommandBase command) { var constructParams = command.ConstructParams; var bookData = (Protocal.OrderBookData)command.OrderData; constructParams.FillOrderCommonData(bookData, command.InstrumentId, command.TradeDay); constructParams.Code = command.GenerateOrderCode(); constructParams.BlotterCode = base.ParseBlotterCode(command); constructParams.ExecutePrice = PriceHelper.CreatePrice(bookData.ExecutePrice, command.InstrumentId, command.TradeDay); constructParams.OrderBatchInstructionID = bookData.OrderBatchInstructionID; constructParams.OriginCode = bookData.OrginCode; if (!bookData.IsOpen) { this.ValidateForCloseOrder(bookData, constructParams); } }
internal static void ParseForGeneral(this OrderConstructParams constructParams, IDBRow dataRowOrder, Guid instrumentId, Guid accountId, DateTime?tradeDay) { constructParams.Id = (Guid)dataRowOrder["ID"]; if (dataRowOrder["Code"] != DBNull.Value) { constructParams.Code = (string)dataRowOrder["Code"]; } constructParams.BlotterCode = dataRowOrder["BlotterCode"] == DBNull.Value ? null : (string)dataRowOrder["BlotterCode"]; constructParams.Phase = (OrderPhase)(byte)dataRowOrder["Phase"]; constructParams.TradeOption = (TradeOption)(byte)dataRowOrder["TradeOption"]; constructParams.IsOpen = (bool)dataRowOrder["IsOpen"]; constructParams.IsBuy = (bool)dataRowOrder["IsBuy"]; if (dataRowOrder["SetPrice"] != DBNull.Value) { constructParams.SetPrice = PriceHelper.CreatePrice((string)dataRowOrder["SetPrice"], instrumentId, tradeDay); } if (dataRowOrder["ExecutePrice"] != DBNull.Value) { constructParams.ExecutePrice = PriceHelper.CreatePrice((string)dataRowOrder["ExecutePrice"], instrumentId, tradeDay); } if (dataRowOrder["SetPriceMaxMovePips"] != DBNull.Value) { constructParams.SetPriceMaxMovePips = (int)dataRowOrder["SetPriceMaxMovePips"]; } if (dataRowOrder["DQMaxMove"] != DBNull.Value) { constructParams.DQMaxMove = (int)dataRowOrder["DQMaxMove"]; } constructParams.Lot = (decimal)dataRowOrder["Lot"]; constructParams.OriginalLot = (decimal)dataRowOrder["OriginalLot"]; constructParams.LotBalance = (decimal)dataRowOrder["LotBalance"]; constructParams.InterestPerLot = dataRowOrder.GetColumn <decimal>("InterestPerLot"); constructParams.StoragePerLot = dataRowOrder.GetColumn <decimal>("StoragePerLot"); constructParams.HitCount = (short)dataRowOrder["HitCount"]; if (dataRowOrder["InterestValueDate"] != DBNull.Value) { constructParams.InterestValueDate = (DateTime)dataRowOrder["InterestValueDate"]; } if (constructParams.HitCount != 0 && dataRowOrder["BestPrice"] != DBNull.Value) { constructParams.BestPrice = PriceHelper.CreatePrice((string)dataRowOrder["BestPrice"], instrumentId, tradeDay); } if (constructParams.HitCount != 0 && dataRowOrder["BestTime"] != DBNull.Value) { constructParams.BestTime = (DateTime)dataRowOrder["BestTime"]; } if (dataRowOrder["EstimateCloseCommission"] != DBNull.Value) { constructParams.EstimateCloseCommission = (decimal)dataRowOrder["EstimateCloseCommission"]; } if (dataRowOrder["EstimateCloseLevy"] != DBNull.Value) { constructParams.EstimateCloseLevy = (decimal)dataRowOrder["EstimateCloseLevy"]; } }