Example #1
0
        private static void WaitForGoal1(Deal deal)
        {
            var sellOrder = TradeInterface.GetOrderById(deal.Symbol, deal.Goal1SellOrder.ClientOrderId);

            if (OrderWorked(sellOrder))
            {
                // Download actual order
                var actualOrders = TradeInterface.GetActualTrades(sellOrder.Symbol, sellOrder.OrderId);
                deal.Goal1SellOrder.FilledOrders = actualOrders.Select(x => x.OrderId).ToList();

                deal.Leftovers -= actualOrders.Select(x => x.Quantity).Sum();

                // Set next state
                deal.CurrentState = Deal.State.WaitForGoal2;

                // Check 2nd goal immediately
                WaitForGoal2(deal);
            }
            else if (OrderCancelled(sellOrder))
            {
                StateTransistion_Cancelled(deal);
            }
        }
Example #2
0
 private static void StateTransistion_Cancelled(Deal deal)
 {
     deal.CurrentState  = Deal.State.Done;
     deal.CurrentResult = Deal.Result.Cancelled;
 }