public void AddPrice(PricingResponse price) { Prices.Add(price); var pricingResponseEventHandler = PricingResponseAdded; var args = new PricingResponseEventArgs { QuoteId = price.QuoteId, Amount = price.Amount, LastSpotBid = price.LastSpotBid, LastSpotAsk = price.LastSpotAsk, NearBidPoints = price.NearBidPoints, NearAskPoints = price.NearAskPoints, NearAllInBid = price.NearAllInBid, NearAllInAsk = price.NearAllInAsk, FarBidPoints = price.FarBidPoints, FarAskPoints = price.FarAskPoints, FarAllInBid = price.FarAllInBid, FarAllInAsk = price.FarAllInAsk }; if (pricingResponseEventHandler != null) { pricingResponseEventHandler(this, args); } }
private void ExtractQuoteData(string requestId, IEnumerable <Tuple <int, string> > tags) { var quoteId = string.IsNullOrEmpty(_nearBidPrices.Item5) ? "" : _nearBidPrices.Item5; var nearBidSpot = _nearBidPrices.Item2; var nearBidPoints = _nearBidPrices.Item3; var nearBidAll = _nearBidPrices.Item4; var nearAskSpot = _nearAskPrices.Item2; var nearAskPoints = _nearAskPrices.Item3; var nearAskAll = _nearAskPrices.Item4; var farBidSpot = _farBidPrices.Item2; var farBidPoints = _farBidPrices.Item3; var farBidAll = _farBidPrices.Item4; var farAskSpot = _farAskPrices.Item2; var farAskPoints = _farAskPrices.Item3; var farAskAll = _farAskPrices.Item4; decimal parseValue; var nearQuantity = decimal.TryParse(txtNearAmount.Text, out parseValue) ? parseValue : 0M; var farQuantity = decimal.TryParse(txtFarAmount.Text, out parseValue) ? parseValue : 0M; int remainingTime = -1; foreach (var tag in tags) { switch (tag.Item1) { case 117: quoteId = tag.Item2; break; case 132: nearBidAll = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 6050: farBidAll = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 188: nearBidSpot = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; farBidSpot = nearBidSpot; break; case 189: nearBidPoints = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 642: farBidPoints = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 133: nearAskAll = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 6051: farAskAll = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 190: nearAskSpot = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; farAskSpot = nearAskSpot; break; case 191: nearAskPoints = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 643: farAskPoints = decimal.TryParse(tag.Item2, out parseValue) ? parseValue : 0M; break; case 6256: remainingTime = decimal.TryParse(tag.Item2, out parseValue) ? (int)parseValue : 0; break; } } _nearBidPrices = new Tuple <decimal, decimal, decimal, decimal, string>(nearQuantity, nearBidSpot, nearBidPoints, nearBidAll, quoteId); _nearAskPrices = new Tuple <decimal, decimal, decimal, decimal, string>(nearQuantity, nearAskSpot, nearAskPoints, nearAskAll, quoteId); _farBidPrices = new Tuple <decimal, decimal, decimal, decimal, string>(farQuantity, farBidSpot, farBidPoints, farBidAll, quoteId); _farAskPrices = new Tuple <decimal, decimal, decimal, decimal, string>(farQuantity, farAskSpot, farAskPoints, farAskAll, quoteId); remainingQuotingTime = remainingTime; var pricingResponseHandler = OnPricingResponse; var pricingResponseEventArgs = new PricingResponseEventArgs() { RequestId = requestId, QuoteId = quoteId, LastSpotBid = nearBidSpot, LastSpotAsk = nearAskSpot, NearBidPoints = nearBidPoints, NearAskPoints = nearAskPoints, NearAllInBid = nearBidAll, NearAllInAsk = nearAskAll, FarBidPoints = farBidPoints, FarAskPoints = farAskPoints, FarAllInBid = farBidAll, FarAllInAsk = farAskAll, RemainingTime = remainingTime }; if (pricingResponseHandler != null) { pricingResponseHandler(this, pricingResponseEventArgs); } }