コード例 #1
0
 public static void SetInstrumentGuidMapping(this DataSet ds)
 {
     try
     {
         if (ds == null)
         {
             return;
         }
         DataTable table = ds.Tables[InstrumentConstants.InstrumentTableName];
         if (table == null)
         {
             return;
         }
         DataColumn column = new DataColumn();
         column.ColumnName    = InstrumentConstants.IntForIntrumentIDColumnName;
         column.DataType      = typeof(Int32);
         column.AutoIncrement = false;
         table.Columns.Add(column);
         DataRowCollection rowCol = table.Rows;
         for (int rowIndex = 0; rowIndex < rowCol.Count; rowIndex++)
         {
             DataRow dr        = rowCol[rowIndex];
             Guid    id        = (Guid)dr[InstrumentConstants.InstrumentIDColumnName];
             int     mappingId = GuidMapping.Add(id);
             dr[InstrumentConstants.IntForIntrumentIDColumnName] = mappingId;
         }
     }
     catch (Exception ex)
     {
         _Logger.Error(ex);
     }
 }
コード例 #2
0
 private static void Initialize(Instrument instrument, DataRow dataRow)
 {
     instrument.Id                      = (Guid)dataRow["ID"];
     instrument.OriginCode              = (string)dataRow["OriginCode"];
     instrument.Code                    = (string)dataRow["Code"];
     instrument.Description             = (string)dataRow["Description"];
     instrument.Denominator             = (int)dataRow["Denominator"];
     instrument.NumeratorUnit           = (int)dataRow["NumeratorUnit"];
     instrument.CommissionFormula       = (byte)dataRow["CommissionFormula"];
     instrument.TradePLFormula          = (byte)dataRow["TradePLFormula"];
     instrument.OrderTypeMask           = (int)dataRow["OrderTypeMask"];
     instrument.IsNormal                = (bool)dataRow["IsNormal"];
     instrument.MaxDQLot                = dataRow.GetItemValue <decimal>("MaxDQLot", 0);
     instrument.MaxOtherLot             = dataRow.GetItemValue <decimal>("MaxOtherLot", 0);
     instrument.CurrencyId              = (Guid)dataRow["CurrencyID"];
     instrument.PriceValidTime          = (int)dataRow["PriceValidTime"];
     instrument.DqQuoteMinLot           = dataRow.GetItemValue <decimal>("DQQuoteMinLot", 0);
     instrument.IsSinglePrice           = (bool)dataRow["IsSinglePrice"];
     instrument.LastAcceptTimeSpan      = TimeSpan.FromMinutes((int)dataRow["LastAcceptTimeSpan"]);
     instrument.BeginTime               = (DateTime)dataRow["BeginTime"];
     instrument.EndTime                 = (DateTime)dataRow["EndTime"];
     instrument.AcceptDQVariation       = (int)dataRow["AcceptDQVariation"];
     instrument.AcceptLmtVariation      = (int)dataRow["AcceptLmtVariation"];
     instrument.AcceptCloseLmtVariation = (int)dataRow["AcceptCloseLmtVariation"];
     instrument.CancelLmtVariation      = (int)dataRow["CancelLmtVariation"];
     instrument.AcceptIfDoneVariation   = (int)dataRow["AcceptIfDoneVariation"];
     instrument.PriceType               = dataRow["PriceType"].ToEnum <PriceType>();
     //instrument.IsHasDocument = (bool)dataRow["IsHasDocument"];
     instrument.Sequence         = (int)dataRow["Sequence"];
     instrument.DayOpenTime      = dataRow.GetItemValue <DateTime?>("DayOpenTime", null);
     instrument.DayCloseTime     = dataRow.GetItemValue <DateTime?>("DayCloseTime", null);
     instrument.LastDayCloseTime = dataRow.GetItemValue <DateTime?>("LastDayCloseTime", null);
     instrument.NextDayOpenTime  = dataRow.GetItemValue <DateTime?>("NextDayOpenTime", null);
     instrument.MocTime          = dataRow.GetItemValue <DateTime?>("MOCTime", null);
     instrument.LastTradeDay     = dataRow.GetItemValue <DateTime?>("LastTradeDay", null);
     instrument.IsActive         = (bool)dataRow["IsActive"];
     instrument.Category         = dataRow["Category"].ToEnum <InstrumentCategory>();
     instrument.CanPlacePendingOrderAtAnyTime = (bool)dataRow["CanPlacePendingOrderAtAnyTime"];
     if (dataRow.Table.Columns.Contains("ExternalExchangeCode"))
     {
         instrument.ExternalExchangeCode = dataRow.GetItemValue <string>("ExternalExchangeCode", null);
     }
     if (dataRow.Table.Columns.Contains("GroupID"))
     {
         instrument.GroupId = dataRow.GetItemValue <Guid?>("GroupID", null);
     }
     instrument.MarginFormula        = (byte)dataRow["MarginFormula"];
     instrument.SequenceForQuotatoin = GuidMapping.Add(instrument.Id);
     instrument.AllowedNewTradeSides = Convert.ToInt16(dataRow["AllowedNewTradeSides"]);
     instrument.Unit = dataRow.GetItemValue <string>("Unit", "");
     instrument.PhysicalLotDecimal = dataRow.GetItemValue <byte>("PhysicalLotDecimal", 0);
     instrument.Narrative          = dataRow.GetItemValue <string>("Narrative", "");
     instrument.QuoteDescription   = dataRow.GetItemValue <string>("QuoteDescription", "");
     if (dataRow.Table.Columns.Contains("DeliveryTimeBeginDay"))
     {
         instrument.DeliveryTimeBeginDay = dataRow.GetItemValue <int>("DeliveryTimeBeginDay", 0);
     }
     if (dataRow.Table.Columns.Contains("DeliveryTimeEndDay"))
     {
         instrument.DeliveryTimeEndDay = dataRow.GetItemValue <int>("DeliveryTimeEndDay", 0);
     }
     if (dataRow.Table.Columns.Contains("DeliveryPointGroupId") && dataRow["DeliveryPointGroupId"] != DBNull.Value)
     {
         instrument.DeliveryPointGroupId = (Guid)dataRow["DeliveryPointGroupId"];
     }
 }