Ejemplo n.º 1
0
 /// <summary>
 ///     Generate the Market Statistics
 /// </summary>
 public static void GenerateMarketStats()
 {
     MarketStatsValue[0]  = Symbol;
     MarketStatsValue[1]  = DataPeriodToString(Period);
     MarketStatsValue[2]  = Bars.ToString(CultureInfo.InvariantCulture);
     MarketStatsValue[3]  = Update.ToString(Df);
     MarketStatsValue[4]  = Update.ToString("HH:mm");
     MarketStatsValue[5]  = Time[0].ToString(Df);
     MarketStatsValue[6]  = Time[0].ToString("HH:mm");
     MarketStatsValue[7]  = MinPrice.ToString(CultureInfo.InvariantCulture);
     MarketStatsValue[8]  = MaxPrice.ToString(CultureInfo.InvariantCulture);
     MarketStatsValue[9]  = AverageGap + " " + Language.T("points");
     MarketStatsValue[10] = MaxGap + " " + Language.T("points");
     MarketStatsValue[11] = AverageHighLow + " " + Language.T("points");
     MarketStatsValue[12] = MaxHighLow + " " + Language.T("points");
     MarketStatsValue[13] = AverageCloseOpen + " " + Language.T("points");
     MarketStatsValue[14] = MaxCloseOpen + " " + Language.T("points");
     MarketStatsValue[15] = DaysOff.ToString(CultureInfo.InvariantCulture);
     MarketStatsValue[16] = Configs.MaxBars.ToString(CultureInfo.InvariantCulture);
     MarketStatsValue[17] = Configs.UseStartTime
                                ? Configs.DataStartTime.ToShortDateString()
                                : Language.T("No limits");
     MarketStatsValue[18] = Configs.UseEndTime
                                ? Configs.DataEndTime.ToShortDateString()
                                : Language.T("No limits");
     MarketStatsValue[19] = Configs.FillInDataGaps ? Language.T("Accomplished") : Language.T("Switched off");
     MarketStatsValue[20] = Configs.CutBadData ? Language.T("Accomplished") : Language.T("Switched off");
 }
Ejemplo n.º 2
0
        public void CheckPriceRange(string catalogLink)
        {
            WebDriver.GetDriver().Navigate().GoToUrl(catalogLink);
            Log.Info("Go to catalog " + catalogLink);

            Log.Info("Wait untill catalog header is visible");
            WebDriver.WaitUntilElementIsVisible(CatalogPage.Get().CatalogHeader);
            Log.Info("catalog header is visible");

            Log.Info("Set min price");
            CatalogPage.Get().PriceFromInput.SendKeys(MinPrice.ToString());

            Log.Info("Set max price");
            CatalogPage.Get().PriceToInput.SendKeys(MaxPrice.ToString());

            Thread.Sleep(2000);

            Log.Info("Wait untill search tag is visible");
            WebDriver.WaitUntilElementIsVisible(CatalogPage.Get().SearchTag);
            Log.Info("search tag is visible");

            Log.Info("enumerate prices");
            foreach (var value in CatalogPage.Get().Prices)
            {
                string text = value.Text;
                int    pos  = text.IndexOf("руб");
                text = text.Substring(0, pos).Replace(" ", "");

                int price = int.Parse(text);

                Assert.That(price >= MinPrice && price <= MaxPrice, $"price {price} out of range {MinPrice} - {MaxPrice}");
            }
        }
Ejemplo n.º 3
0
        public override string ToString()
        {
            var          str = new StringBuilder();
            const string sep = "; ";

            str.Append(CustomUrl); str.Append(sep);
            str.Append(SearchText); str.Append(sep);
            str.Append(MinPrice.ToString()); str.Append(sep);
            str.Append(MaxPrice.ToString()); str.Append(sep);
            str.Append(Currency); str.Append(sep);
            str.Append(ShipCountry); str.Append(sep);
            str.Append(SortType); str.Append(sep);
            return(str.ToString());
        }
Ejemplo n.º 4
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value == null)
            {
                return(new ValidationResult(true, null));
            }
            decimal price;

            if (!Decimal.TryParse(value.ToString(), NumberStyles.Any, cultureInfo, out price))
            {
                return(new ValidationResult(false, "Invalid Characters Entered"));
            }
            if (price < MinPrice || price > MaxPrice)
            {
                return(new ValidationResult(false, "Not in the correct range of " + MinPrice.ToString("C") + " to " + MaxPrice.ToString("C")));
            }
            return(new ValidationResult(true, null));
        }
Ejemplo n.º 5
0
        protected override void DoUpdate()
        {
            var form = new HtmlForm("/i.html");

            form.Inputs["_ipg"]             = "50";
            form.Inputs["_in_kw"]           = "1";
            form.Inputs["_ex_kw"]           = "";
            form.Inputs["_sacat"]           = "See-All-Categories";
            form.Inputs["_nkw"]             = Search;
            form.Inputs["_okw"]             = Search;
            form.Inputs["_oexkw"]           = "";
            form.Inputs["_udlo"]            = "";
            form.Inputs["_udhi"]            = "";
            form.Inputs["_sabdlo"]          = "";
            form.Inputs["_sabdhi"]          = "";
            form.Inputs["_samilow"]         = "";
            form.Inputs["_samihi"]          = "";
            form.Inputs["_sabdlo"]          = "";
            form.Inputs["LH_SALE_CURRENCY"] = "0";
            form.Inputs["_dmd"]             = "1";
            form.Inputs["_fpos"]            = "Zip code";

            if (MinPrice != 0 || MaxPrice != 0)
            {
                form.Inputs["_udlo"]      = MinPrice.ToString();
                form.Inputs["_udhi"]      = MaxPrice.ToString();
                form.Inputs["_mPrRngCbx"] = "1";
            }

            var now = DateTime.UtcNow;

            var url     = "http://shop.ebay.com" + form.Action + "?" + Http.MakeQueryString(form.Inputs);
            var results = Html.Get(url);
            var lviews  = results.SelectNodes("//table[@class='lview nol']");

            if (lviews == null || lviews.Count == 0)
            {
                Console.WriteLine("No items?");
                return;
            }

            foreach (var lview in lviews)
            {
                var ttl = lview.SelectSingleNode(".//div[@class='ttl']/a");
                if (ttl == null)
                {
                    continue;
                }

                var itemUrl = Html.ReplaceHtmlEntities(ttl.Attributes["href"].Value.Trim());
                var title   = ttl.InnerText.Trim();
                if (title.Length == 0)
                {
                    continue;
                }

                var msg = GetMessageByRawId(itemUrl);
                msg.Url = itemUrl;

                //
                // Parse the price
                //
                var buyNowPrice = "";
                var curPrice    = "";
                var bprice      = lview.SelectSingleNode(".//td[@class='prices']/div[position()=2]");
                if (bprice != null)
                {
                    buyNowPrice = bprice.InnerText;
                }
                var price = lview.SelectSingleNode(".//td[@class='prices g-b']");
                if (price == null)
                {
                    price = lview.SelectSingleNode(".//div[@class='g-b']");
                }
                if (price != null)
                {
                    curPrice = price.InnerText;
                }

                msg.Subject = title;
                if (curPrice != "")
                {
                    msg.Subject += " - " + curPrice;
                }

                if (buyNowPrice != "")
                {
                    msg.Subject += " (" + buyNowPrice + ")";
                }

                //
                // Parse the close date
                //
                var tds = lview.SelectNodes(".//tr/td");
                foreach (var td in tds)
                {
                    var c = td.Attributes["class"];
                    if (c == null)
                    {
                        continue;
                    }
                    if (c.Value.StartsWith("time"))
                    {
                        msg.PublishTime = now + ParseTime(Html.ReplaceHtmlEntities(td.InnerText));
                    }
                }

                //
                // Get the body
                //
                if (msg.BodyHtml.Length == 0)
                {
                    try {
                        var m       = ItemIdRe.Match(msg.Url);
                        var itemId  = m.Groups[1].Value;
                        var descUrl = string.Format("http://vi.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item={0}&bv=safari&t=0&js=-1",
                                                    itemId);
                        msg.BodyHtml = Http.Get(descUrl);
                    }
                    catch (Exception) {
                    }
                }

                Save(msg);
            }
        }
Ejemplo n.º 6
0
        public override string GetFilterName()
        {
            string baseFilerName = base.GetFilterName();

            return($"{baseFilerName}{OnlyAvailability.ToString() ?? "_"}{OnlySale.ToString() ?? "_"}{MinPrice.ToString() ?? "_"}{MaxPrice.ToString() ?? "_"}");
        }