private void UpdateQuotes(object state) { var parameters = (QuotingParameters)state; if (Sync.ConsolePauseEvent.WaitOne(0, false)) { BroadcastStatusMessage(parameters.ConnectionId, "Paused"); } else { BroadcastStatusMessage(parameters.ConnectionId, "Processing"); try { var pairNames = _customerInfo.GetListOfPairNames(parameters.CustomerId); foreach (var p in pairNames) { var r = _ratesService.GetRate(p); if (r != null) { var spread = _spreadProvider.GetSpread(r.PairName, parameters.CustomerId); var cp = new CurrencyPair(); cp.PairName = r.PairName; cp.Bid = r.Bid - spread.SpreadBid; cp.Ask = r.Ask - spread.SpreadAsk; cp.SpreadBid = spread.SpreadBid; cp.SpreadAsk = spread.SpreadAsk; BroadcastMarketPrice(cp, parameters.ConnectionId); } } } catch (Exception e) { _wrapper.Log.Error(e.Message); Console.WriteLine(e.Message); } } }
public Spread GetSpread(string pairName, int customerId) { var spread = new Spread(); try { spread = _provider.GetSpread(pairName, customerId); if (spread == null) { spread = new Spread { SpreadAsk = Decimal.Zero, SpreadBid = Decimal.Zero }; } } catch (Exception e) { _wrapper.Log.Error(e.Message); Console.WriteLine(e.Message); } return(spread); }