Beispiel #1
0
 bool hasStickers(NewItem item)
 {
     if (isSouvenir(item.i_market_name))
     {
         return(false);
     }
     return(!__emptystickered__.NoStickers(item.i_classid, item.i_instanceid));
 }
Beispiel #2
0
        public bool WantToBuy(NewItem item)
        {
            if (stopbuy)
            {
                return(false);
            }
            if (!hasStickers(item))
            {
                //we might want to manipulate it.
                string id = item.i_classid + "_" + item.i_instanceid;
                if (!ManipulatedItems.TryGetValue(id, out int price))
                {
                    return(false);
                }
                return(price < item.ui_price + 10);
            }

            if (!L1(item))
            {
                return(false);
            }
            __database__.EnterReadLock();
            CurrentItemsLock.EnterReadLock();
            try {
                if (!__database__.newDataBase.TryGetValue(item.i_market_name, out BasicSalesHistory salesHistory))
                {
                    return(false);
                }
                if (newBuyFormula != null && newBuyFormula.IsRunning())
                {
                    if (item.ui_price < newBuyFormula.WantToBuy * salesHistory.GetMedian() &&
                        salesHistory.GetMedian() - item.ui_price > 1000 &&
                        salesHistory.GetCnt() >= Consts.MINSIZE)
                    {
                        return(true); //back to good ol' dayz
                    }
                }

                if (!currentItems.TryGetValue(item.i_market_name, out List <int> prices))
                {
                    return(false);
                }
                //if (item.ui_price < 40000 && salesHistory.cnt >= MINSIZE && item.ui_price < 0.8 * salesHistory.median && salesHistory.median - item.ui_price > 600 && !blackList.Contains(item.i_market_name))

                //else
                {
                    if (prices.Count >= 6 &&
                        item.ui_price < WANT_TO_BUY * prices[2] &&
                        salesHistory.GetCnt() >= Consts.MINSIZE &&
                        prices[2] < salesHistory.GetMedian() * 1.2 &&
                        prices[2] - item.ui_price > 1000)
                    {
                        Log.Info("Going to buy " + item.i_market_name + ". Expected profit " +
                                 (salesHistory.GetMedian() - item.ui_price));
                        return(true);
                    }
                }
            } finally {
                __database__.ExitReadLock();
                CurrentItemsLock.ExitReadLock();
            }

            return(false);
        }
Beispiel #3
0
        bool ParseNewDatabase()
        {
            try {
                try {
                    string[] lines;
                    {
                        JObject things =
                            JObject.Parse(
                                Utility.Request.Get("https://market.csgo.com/itemdb/current_730.json"));
                        string db = (string)things["db"];
                        lines = Utility.Request.Get("https://market.csgo.com/itemdb/" + db).Split('\n');
                    }
                    string[] indexes = lines[0].Split(';');
                    int      id      = 0;

                    if (NewItem.mapping.Count == 0)
                    {
                        foreach (var str in indexes)
                        {
                            NewItem.mapping[str] = id++;
                        }
                    }
                    Dictionary <string, List <int> > currentItemsCache = new Dictionary <string, List <int> >();

                    for (id = 1; id < lines.Length - 1; ++id)
                    {
                        string[] item = lines[id].Split(';');
                        if (item[NewItem.mapping["c_stickers"]] == "0")
                        {
                            AddEmptyStickered(long.Parse(item[NewItem.mapping["c_classid"]]), long.Parse(item[NewItem.mapping["c_instanceid"]]));
                        }
                        // new logic
                        else
                        {
                            String name = item[NewItem.mapping["c_market_name"]];
                            if (name.Length >= 2)
                            {
                                name = name.Remove(0, 1);
                                name = name.Remove(name.Length - 1);
                            }
                            else
                            {
                                continue;
                            }

                            if (!currentItemsCache.ContainsKey(name))
                            {
                                currentItemsCache.Add(name, new List <int>());
                            }
                            if (int.TryParse(item[NewItem.mapping["c_price"]], out int val))
                            {
                                currentItemsCache[name].Add(val);
                            }
                            else
                            {
                                Log.Warn($"{item[NewItem.mapping["c_price"]]} doesnt seem like a valid price");
                            }
                        }
                    }
                    CurrentItemsLock.EnterWriteLock();
                    this.currentItems = currentItemsCache;
                    SortCurrentItems();
                    CurrentItemsLock.ExitWriteLock();

                    // Calling WantToBuy function for all items.
                    indexes = lines[0].Split(';');
                    id      = 0;
                    for (id = 1; id < lines.Length - 1; ++id)
                    {
                        string[] itemInString = lines[id].Split(';');
                        NewItem  newItem      = new NewItem(itemInString);
                        //if (newItem.i_market_name == "") {
                        //    Log.Info("Item has no name");
                        //}
                        if (WantToBuy(newItem))
                        {
                            Protocol.Buy(newItem);
                        }
                    }
                } catch (Exception ex) {
                    Log.Error("Some error occured. Message: " + ex.Message + "\nTrace: " + ex.StackTrace);
                }
                return(true);
            } catch (Exception e) {
                Log.Error(e.Message);
                return(false);
            }
        }
Beispiel #4
0
 public bool L1(NewItem item)
 {
     return(item.ui_price < 400000L && !blackList.Contains(item.i_market_name));
 }