예제 #1
0
        public void UpdateSellOrder(DirectOrder order, List<DirectOrder> sellOrders, List<DirectOrder> buyOrders)
        {
            if (order == null)
                return;

            DirectOrder highestBuyOrder = buyOrders.OrderByDescending(o => o.Price).FirstOrDefault(o => o.StationId == order.StationId);
            DirectOrder lowestSellOrder = sellOrders.OrderBy(o => o.Price).FirstOrDefault(o => o.StationId == order.StationId);

            if (lowestSellOrder != null && lowestSellOrder.Price <= order.Price && lowestSellOrder.OrderId != order.OrderId)
            {
                double priceDifference = order.Price - lowestSellOrder.Price;
                double priceDifferencePct = priceDifference / order.Price;
                double price = double.Parse((decimal.Parse(lowestSellOrder.Price.ToString()) - 0.01m).ToString());

                bool UpdateOrder = false;

                if (priceDifferencePct < 0.05 && priceDifference < 5000000)
                    UpdateOrder = true;
                else if (highestBuyOrder != null && lowestSellOrder.Price / highestBuyOrder.Price >= 1.5 && priceDifferencePct < 0.25)
                    UpdateOrder = true;

                if (UpdateOrder == true)
                {
                    Logging.Log("UpdateOrder:UpdateSellOrder", "Modifying order  for Order Id - " + order.OrderId + " Price - " + price, Logging.White);
                    bool success = order.ModifyOrder(price);
                }
            }
        }
예제 #2
0
        public void UpdateBuyOrder(DirectOrder order, List<DirectOrder> sellOrders, List<DirectOrder> buyOrders)
        {
            if (order == null)
                return;

            DirectOrder highestBuyOrder = buyOrders.OrderByDescending(o => o.Price).FirstOrDefault(o => o.StationId == order.StationId);
            DirectOrder lowestSellOrder = sellOrders.OrderBy(o => o.Price).FirstOrDefault(o => o.StationId == order.StationId);

            double profit = lowestSellOrder.Price - highestBuyOrder.Price;
            double tax = lowestSellOrder.Price * .01 + highestBuyOrder.Price * 0.015;
            double profitPct = lowestSellOrder.Price / highestBuyOrder.Price;

            if (highestBuyOrder != null && lowestSellOrder != null && ((profit < 10000000 && profitPct < 1.25) || (profit >= 10000000 && tax > profit * 0.5)))
            {
                Logging.Log("UpdateAllOrders:Process", "Canceling order for Order Id - " + order.OrderId, Logging.White);
                order.CancelOrder();
            }
            // Don't modify if there isn't a lowest order and don't modify if the lowest order is our own
            else if (highestBuyOrder != null && highestBuyOrder.OrderId != order.OrderId && highestBuyOrder.Price >= order.Price)
            {
                double priceDifference = highestBuyOrder.Price - order.Price;
                double priceDifferencePct = priceDifference / order.Price;
                double price = double.Parse((decimal.Parse(highestBuyOrder.Price.ToString()) + 0.01m).ToString());

                bool createUpdateOrder = false;

                if (priceDifferencePct < 0.05 && priceDifference < 5000000)
                    createUpdateOrder = true;
                else if (lowestSellOrder != null && lowestSellOrder.Price / highestBuyOrder.Price >= 1.5 && priceDifferencePct < 0.25)
                    createUpdateOrder = true;

                if (createUpdateOrder == true)
                {
                    Logging.Log("UpdateAllOrders:Process", "Modifying order for Order Id - " + order.OrderId + " Price - " + price, Logging.White);
                    bool success = order.ModifyOrder(price);
                }
            }
        }