コード例 #1
0
ファイル: IBTest.cs プロジェクト: zino974/qdms
 public void SetUp()
 {
     _ibClientMock = new Mock <IIBClient>();
     _ibClientMock.Setup(x => x.Connected).Returns(true);
     _ibDatasource = new IB(Host, Port, client: _ibClientMock.Object);
     _ibDatasource.Connect();
 }
コード例 #2
0
ファイル: IBTest.cs プロジェクト: QANTau/QDMS
 public void SetUp()
 {
     _ibClientMock = new Mock<IIBClient>();
     _ibClientMock.Setup(x => x.Connected).Returns(true);
     _ibDatasource = new IB(client: _ibClientMock.Object);
     _ibDatasource.Connect();
 }
コード例 #3
0
        public void HistoricalDataUpdateCorrectlyRaisesRealTimeDataEvent()
        {
            //need to set it up from the start w/ the right setting
            _ibClientMock = new Mock <IIBClient>();
            _ibClientMock.Setup(x => x.Connect(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Callback(() => _clientIsConnected = true);
            _ibClientMock.Setup(x => x.Connected).Returns(() => _clientIsConnected);

            var settings = new Mock <ISettings>();

            settings.Setup(x => x.ibClientHost).Returns(Host);
            settings.Setup(x => x.ibUseNewRealTimeDataSystem).Returns(true);

            _ibDatasource = new IB(settings.Object, client: _ibClientMock.Object);
            _ibDatasource.Connect();

            var exchange = new Exchange {
                ID = 1, Name = "Ex", Timezone = "Pacific Standard Time"
            };
            var req = new RealTimeDataRequest
            {
                Instrument = new Instrument {
                    ID = 1, Symbol = "SPY", UnderlyingSymbol = "SPY", Exchange = exchange, Currency = "USD", Type = InstrumentType.Stock
                },
                Frequency = QDMS.BarSize.FiveSeconds,
                RTHOnly   = true
            };

            int requestID = -1;

            _ibClientMock
            .Setup(x => x.RequestHistoricalData(
                       It.IsAny <int>(),
                       It.IsAny <Contract>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <QDMSIBClient.BarSize>(),
                       It.IsAny <HistoricalDataType>(),
                       It.IsAny <bool>(),
                       It.IsAny <bool>(),
                       It.IsAny <List <TagValue> >()))
            .Callback <int, Contract, string, string, BarSize, HistoricalDataType, bool, bool, List <TagValue> >((y, a, b, c, d, e, f, g, h) => requestID = y);

            _ibDatasource.RequestRealTimeData(req);

            bool received = false;

            _ibDatasource.DataReceived += (sender, e) => received = true;

            _ibClientMock.Raise(x => x.HistoricalDataUpdate += null, new HistoricalDataEventArgs(requestID, new Bar(new DateTime(2014, 1, 15),
                                                                                                                    1,
                                                                                                                    2,
                                                                                                                    3,
                                                                                                                    4,
                                                                                                                    5,
                                                                                                                    5,
                                                                                                                    3)));

            Assert.IsTrue(received);
        }
コード例 #4
0
        public void SetUp()
        {
            _ibClientMock = new Mock <IIBClient>();
            _ibClientMock.Setup(x => x.Connected).Returns(true);

            var settings = new Mock <ISettings>();


            _ibDatasource = new IB(settings.Object, client: _ibClientMock.Object);
            _ibDatasource.Connect();
        }
コード例 #5
0
        public void SetUp()
        {
            _clientIsConnected = false;
            _ibClientMock      = new Mock <IIBClient>();
            _ibClientMock.Setup(x => x.Connect(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Callback(() => _clientIsConnected = true);
            _ibClientMock.Setup(x => x.Connected).Returns(() => _clientIsConnected);

            var settings = new Mock <ISettings>();

            settings.Setup(x => x.ibClientHost).Returns(Host);

            _ibDatasource = new IB(settings.Object, client: _ibClientMock.Object);
            _ibDatasource.Connect();
        }