Exemplo n.º 1
0
        public async Task HistoricalDataController_Should_RetrieveHistoricalData()
        {
            // Setup
            TwsObjectFactory   twsObjectFactory = new TwsObjectFactory("localhost", TestConstants.Port, 1);
            ITwsControllerBase twsController    = twsObjectFactory.TwsControllerBase;

            await twsController.EnsureConnectedAsync();

            Contract contract = new Contract
            {
                SecType     = TwsContractSecType.Stock,
                Symbol      = "MSFT",
                Exchange    = TwsExchange.Smart,
                PrimaryExch = TwsExchange.Island,
            };

            var queryTime = DateTime.Now.AddMonths(-6);

            // Call
            List <HistoricalDataEventArgs> historicalDataEvents = await twsController.GetHistoricalDataAsync(contract, queryTime, TwsDuration.OneMonth, TwsBarSizeSetting.OneDay, TwsHistoricalDataRequestType.Midpoint);

            // Assert
            historicalDataEvents.Count.Should().BeGreaterThan(0);

            await twsController.DisconnectAsync();
        }