Пример #1
0
        public IBConnector(IBParameters settings)
        {
            this.settings     = settings;
            IBFeed            = new IBFeed(this);
            IBOrderRouter     = new IBOrderRouter(this, settings.SessionUid, settings.RouterMode);
            Adapter           = new IBAdapter(this, settings.InstrumentConverter);
            ContractContainer = new ContractContainer(Adapter, settings.InstrumentConverter);

            ConnectionStatusProviders = new IConnectionStatusProvider[] { this };
        }
Пример #2
0
        /// <summary>
        ///     Проверить подписку
        /// </summary>
        async Task <SubscriptionTestResult> ISubscriptionTester <IBInstrumentData> .TestSubscriptionAsync(IBInstrumentData data)
        {
            if (data.Symbol == null)
            {
                return(SubscriptionTestResult.Failed("No symbol has been specified"));
            }

            // Мы ожидаем, что внешний конвертер сформирует код в формате LOCALSYMBOL

            Contract contract;

            switch (data.InstrumentType)
            {
            case IBInstrumentType.Equity:
            case IBInstrumentType.Index:
            case IBInstrumentType.Commodity:
            case IBInstrumentType.FX:
                contract = ContractContainer.GetAssetContractStub(data);
                break;

            case IBInstrumentType.Future:
                contract = ContractContainer.GetFutureContractStub(data);
                break;

            case IBInstrumentType.AssetOption:
                contract = ContractContainer.GetAssetOptionContractStub(data);
                break;

            case IBInstrumentType.FutureOption:
                contract = ContractContainer.GetFutureOptionContractStub(data);
                break;

            default:
                return(SubscriptionTestResult.Failed($"Bad instrument type: {data.InstrumentType}"));
            }

            var testResult = TestContract(contract);
            var result     = await testResult.WaitAsync();

            if (result)
            {
                return(SubscriptionTestResult.Passed());
            }

            return(SubscriptionTestResult.Failed());
        }