public void AbandonQuotePrice(QuotePriceClient quotePrice, QuotePriceForInstrument quotePriceForInstrument, bool isSigle, Button btn) { if (quotePriceForInstrument != null) { List<Answer> quoteQuotations = new List<Answer>(); if (isSigle) { if (quotePrice != null) { quoteQuotations.Add(quotePrice.ToSendQutoPrice()); } } else { quoteQuotations = quotePriceForInstrument.GetSelectedQuotePriceForAccount(); } if (quoteQuotations.Count > 0) { var AbandonQuoteEventLog = new EventLogEntity(Guid.NewGuid()) { //write log }; } //Notify service string exchangeCode = string.Empty; ConsoleClient.Instance.AbandonQuote(quoteQuotations); } }
public static InstrumentClient GetInstrument(QuotePriceClient quotePriceClient) { //Property not empty InstrumentClient instrument = new InstrumentClient(); instrument.Id = quotePriceClient.InstrumentId; instrument.Code = "GBP" + GetCode(); instrument.Origin = "1.1"; instrument.Ask = "1.5"; instrument.Bid = "1.2"; instrument.Denominator = 10; instrument.NumeratorUnit = 1; instrument.MaxAutoPoint = 100; instrument.MaxSpread = 100; //instrument.AlertPoint = 10; instrument.AutoPoint = 1; instrument.Spread = 3; return(instrument); }
void MessageClient_QuotePriceReceived(QuoteMessage quoteMessage) { this.Dispatcher.BeginInvoke((Action<QuoteMessage>)delegate(QuoteMessage result) { //声音处理 MediaManager.PlayMedia(this._Media, MediaManager._EnquiryMediaSource); int waiteTime = 50; //取初始化数据系统参数 Guid customerId = result.CustomerID; //通过CustomerId获取Customer对象 //var customer = this._Customers.SingleOrDefault(P => P.id == customerId); var customer = new Customer(); customer.Id = result.CustomerID; customer.Code = "WF007"; QuotePriceClient quotePriceClient = new QuotePriceClient(result, waiteTime, customer); QuotePriceForInstrument clientQuotePriceForInstrument = null; clientQuotePriceForInstrument = this._ClientQuotePriceForInstrument.SingleOrDefault(P => P.InstrumentClient.Id == quotePriceClient.InstrumentId); if (clientQuotePriceForInstrument == null) { //从内存中获取Instrument //var instrumentEntity = this._Instruments.SingleOrDefault(P => P.InstrumentId == clientQuotePriceForAccount.InstrumentId); clientQuotePriceForInstrument = new QuotePriceForInstrument(); var instrument = this.GetInstrument(quotePriceClient); clientQuotePriceForInstrument.InstrumentClient = instrument; clientQuotePriceForInstrument.Origin = instrument.Origin; clientQuotePriceForInstrument.Adjust = decimal.Parse(instrument.Origin); clientQuotePriceForInstrument.AdjustLot = quotePriceClient.QuoteLot; this._ClientQuotePriceForInstrument.Add(clientQuotePriceForInstrument); } clientQuotePriceForInstrument.OnEmptyQuotePriceClient += new QuotePriceForInstrument.EmptyQuotePriceHandle(ClientQuotePriceForInstrument_OnEmptyClientQuotePriceClient); //clientQuotePriceForInstrument.OnEmptyCheckBoxClient += new QuotePriceForInstrument.EmptyCheckBoxHandle(ClientQuotePriceForInstrument_OnEmptyCheckBoxClient); clientQuotePriceForInstrument.AddNewQuotePrice(quotePriceClient); if (!this._QuoteTimer.IsEnabled) { this._QuoteTimer.Start(); } }, quoteMessage); }
private InstrumentClient GetInstrument(QuotePriceClient quotePriceClient) { //Property not empty InstrumentClient instrument = new InstrumentClient(); instrument.Id = quotePriceClient.InstrumentId; instrument.Code = "GBP" + GetCode(); instrument.Origin = "1.1"; instrument.Ask = "1.5"; instrument.Bid = "1.2"; instrument.Denominator = 10; instrument.NumeratorUnit = 1; instrument.MaxAutoPoint = 100; instrument.MaxSpread = 100; //instrument.AlertPoint = 10; instrument.AutoPoint = 1; instrument.Spread = 3; return instrument; }
public void RemoveSendQuotePrice(QuotePriceClient quotePriceClient) { bool isCurrentQuotePrice = (quotePriceClient.Id == this.QuotePriceForInstrument.QuoteId); this.QuotePriceClients.Remove(quotePriceClient); if (this.QuotePriceClients.Count == 0) { this.QuotePriceForInstrument = null; return; } bool isCurrentInstrument = (quotePriceClient.InstrumentId == this.QuotePriceClients[0].InstrumentId); if (isCurrentInstrument && this.QuotePriceClients.Count > 0) { this.QuotePriceForInstrument.SwitchNewInstrument(this.QuotePriceClients[0],false); this.QuotePriceForInstrument.SumBuyLot -= quotePriceClient.BuyLot; this.QuotePriceForInstrument.SumSellLot -= quotePriceClient.SellLot; } else { this.QuotePriceForInstrument.SwitchNewInstrument(this.QuotePriceClients[0], true); var quotePriceClients = this.QuotePriceClients.Where(P => P.InstrumentId == this.QuotePriceForInstrument.Instrument.Id); foreach (QuotePriceClient entity in quotePriceClients) { this.QuotePriceForInstrument.SumBuyLot += entity.BuyLot; this.QuotePriceForInstrument.SumSellLot += entity.SellLot; } } this.QuotePriceForInstrument.CreateBestPrice(true); }
public void AddSendQuotePrice(QuotePriceClient quotePriceClient) { this.QuotePriceClients.Add(quotePriceClient); if (this.QuotePriceForInstrument == null) { this.QuotePriceForInstrument = new QuotePriceForInstrument(quotePriceClient); if (this.OnBindingQuotePriceUIEvent != null) { this.OnBindingQuotePriceUIEvent(); } } else { bool isCurrentInstrument = (quotePriceClient.InstrumentId == this.QuotePriceForInstrument.Instrument.Id); if (isCurrentInstrument) { this.QuotePriceForInstrument.SumBuyLot += quotePriceClient.BuyLot; this.QuotePriceForInstrument.SumSellLot += quotePriceClient.SellLot; } this.QuotePriceForInstrument.CreateBestPrice(true); } }
public QuotePriceForInstrument(QuotePriceClient quotePriceClient) { this.FirstQuoteUpdate(quotePriceClient); }
internal void SwitchNewInstrument(QuotePriceClient quotePriceClient, bool isResetSumLot) { this.QuoteId = quotePriceClient.Id; this.Instrument = quotePriceClient.Instrument; this.InstrumentCode = this._Instrument.Code; this.Origin = this._Instrument.Origin; this.Ask = this._Instrument.Ask; this.Bid = this._Instrument.Bid; if (isResetSumLot) { this.SumBuyLot = decimal.Zero; this.SumSellLot = decimal.Zero; } this.Lot = quotePriceClient.Lot; this.AnswerLot = this.Lot; this.BSStatus = quotePriceClient.BSStatus; this.AdjustPoint = (decimal)this.Instrument.NumeratorUnit / (decimal)this.Instrument.Denominator; }
public void ProcessQuoteMessage(QuoteMessage quoteMessage) { this.PlaySound(SoundOption.Enquiry); int waiteTime = this._SettingsParameterManager.DealingOrderParameter.EnquiryWaitTime; string exhcangeCode = quoteMessage.ExchangeCode; Guid customerId = quoteMessage.CustomerID; ExchangeSettingManager settingManager = this.GetExchangeSetting(exhcangeCode); Dictionary<Guid, InstrumentClient> instruments = this.GetInstruments(exhcangeCode); Customer customer = settingManager.GetCustomers().SingleOrDefault(P => P.Id == customerId); if (customer == null) return; if (!instruments.ContainsKey(quoteMessage.InstrumentID)) return; InstrumentClient instrument = instruments[quoteMessage.InstrumentID]; QuotePolicyDetail quotePolicy = settingManager.GetQuotePolicyDetail(instrument.Id, customer); ExchangeQuotation quotation = this.GetExchangeQuotation(exhcangeCode, quotePolicy); QuotePriceClient quotePriceClient = new QuotePriceClient(quoteMessage, waiteTime, instrument, customer, quotation); this._QuotePriceClientModel.AddSendQuotePrice(quotePriceClient); App.MainFrameWindow.QuotePriceWindow.ShowQuotePriceWindow(); }
public bool? IsValidPrice(QuotePriceClient quotePriceClient, decimal adjust) { if (quotePriceClient.Origin == null) return false; Price lastOriginPrice = Price.CreateInstance(quotePriceClient.Origin, this.Instrument.NumeratorUnit, this.Instrument.Denominator); string validInt = "^-?\\d+$"; Price originPrice; if (Regex.IsMatch(adjust.ToString(), validInt)) { originPrice = lastOriginPrice + (int)adjust; } else { originPrice = Price.CreateInstance((double)adjust, this.Instrument.NumeratorUnit, this.Instrument.Denominator); } if (originPrice != null) { if (lastOriginPrice != null) { return (Math.Abs(lastOriginPrice - originPrice) > this.Instrument.AlertPoint); } else { return false; } } else { return null; } }
public void ProcessQuoteMessage(QuoteMessage quoteMessage) { int waiteTime = 50; // this.SettingsManager.GetSettingsParameter(quoteMessage.ExchangeCode).ParameterSetting.EnquiryWaitTime; string exhcangeCode = quoteMessage.ExchangeCode; Guid customerId = quoteMessage.CustomerID; Customer customer = this.SettingsManager.GetCustomers().SingleOrDefault(P => P.Id == customerId); if (customer == null) { //get from db return; } if (!this._Instruments.ContainsKey(quoteMessage.InstrumentID)) return; InstrumentClient instrument = this._Instruments[quoteMessage.InstrumentID]; QuotePolicyDetail quotePolicy = this.SettingsManager.GetQuotePolicyDetail(instrument.Id, customer); ExchangeQuotation quotation = this.GetExchangeQuotation(exhcangeCode, quotePolicy); QuotePriceClient quotePriceClient = new QuotePriceClient(quoteMessage, waiteTime, instrument, customer, quotation); this._QuotePriceClientModel.AddSendQuotePrice(quotePriceClient); }
private Answer GetSelectedQuotePriceForAccount(QuotePriceClient quotePrice) { Answer quoteQuotation = quotePrice.ToSendQutoPrice(); quoteQuotation.InstrumentId = this.InstrumentClient.Id; quoteQuotation.TimeStamp = ShareFixedData.GetServiceTime(); return quoteQuotation; }
public void UpdateCurrentPrice(QuotePriceClient quotePriceClient) { quotePriceClient.Origin = this.InstrumentClient.Origin; quotePriceClient.Ask = this.InstrumentClient.Ask; quotePriceClient.Bid = this.InstrumentClient.Bid; }
//Remove QuotePrice public void RemoveSendQuotePrice(QuotePriceClient quotePriceClient) { this._QuotePriceClients.Remove(quotePriceClient); if (this._QuotePriceClients.Count == 0) { this.OnEmptyQuotePriceClient(this); } }
public void AdjustCurrentPrice(decimal adjust, QuotePriceClient quotePriceClient, bool isAdjustInstrument) { Quotation quotation = Quotation.Create((double)adjust, double.Parse(quotePriceClient.Origin), this.InstrumentClient.NumeratorUnit.Value, this.InstrumentClient.Denominator.Value, this.InstrumentClient.AutoPoint.Value, this.InstrumentClient.Spread.Value); if (isAdjustInstrument) { this.Origin = quotation.Origin; this.Adjust = decimal.Parse(quotation.Origin); } quotePriceClient.Origin = quotation.Origin; quotePriceClient.Ask = quotation.Ask; quotePriceClient.Bid = quotation.Bid; }
public void AddNewQuotePrice(QuotePriceClient quotePriceClient) { var existEntity = this.QuotePriceClients.SingleOrDefault(P => P.InstrumentId == quotePriceClient.InstrumentId && P.CustomerId == quotePriceClient.CustomerId); if (existEntity != null) { existEntity.AdjustSingle = existEntity.AdjustSingle; existEntity.CustomerId = existEntity.CustomerId; existEntity.InstrumentId = existEntity.InstrumentId; existEntity.QuoteLot = existEntity.QuoteLot; existEntity.IsSelected = existEntity.IsSelected; existEntity.TimeStamp = existEntity.TimeStamp; existEntity.WaitTimes = existEntity.WaitTimes; existEntity.Ask = this.InstrumentClient.Ask; existEntity.Bid = this.InstrumentClient.Bid; existEntity.Origin = this.InstrumentClient.Origin; } else { quotePriceClient.Ask = this.InstrumentClient.Ask; quotePriceClient.Bid = this.InstrumentClient.Bid; quotePriceClient.Origin = this.InstrumentClient.Origin; this._QuotePriceClients.Add(quotePriceClient); } }
private void SendQuotePrice(QuotePriceClient quotePrice, QuotePriceForInstrument quotePriceForInstrument, bool isSingle, Button btn) { if (quotePriceForInstrument != null) { List<Answer> ToSendQutoPrices = new List<Answer>(); if (isSingle) { if (quotePrice != null) { ToSendQutoPrices.Add(quotePrice.ToSendQutoPrice()); } } else { ToSendQutoPrices = quotePriceForInstrument.GetSelectedQuotePriceForAccount(); } if (ToSendQutoPrices.Count > 0) { var ConfirmedQuoteEventLog = new EventLogEntity(Guid.NewGuid()) { //Write Log }; object[] abandonStatus = new object[] { ConfirmedQuoteEventLog, btn }; ConsoleClient.Instance.SendQuotePrice(ToSendQutoPrices); } } }
internal void FirstQuoteUpdate(QuotePriceClient quotePriceClient) { this._QuoteId = quotePriceClient.Id; this._Instrument = quotePriceClient.Instrument; this._InstrumentCode = this._Instrument.Code; this._Origin = quotePriceClient.ExchangeQuotation.Origin; this._Ask = quotePriceClient.ExchangeQuotation.Ask; this._Bid = quotePriceClient.ExchangeQuotation.Bid; this._SumBuyLot = quotePriceClient.BuyLot; this._SumSellLot = quotePriceClient.SellLot; this._Lot = quotePriceClient.Lot; this._AnswerLot = this._Lot; this._AdjustLot = this._Lot; this._BSStatus = quotePriceClient.BSStatus; this._AdjustPoint = (decimal)this.Instrument.NumeratorUnit / (decimal)this.Instrument.Denominator; this.CreateBestPrice(true); this.SettingBackGround(); }