Exemple #1
0
        private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
        {
            // Do not make price higher if we are already on top of the list (first alive).
            // Consider fixed orders.
            foreach (Order O in AllOrders)
            {
                if (!O.Alive)
                {
                    continue;
                }
                if (O.OrderType == 1)
                {
                    continue;
                }
                if (O == MyOrder)
                {
                    return(false);
                }
                else
                {
                    break;
                }
            }

            // Do not increase price, if we already have price higher or equal compared to minimal price.
            if (MyOrder.Price >= (MinimalPrice - 0.00001))
            {
                return(false);
            }

            if (MaxPrice >= MinimalPrice)
            {
                // We can set higher price.
                LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MinimalPrice.ToString("F4"));
                double NewP = MyOrder.SetPrice(MinimalPrice);
                if (NewP > 0)
                {
                    MyOrder.Price = NewP;
                }

                return(true);
            }
            else if (MyOrder.Price < MaxPrice)
            {
                // We can at least set price to be MaxPrice
                LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MaxPrice.ToString("F4"));
                double NewP = MyOrder.SetPrice(MaxPrice);
                if (NewP > 0)
                {
                    MyOrder.Price = NewP;
                }

                return(true);
            }

            return(false);
        }
Exemple #2
0
        private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
        {
            // Do not make price higher if we are already on top of the list (first alive).
            // Consider fixed orders.
            foreach (Order O in AllOrders)
            {
                if (!O.Alive)
                {
                    continue;
                }
                if (O.OrderType == 1)
                {
                    continue;
                }
                if (O == MyOrder)
                {
                    return(false);
                }
                else
                {
                    break;
                }
            }

            // Do not increase price, if we already have price higher or equal compared to minimal price.
            if (MyOrder.Price >= (MinimalPrice - 0.0001))
            {
                return(false);
            }

            // Check time if decrase is possible.
            if (IncreaseTime + APIWrapper.PRICE_INCREASE_INTERVAL > DateTime.Now)
            {
                return(true);
            }

            // Определяем границы повышения цены
            double __newPrice = MaxPrice >= MinimalPrice ? MinimalPrice : MaxPrice;
            int    __steps    = (int)Math.Floor((__newPrice - MyOrder.Price) / (APIWrapper.PRICE_DECREASE_STEP[MyOrder.Algorithm] * (-1)));

            if (__steps > 3 && __steps < 20)
            {
                __newPrice = MyOrder.Price - APIWrapper.PRICE_DECREASE_STEP[MyOrder.Algorithm] * 3.0;
            }

            if (__newPrice > MyOrder.Price)
            {
                LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO,
                                     "Setting price order #" + MyOrder.ID + " to " + __newPrice.ToString("F4"));
                double NewP = MyOrder.SetPrice(__newPrice);
                if (NewP > 0)
                {
                    MyOrder.Price = NewP;
                }

                IncreaseTime = DateTime.Now;
                return(true);
            }

            return(false);

            /*if (MaxPrice >= MinimalPrice)
             * {
             *  // We can set higher price.
             *  LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MinimalPrice.ToString("F4"));
             *  double NewP = MyOrder.SetPrice(MinimalPrice);
             *  if (NewP > 0) MyOrder.Price = NewP;
             *
             *  return true;
             * }
             * else if (MyOrder.Price < MaxPrice)
             * {
             *  // We can at least set price to be MaxPrice
             *  LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MaxPrice.ToString("F4"));
             *  double NewP = MyOrder.SetPrice(MaxPrice);
             *  if (NewP > 0) MyOrder.Price = NewP;
             *
             *  return true;
             * }
             *
             * return false; */
        }
        private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
        {
            // Do not make price higher if we are already on top of the list (first alive).
            // Consider fixed orders.
            foreach (Order O in AllOrders)
            {
                if (!O.Alive) continue;
                if (O.OrderType == 1) continue;
                if (O == MyOrder) return false;
                else break;
            }

            // Do not increase price, if we already have price higher or equal compared to minimal price.
            if (MyOrder.Price >= MinimalPrice) return false;

            if (MaxPrice >= MinimalPrice)
            {
                // We can set higher price.
                LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MinimalPrice.ToString("F4"));
                double NewP = MyOrder.SetPrice(MinimalPrice);
                if (NewP > 0) MyOrder.Price = NewP;

                return true;
            }
            else if (MyOrder.Price < MaxPrice)
            {
                // We can at least set price to be MaxPrice
                LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MaxPrice.ToString("F4"));
                double NewP = MyOrder.SetPrice(MaxPrice);
                if (NewP > 0) MyOrder.Price = NewP;

                return true;
            }

            return false;
        }