示例#1
0
        private void CreateManagers()
        {
            _memberManagersList = new List <IUnlBaseMemberManager>();

            OptionsManager = new OptionsManager(ManagedSecurity, this);
            _memberManagersList.Add(OptionsManager);

            PositionsDataBuilder = new PositionsDataBuilder(ManagedSecurity, this);
            _memberManagersList.Add(PositionsDataBuilder);

            OrdersManager = new OrdersManager(ManagedSecurity, this);
            _memberManagersList.Add(OrdersManager);

            TradingManager = new TradingManager(ManagedSecurity, this);
            _memberManagersList.Add(TradingManager);
            TradingManager.SendTradingTimeEvent    += TradingManager_SendTradingTimeEvent;
            TradingManager.PositionNeedToOptimized += TradingManagerOnPositionNeedToOptimized;
        }
示例#2
0
        protected override void HandleMessage(IMessage message)
        {
            //if (Symbol.Equals("MCD"))//For test
            //{}
            switch (message.APIDataType)
            {
            case EapiDataTypes.AccountSummaryData:
                TradingManager.HandleMessage(message);
                OrdersManager.HandleMessage(message);
                AccountSummaryData = message as AccountSummaryData;
                break;

            case EapiDataTypes.SecurityContract:
                SecurityContract = (SecurityContract)message;
                EvaluateTradingEvents();
                break;

            case EapiDataTypes.SecurityData:
                var securityData = (SecurityData)message;

                if (securityData.SecurityContract.Symbol == Symbol)
                {
                    UnlTradingData.UnlSecurityData = securityData;

                    MainSecurityData = securityData;
                    SendMessageToAllComponents(message);
                }
                break;

            case EapiDataTypes.OptionData:
                OptionsManager.HandleMessage(message);
                break;

            case EapiDataTypes.PositionData:
                PositionsDataBuilder.HandleMessage(message);
                break;

            case EapiDataTypes.OrderData:
                OrdersManager.HandleMessage(message);
                break;

            case EapiDataTypes.OrderStatus:
                OrdersManager.HandleMessage(message);
                break;

            case EapiDataTypes.BrokerConnectionStatus:
                var connectionStatusMessage = (BrokerConnectionStatusMessage)message;
                ConnectionStatus = connectionStatusMessage.Status;
                if (connectionStatusMessage.AfterConnectionToApiWrapper)
                {
                    DoWorkAfterConnection();
                }
                SendMessageToAllComponents(message);
                break;

            case EapiDataTypes.MarginData:
                var marginData = (MarginData)message;
                UnlTradingData.Margin = marginData.Margin;
                break;

            case EapiDataTypes.TransactionData:
                //Filter other unl messages:
                var transactionData = message as TransactionData;
                if (transactionData == null)
                {
                    break;
                }

                if (transactionData.OptionData.OptionContract.Symbol.Equals(Symbol) == false)
                {
                    break;
                }

                var tradingManager = _memberManagersList.First(m => m is ITradingManager) as ITradingManager;
                tradingManager?.HandleMessage(message);

                break;

            case EapiDataTypes.ExceptionData:

                break;
            }
            SendMessageToSubscribers(message);
        }