Beispiel #1
0
		/// <summary>
		/// To download information about exchange instruments.
		/// </summary>
		/// <param name="market">Exchange.</param>
		/// <returns>Securities.</returns>
		public IEnumerable<Product> DownloadProducts(Market market) //Страница  Market
		{
			if (market == null)
				throw new ArgumentNullException(nameof(market));

			var page = 1;

			while (true)
			{
				var url = "https://www.interactivebrokers.com.hk/en/?f=%2Fen%2Ftrading%2Fexchanges.php%3Fexch%3D"
					+ market.Id + "%26amp%3Bshowcategories%3DSTK%26amp%3Bshowproducts%3D%26amp%3Bsequence_idx%3D"
					+ page + "00%26amp%3Bsortproducts%3D%26amp%3Bib_entity%3Dhk#show";

				var restxt = MakeRequest(url);

				if (restxt.ContainsIgnoreCase("No result for this combination"))
					yield break;

				page++;

				var body = restxt.Substrings("<h2>Stocks</h2>", "</table>")[0];
				var stocks = body.Substrings("<tr class=\"linebottom\">", "</tr>");

				foreach (var t in stocks)
				{
					yield return new Product
					{
						ContractId = t.Substrings("&conid=", "'")[0].To<long>(),
						Name = t.Substrings(";\">", "</a>")[0]
					};
				}
			}
		}
Beispiel #2
0
		//private string cururl;

		private static Market DownloadMarket(string marketPage, string country) //Страница  Market
		{
			if (marketPage.ContainsIgnoreCase("comm_table_content lineRightGray"))
				country = marketPage.Substrings("<br><b>", "</b>")[0];

			var market = new Market
			{
				Country = country,
				Name = marketPage.Substrings("ib_entity=hk\">", "</a>")[0],
				//Products = marketPage.Replace("\n", "").Substrings("</a></td><td align='left' valign='top' class='lineRightGray comm_table_content'>", "<br>")[0],
				Id = marketPage.ContainsIgnoreCase("showcategories")
					? marketPage.Substrings("exchanges.php?exch=", "&showcategories")[0]
					: marketPage.Substrings("etfs.php?exch=", "&ib_entity")[0],
				Hours = marketPage.Substrings("comm_table_content'>", "</td>")[2]
			};

			return market;
			//if (!IsMarket(market.Id, markets))
			//	markets.Add(market);
		}