Example #1
0
            int IComparer.Compare(object a, object b)
            {
                MyMarketOrder oa = (MyMarketOrder)a;
                MyMarketOrder ob = (MyMarketOrder)b;

                if (oa.QuantityRemaining > ob.QuantityRemaining)
                {
                    return(1);
                }
                if (oa.QuantityRemaining < ob.QuantityRemaining)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
Example #2
0
        public void EvaluateAndUpdateOrder(MyMarketOrder order)
        {
            Debug.Assert(order != null);
            Log.WriteLog("Trying to evaluate and update order " + order.ID.ToString() + ": " + order.Type.ToString());

            //update evaluate cd
            order.EvaluateCoolDownEndTime = System.DateTime.UtcNow.AddMilliseconds(Config.IntervalOfProcessingSameOrder);

            // get good price
            double RecommendedPrice = _decide.GetRecommendedPrice(order);
            // <0 means we cannot find a obvious best price
            // new price >0?
            if (RecommendedPrice > 0)
            {
                // if already good
                if (RecommendedPrice == order.Price)
                {
                    // need no update -> update state
                    order.Status = OrderStatus.NeedNoUpdate;
                }
                else
                {
                    // TODO check config limit

                    //  Update  -> update state and modify cd /// or hesatate(config restricted)
                    order.Modify(RecommendedPrice);
                    order.Status = OrderStatus.AutoModified;
                }
            }
            else
            {
                order.Status = OrderStatus.Hesitate;
            }

            Log.WriteLog("Done evaluating and updating order " + order.ID.ToString() + ": " + order.Type.ToString());
        }
Example #3
0
        public double GetRecommendedPrice(MyMarketOrder order)
        {
            Log.WriteLog("Trying to find new price for picked order.");

            // get order situation (not mine)
            MarketSituation situation = order.GetMarketSituation();

            if (situation != null)
            {
                // filter orders by distance(currently compete with orders in same station.)
                //Temporaty only compete with same station.
                int StationID = _character.CurrentStationID;

                double HighestBuy = 0;
                List <MarketOrderBase> buyOrders = situation.BuyOrdersInMarket.OrderByDescending(o => o.Price).ToList();
                if (buyOrders.Any())
                {
                    HighestBuy = buyOrders.First().Price;
                    //  InnerSpace.Echo("highest buy" + HighestBuy.ToString());
                }

                double LowestSell = 0;
                List <MarketOrderBase> sellOrders = situation.SellOrdersInMarket.OrderBy(o => o.Price).ToList();
                if (sellOrders.Any())
                {
                    LowestSell = sellOrders.First().Price;
                    // InnerSpace.Echo("lowest sell" + LowestSell.ToString());
                }
                if (HighestBuy != 0 && LowestSell != 0)
                {
                    double score = (LowestSell - HighestBuy) / ((HighestBuy + LowestSell) / 2) * 100;

                    // InnerSpace.Echo("score" + score.ToString());

                    if (score > _config.ValidGapSizeRatio)
                    {
                        if (order.OrderType == OrderType.Sell)
                        {
                            return(LowestSell - 0.01);
                        }
                        else
                        {
                            return(HighestBuy + 0.01);
                        }
                    }
                }

                if (HighestBuy != 0)//means no sell order
                {
                    if (order.OrderType == OrderType.Buy)
                    {
                        return(HighestBuy + 0.01);
                    }
                }

                if (LowestSell != 0)//means no buy order
                {
                    if (order.OrderType == OrderType.Sell)
                    {
                        return(LowestSell - 0.01);
                    }
                }
            }

            Log.WriteLog("Done finding new price for picked order.");
            return(-1);
        }
Example #4
0
        public double GetRecommendedPrice(MyMarketOrder order)
        {
            Log.WriteLog("Trying to find new price for picked order.");

            // get order situation (not mine)
            MarketSituation situation = order.GetMarketSituation();

            if (situation != null)
            {
                // filter orders by distance(currently compete with orders in same station.)
                //Temporaty only compete with same station.
                int StationID = _character.CurrentStationID;

                double HighestBuy = 0;
                List<MarketOrderBase> buyOrders = situation.BuyOrdersInMarket.OrderByDescending(o => o.Price).ToList();
                if (buyOrders.Any())
                {
                    HighestBuy = buyOrders.First().Price;
                    //  InnerSpace.Echo("highest buy" + HighestBuy.ToString());
                }

                double LowestSell = 0;
                List<MarketOrderBase> sellOrders = situation.SellOrdersInMarket.OrderBy(o => o.Price).ToList();
                if (sellOrders.Any())
                {
                    LowestSell = sellOrders.First().Price;
                    // InnerSpace.Echo("lowest sell" + LowestSell.ToString());

                }
                if (HighestBuy != 0 && LowestSell != 0)
                {
                    double score = (LowestSell - HighestBuy) / ((HighestBuy + LowestSell) / 2) * 100;

                    // InnerSpace.Echo("score" + score.ToString());

                    if (score > _config.ValidGapSizeRatio)
                    {
                        if (order.OrderType == OrderType.Sell)
                        {
                            return LowestSell - 0.01;
                        }
                        else
                        {
                            return HighestBuy + 0.01;
                        }
                    }
                }

                if (HighestBuy != 0)//means no sell order
                {
                    if (order.OrderType == OrderType.Buy)
                    {
                        return HighestBuy + 0.01;
                    }
                }

                if (LowestSell != 0)//means no buy order
                {
                    if (order.OrderType == OrderType.Sell)
                    {
                        return LowestSell - 0.01;
                    }
                }
            }

            Log.WriteLog("Done finding new price for picked order.");
            return -1;
        }
Example #5
0
        private void _customRowFormat(object sender, FormatRowEventArgs e)
        {
            MyMarketOrder o = (MyMarketOrder)e.Model;

            //switch (e.DisplayIndex % 5)
            //{
            //    case 0:
            //        e.Item.BackColor = Color.DarkGray;
            //        break;
            //    case 1:
            //        e.Item.BackColor = Color.PaleGreen;
            //        break;
            //    case 2:
            //        e.Item.BackColor = Color.SandyBrown;
            //        break;
            //    case 3:
            //        e.Item.BackColor = Color.LightSkyBlue;
            //        break;
            //    case 4:
            //        e.Item.BackColor = Color.Plum;
            //        break;
            //    default:
            //        break;
            //}


            if (o.Status == OrderStatus.OutOfReach)
            {
                e.Item.ForeColor = Color.LightGray;
                e.Item.BackColor = Color.DarkGray;
            }
            else
            {
                if (!o.IsModifyCoolDownFinished)
                {
                    e.Item.ForeColor = Color.Gray;
                }
                switch (o.Status)
                {
                case OrderStatus.NeedNoUpdate:
                    e.Item.BackColor = Color.PaleGreen;
                    break;

                case OrderStatus.Hesitate:
                    e.Item.BackColor = Color.SandyBrown;
                    break;

                case OrderStatus.AutoModified:
                    e.Item.BackColor = Color.LightSkyBlue;
                    break;

                case OrderStatus.ManuallySpecified:
                    e.Item.BackColor = Color.Plum;
                    break;

                case OrderStatus.Unknown:
                default:
                    break;
                }
            }
        }