public HistoryQuotationAddingControl(InstrumentQuotation instrumentQuotation,Action<HistoryQuotationData> addHistoryQuotation)
        {
            InitializeComponent();
            this._HistoryQuotationData = new HistoryQuotationData();
            this._AddHistoryQuotation = addHistoryQuotation;

            this._HistoryQuotationData.InstrumentId = instrumentQuotation.InstruemtnId;
            this._HistoryQuotationData.InstrumentCode = instrumentQuotation.InstrumentCode;
            this._HistoryQuotationData.ExchangeCode = instrumentQuotation.ExchangeCode;
            this._HistoryQuotationData.Time = instrumentQuotation.TimeSpan;
            InstrumentClient instrument = App.MainFrameWindow.ExchangeDataManager.ExchangeSettingManagers[instrumentQuotation.ExchangeCode].Instruments[instrumentQuotation.InstruemtnId];
            HistoryQuotationInfo info = new HistoryQuotationInfo();
            info.NumeratorUnit = instrument.NumeratorUnit;
            info.Denominator = instrument.Denominator;
            this.Origin.Mask = info.GetMask();
            this.TimeSpan.Value = instrumentQuotation.TimeSpan;
            this.Origin.Value = instrumentQuotation.Origin;
            this.TimeMessage.Text = string.Format("Value must less than {0}", instrumentQuotation.TimeSpan);
        }
 public bool Init()
 {
     try
     {
         ExchangeQuotationViewModel.Instance.InitData();
         if (ExchangeQuotationViewModel.Instance.IsInitData)
         {
             this.Dispatcher.BeginInvoke((Action)delegate()
             {
                 this.QuotationGrid.ItemsSource = ExchangeQuotationViewModel.Instance.Exchanges;
                 InstrumentQuotation ins = new InstrumentQuotation();
                 this.QuotationProperty.SetSource(ExchangeQuotationViewModel.Instance.Exchanges[0]);
                 this.InitExchangeSystemComboBox();
             });
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "ExchangeQuotation.Init is abort.\r\n{0}", ex.ToString());
         return true;
     }
 }
 private void UpdateInstrument(InstrumentQuotationEditType type, InstrumentQuotation instrumentQuotation,int value)
 {
     InstrumentQuotationSet set = new InstrumentQuotationSet();
     set.ExchangeCode = instrumentQuotation.ExchangeCode;
     set.QoutePolicyId = instrumentQuotation.QuotationPolicyId;
     set.InstrumentId = instrumentQuotation.InstruemtnId;
     set.type = type;
     set.Value = value;
     ConsoleClient.Instance.UpdateInstrument(set);
 }
 public static InstrumentQuotation Convert(ExchangeQuotation quote,string exchangeCode)
 {
     InstrumentQuotation instrument = new InstrumentQuotation();
     instrument.ExchangeCode = exchangeCode;
     instrument.QuotationPolicyId = quote.QuotationPolicyId;
     instrument.QuotationPolicyCode = quote.QuotationPolicyCode;
     instrument.Ask = quote.Ask;
     instrument.Bid = quote.Bid;
     instrument.High = quote.High;
     instrument.InstruemtnId = quote.InstruemtnId;
     instrument.InstrumentCode = quote.InstrumentCode;
     instrument.InstrumentOriginCode = quote.OriginInstrumentCode;
     instrument.Low = quote.Low;
     instrument.Origin = quote.Origin;
     instrument.TimeSpan = quote.Timestamp.ToShortTimeString();
     instrument.PriceType = quote.PriceType;
     instrument.AutoAdjustPoints = quote.AutoAdjustPoints1;
     instrument.AutoAdjustPoints2 = quote.AutoAdjustPoints2;
     instrument.AutoAdjustPoints3 = quote.AutoAdjustPoints3;
     instrument.AutoAdjustPoints4 = quote.AutoAdjustPoints4;
     instrument.SpreadPoints = quote.SpreadPoints1;
     instrument.SpreadPoints2 = quote.SpreadPoints2;
     instrument.SpreadPoints3 = quote.SpreadPoints3;
     instrument.SpreadPoints4 = quote.SpreadPoints4;
     instrument.MaxAuotAdjustPoints = quote.MaxAuotAdjustPoints;
     instrument.MaxSpreadPoints = quote.MaxSpreadPoints;
     instrument.IsOriginHiLo = quote.IsOriginHiLo;
     instrument.IsAutoFill = quote.IsAutoFill;
     instrument.IsPriceEnabled = quote.IsPriceEnabled;
     instrument.IsAutoEnablePrice = quote.IsAutoEnablePrice;
     instrument.OrderTypeMask = quote.OrderTypeMask;
     instrument.AcceptLmtVariation = quote.AcceptLmtVariation;
     instrument.AutoDQMaxLot = quote.AutoDQMaxLot;
     instrument.AlertVariation = quote.AlertVariation;
     instrument.DqQuoteMinLot = quote.DqQuoteMinLot;
     instrument.MaxDQLot = quote.MaxDQLot;
     instrument.NormalWaitTime = quote.NormalWaitTime;
     instrument.AlertWaitTime = quote.AlertWaitTime;
     instrument.MaxOtherLot = quote.MaxOtherLot;
     instrument.CancelLmtVariation = quote.CancelLmtVariation;
     instrument.MaxMinAdjust = quote.MaxMinAdjust;
     instrument.PenetrationPoint = quote.PenetrationPoint;
     instrument.PriceValidTime = quote.PriceValidTime;
     instrument.AutoCancelMaxLot = quote.AutoCancelMaxLot;
     instrument.AutoAcceptMaxLot = quote.AutoAcceptMaxLot;
     return instrument;
 }
 public bool Convert(Dictionary<string, ExchangeSettingManager> exchangeSettingManagers)
 {
     if (exchangeSettingManagers.Keys.Count == 0)
     {
         return false;
     }
     if (this._Exchanges.Count > 0)
     {
         return false;
     }
     foreach (string key in exchangeSettingManagers.Keys)
     {
         foreach (Guid quotepolicyId in exchangeSettingManagers[key].ExchangeQuotations.Keys)
         {
             foreach (Guid instrumentId in exchangeSettingManagers[key].ExchangeQuotations[quotepolicyId].Keys)
             {
                 InstrumentQuotation instrument = new InstrumentQuotation();
                 instrument = InstrumentQuotation.Convert(exchangeSettingManagers[key].ExchangeQuotations[quotepolicyId][instrumentId], key);
                 this._Exchanges.Add(instrument);
             }
         }
     }
     if (this._Exchanges.Count == 0)
     {
         return false;
     }
     this.HighLowBatchProcessInfos = new ObservableCollection<UpdateHighLowBatchProcessInfo>();
     return true;
 }
        //public ExchangeQuotationPropertyControl( Action<InstrumentQuotation> setInstrumentQuotation)
        //{
        //    InitializeComponent();
        //    this._SetInstrumentQuotation = setInstrumentQuotation;
        //}
        public void SetSource(InstrumentQuotation source)
        {
            this._IsInit = false;
            this._Source = source;
            var model = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            Binding bind = new Binding("AutoAdjustPoints");
            bind.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoAdjustPoints.SetBinding(XamNumericInput.ValueProperty, bind);
            Binding autoAdjustPoints2 = new Binding("AutoAdjustPoints2");
            autoAdjustPoints2.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoAdjustPoints2.SetBinding(XamNumericInput.ValueProperty, autoAdjustPoints2);
            Binding autoAdjustPoints3 = new Binding("AutoAdjustPoints3");
            autoAdjustPoints3.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoAdjustPoints3.SetBinding(XamNumericInput.ValueProperty, autoAdjustPoints3);
            Binding autoAdjustPoints4 = new Binding("AutoAdjustPoints4");
            autoAdjustPoints4.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoAdjustPoints4.SetBinding(XamNumericInput.ValueProperty, autoAdjustPoints4);

            Binding spreadPoints = new Binding("SpreadPoints");
            spreadPoints.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.SpreadPoints.SetBinding(XamNumericInput.ValueProperty, spreadPoints);
            Binding spreadPoints2 = new Binding("SpreadPoints2");
            spreadPoints2.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.SpreadPoints2.SetBinding(XamNumericInput.ValueProperty, spreadPoints2);
            Binding spreadPoints3 = new Binding("SpreadPoints3");
            spreadPoints3.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.SpreadPoints3.SetBinding(XamNumericInput.ValueProperty, spreadPoints3);
            Binding spreadPoints4 = new Binding("SpreadPoints4");
            spreadPoints4.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.SpreadPoints4.SetBinding(XamNumericInput.ValueProperty, spreadPoints4);

            Binding maxAuotAdjustPoints = new Binding("MaxAuotAdjustPoints");
            maxAuotAdjustPoints.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.MaxAuotAdjustPoints.SetBinding(XamNumericInput.ValueProperty, maxAuotAdjustPoints);
            Binding maxSpreadPoints = new Binding("MaxSpreadPoints");
            maxSpreadPoints.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.MaxSpreadPoints.SetBinding(XamNumericInput.ValueProperty, maxSpreadPoints);

            this.priceType.SelectedItem = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId).PriceType.ToString();

            Binding allowLimit = new Binding("AllowLimit");
            allowLimit.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AllowLomit.SetBinding(CheckBox.IsCheckedProperty, allowLimit);
            Binding isOriginHiLo = new Binding("IsOriginHiLo");
            isOriginHiLo.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.IsOriginHiLo.SetBinding(CheckBox.IsCheckedProperty, isOriginHiLo);
            Binding isAutoFill = new Binding("IsAutoFill");
            isAutoFill.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.IsAutoFill.SetBinding(CheckBox.IsCheckedProperty, isAutoFill);
            Binding IsPriceEnabled = new Binding("IsPriceEnabled");
            IsPriceEnabled.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.IsEnablePrice.SetBinding(CheckBox.IsCheckedProperty, IsPriceEnabled);

            Binding acceptLmtVariation = new Binding("AcceptLmtVariation");
            acceptLmtVariation.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AcceptLmtVariation.SetBinding(XamNumericInput.ValueProperty, acceptLmtVariation);
            Binding autoDQMaxLot = new Binding("AutoDQMaxLot");
            autoDQMaxLot.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoDQMaxLot.SetBinding(XamNumericInput.ValueProperty, autoDQMaxLot);
            Binding alertVariation = new Binding("AlertVariation");
            alertVariation.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AlertVariation.SetBinding(XamNumericInput.ValueProperty, alertVariation);
            Binding dqQuoteMinLot = new Binding("DqQuoteMinLot");
            dqQuoteMinLot.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.DqQuoteMinLot.SetBinding(XamNumericInput.ValueProperty, dqQuoteMinLot);
            Binding maxDQLot = new Binding("MaxDQLot");
            maxDQLot.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.MaxDQLot.SetBinding(XamNumericInput.ValueProperty, maxDQLot);
            Binding normalWaitTime = new Binding("NormalWaitTime");
            normalWaitTime.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.NormalWaitTime.SetBinding(XamNumericInput.ValueProperty, normalWaitTime);
            Binding alertWaitTime = new Binding("AlertWaitTime");
            alertWaitTime.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AlertWaitTime.SetBinding(XamNumericInput.ValueProperty, alertWaitTime);
            Binding maxOtherLot = new Binding("MaxOtherLot");
            maxOtherLot.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.MaxOtherLot.SetBinding(XamNumericInput.ValueProperty, maxOtherLot);
            Binding cancelLmtVariation = new Binding("CancelLmtVariation");
            cancelLmtVariation.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.CancelLmtVariation.SetBinding(XamNumericInput.ValueProperty, cancelLmtVariation);
            Binding maxMinAdjust = new Binding("MaxMinAdjust");
            maxMinAdjust.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.MaxMinAdjust.SetBinding(XamNumericInput.ValueProperty, maxMinAdjust);
            Binding penetrationPoint = new Binding("PenetrationPoint");
            penetrationPoint.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.PenetrationPoint.SetBinding(XamNumericInput.ValueProperty, penetrationPoint);
            Binding priceValidTime = new Binding("PriceValidTime");
            priceValidTime.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.PriceValidTime.SetBinding(XamNumericInput.ValueProperty, priceValidTime);
            Binding autoCancelMaxLot = new Binding("AutoCancelMaxLot");
            autoCancelMaxLot.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoCancelMaxLot.SetBinding(XamNumericInput.ValueProperty, autoCancelMaxLot);
            Binding autoAcceptMaxLot = new Binding("AutoAcceptMaxLot");
            autoAcceptMaxLot.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoAcceptMaxLot.SetBinding(XamNumericInput.ValueProperty, autoAcceptMaxLot);
            Binding hitPriceVariationForSTP = new Binding("HitPriceVariationForSTP");
            hitPriceVariationForSTP.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.HitPriceVariationForSTP.SetBinding(XamNumericInput.ValueProperty, hitPriceVariationForSTP);
            Binding autoDQDelay = new Binding("AutoDQDelay");
            autoDQDelay.Source = ExchangeQuotationViewModel.Instance.Exchanges.SingleOrDefault(i => i.ExchangeCode == source.ExchangeCode && i.QuotationPolicyId == source.QuotationPolicyId && i.InstruemtnId == source.InstruemtnId);
            this.AutoDQDelay.SetBinding(XamNumericInput.ValueProperty, autoDQDelay);
            this._IsInit = true;
        }