Exemplo n.º 1
0
        protected override void TryEndRecovery()
        {
            if (debug)
            {
                log.Debug("TryEndRecovery Status " + ConnectionStatus +
                          ", Session Status Online " + isOrderServerOnline +
                          ", Resend Complete " + IsResendComplete);
            }
            switch (ConnectionStatus)
            {
            case Status.Recovered:
            case Status.PendingLogOut:
            case Status.PendingLogin:
            case Status.PendingServerResend:
            case Status.Disconnected:
                return;

            case Status.PendingRecovery:
                if (IsResendComplete && isOrderServerOnline)
                {
                    OrderStore.RequestSnapshot();
                    EndRecovery();
                    //RequestPositions();
                    //RequestSessionUpdate();
                    StartPositionSync();
                    return;
                }
                break;

            default:
                throw new ApplicationException("Unexpected connection status for TryEndRecovery: " + ConnectionStatus);
            }
        }
Exemplo n.º 2
0
        public override bool OnLogin()
        {
            if (debug)
            {
                log.Debug("LimeFIXProvider.Login()");
            }

            if (OrderStore.Recover())
            {
                // Reset the order algorithms
                lock (orderAlgorithmsLocker)
                {
                    var symbolIds = new List <long>();
                    foreach (var kvp in orderAlgorithms)
                    {
                        symbolIds.Add(kvp.Key);
                    }
                    orderAlgorithms.Clear();
                    foreach (var symbolId in symbolIds)
                    {
                        CreateAlgorithm(symbolId);
                    }
                }
                if (debug)
                {
                    log.Debug("Recovered from snapshot Local Sequence " + OrderStore.LocalSequence + ", Remote Sequence " + OrderStore.RemoteSequence);
                }
                if (debug)
                {
                    log.Debug("Recovered orders from snapshot: \n" + OrderStore.OrdersToString());
                }
                if (debug)
                {
                    log.Debug("Recovered symbol positions from snapshot:\n" + OrderStore.SymbolPositionsToString());
                }
                if (debug)
                {
                    log.Debug("Recovered strategy positions from snapshot:\n" + OrderStore.StrategyPositionsToString());
                }
                RemoteSequence = OrderStore.RemoteSequence;
                SendLogin(OrderStore.LocalSequence);
                OrderStore.RequestSnapshot();
            }
            else
            {
                if (debug)
                {
                    log.Debug("Unable to recover from snapshot. Beginning full recovery.");
                }
                OrderStore.SetSequences(0, 0);
                OrderStore.ForceSnapshot();
                SendLogin(OrderStore.LocalSequence);
            }
            return(true);
        }