// S22\AUD/CAD\0.92425\0.92590\0.92930\0.92053\D\A\5\0.92333\$
		// SA\AUD/USD\Bid\Ask\High\Low\D\A\4\Close\$
		public List<CurrencyPair> ParseToCurrencyPair(string message)
		{
			var pairsList = new List<CurrencyPair>();

			if (message.IndexOf('S') == 0)
			{
				message = message.Remove(0, 1);
			}

			var m = Regex.Replace(message, @"\r\n?|\n", Environment.NewLine);
			var list = m.Split('$');

			foreach (var s in list)
			{
				if (!string.IsNullOrEmpty(s) &&
					!s.Contains(Environment.NewLine))
				{
					var p = s.Split('\\');

					if (p.Length == 11)
					{
						try
						{
							var pair = new CurrencyPair();

							var pairId = p[0];
							pair.PairName = p[1];
							pair.Ask = Convert.ToDecimal(p[2]);
							pair.Bid = Convert.ToDecimal(p[3]);
							var high = Convert.ToDecimal(p[4]);
							var low = Convert.ToDecimal(p[5]);
							var close = Convert.ToDecimal(p[9]);

							pairsList.Add(pair);
						}
						catch (Exception ex)
						{
							_wrapper.Log.Error(ex.Message);
						}
					}
					else
					{
						_wrapper.Log.Error("Partial data from data feed");
						Console.WriteLine("Partial data from data feed");
					}
				}
			}

			return pairsList;
		}
		//<table>
		//<tr>
		//<td>EUR/USD</td>
		//<td>1376052534888</td>
		//<td>1.33</td>
		//<td>702</td>
		//<td>1.33</td>
		//<td>710</td>
		//<td>1.33654</td>
		//<td>1.33909</td>
		//<td>1.33810</td>
		//</tr>
		public List<CurrencyPair> ParseToCurrencyPair(string message)
		{
			var pairsList = new List<CurrencyPair>();

			try
			{
				var doc = new HtmlDocument();
				doc.LoadHtml(message);

				var table =
					doc.DocumentNode.SelectSingleNode("//table")
					   .Descendants("tr")
					   .Where(tr => tr.Elements("td").Count() > 1)
					   .Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
					   .ToList();

				foreach (var t in table)
				{
					var pair = new CurrencyPair();

					pair.PairName = t[0];
					pair.Bid = Convert.ToDecimal(t[2] + t[3]);
					pair.Ask = Convert.ToDecimal(t[4] + t[5]);

					var high = Convert.ToDecimal(t[6]);
					var low = Convert.ToDecimal(t[7]);
					var close = Convert.ToDecimal(t[8]);

					pairsList.Add(pair);
				}
			}
			catch (Exception ex)
			{
				_wrapper.Log.Error(ex.Message);
				Console.WriteLine(ex.Message);
			}

			return pairsList;
		}
		private void BroadcastMarketPrice(CurrencyPair pair, string connectionId)
		{
			Clients.Client(connectionId).UpdateMarketPrice(pair);
		}
		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 = _gainCapitalRatesService.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);
				}
			}
		}
		//<Rates>
		//<Rate Symbol="EURUSD">
		//<Bid>1.32803</Bid>
		//<Ask>1.32826</Ask>
		//<High>1.32974</High>
		//<Low>1.3245</Low>
		//<Direction>-1</Direction>
		//<Last>06:36:37</Last>
		//</Rate>
		public List<CurrencyPair> ParseToCurrencyPair(XmlDocument message)
		{
			var pairsList = new List<CurrencyPair>();

			try
			{
				var parentList = message.ChildNodes;
				foreach (XmlNode parentNode in parentList)
				{
					var childList = parentNode.ChildNodes;
					foreach (XmlNode childNode in childList)
					{
						var pair = new CurrencyPair();

						if (childNode.Attributes != null)
						{
							pair.PairName = (childNode.Attributes["Symbol"].Value);
						}

						var nodeBid = childNode["Bid"];
						if (nodeBid != null)
						{
							pair.Bid = Convert.ToDecimal(nodeBid.InnerText);
						}

						var nodeAsk = childNode["Ask"];
						if (nodeAsk != null)
						{
							pair.Ask = Convert.ToDecimal(nodeAsk.InnerText);
						}

						var nodeHigh = childNode["High"];
						if (nodeHigh != null)
						{
							var high = Convert.ToDecimal(nodeHigh.InnerText);
						}

						var nodeLow = childNode["Low"];
						if (nodeLow != null)
						{
							var low = Convert.ToDecimal(nodeLow.InnerText);
						}

						var nodeDir = childNode["Direction"];
						if (nodeDir != null)
						{
							var direction = Convert.ToInt32(nodeDir.InnerText);
						}

						var nodeLast = childNode["Last"];
						if (nodeLast != null)
						{
							var date = Convert.ToDateTime(nodeLast.InnerText);
						}

						pairsList.Add(pair);
					}
				}
			}
			catch (Exception ex)
			{
				_wrapper.Log.Error(ex.Message);
				Console.WriteLine(ex.Message);
			}

			return pairsList;
		}