当前位置: 首页>>代码示例>>C#>>正文


C# QDMS.Instrument类代码示例

本文整理汇总了C#中QDMS.Instrument的典型用法代码示例。如果您正苦于以下问题:C# Instrument类的具体用法?C# Instrument怎么用?C# Instrument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Instrument类属于QDMS命名空间,在下文中一共展示了Instrument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DataImportWindow

        public DataImportWindow(Instrument instrument)
        {
            InitializeComponent();

            //reload the instrument first to make sure we have up-to-date data
            using (var context = new MyDBContext())
            {
                context.Instruments.Attach(instrument);
                context.Entry(instrument).Reload();
                _instrument = instrument;
            }

            Title += " - " + _instrument.Symbol;

            //fill frequency combo box
            var values = MyUtils.GetEnumValues<BarSize>();
            foreach (BarSize s in values)
            {
                FrequencyComboBox.Items.Add(s);
            }
            FrequencyComboBox.SelectedItem = BarSize.OneDay;

            MinDT.Value = new DateTime(1950, 1, 1);
            MaxDT.Value = DateTime.Now;
        }
开发者ID:ychaim,项目名称:qdms,代码行数:25,代码来源:DataImportWindow.xaml.cs

示例2: InstrumentToContract

        public static Contract InstrumentToContract(Instrument instrument)
        {
            string symbol = string.IsNullOrEmpty(instrument.DatasourceSymbol) ? instrument.Symbol : instrument.DatasourceSymbol;
            var contract = new Contract(
                0,
                symbol,
                SecurityTypeConverter(instrument.Type),
                instrument.Expiration.HasValue ? instrument.Expiration.Value.ToString("yyyyMM", CultureInfo.InvariantCulture) : "",
                0,
                OptionTypeToRightType(instrument.OptionType),
                instrument.Multiplier.ToString(),
                "",
                instrument.Currency,
                null,
                null,
                SecurityIdType.None,
                string.Empty);

            if (instrument.Strike.HasValue)
                contract.Strike = (double)instrument.Strike.Value;

            if (instrument.Exchange != null)
                contract.Exchange = instrument.Exchange.Name;

            return contract;
        }
开发者ID:kod3r,项目名称:qdms,代码行数:26,代码来源:TWSUtils.cs

示例3: DataPushRequestIsForwardedToLocalStorage

        public void DataPushRequestIsForwardedToLocalStorage()
        {
            var instrument = new Instrument
            {
                ID = 1,
                Symbol = "SPY",
                Datasource = new Datasource { ID = 1, Name = "MockSource" }
            };

            var data = new List<OHLCBar>
            {
                new OHLCBar {Open = 1, High = 2, Low = 3, Close = 4, DT = new DateTime(2013, 1, 1) }
            };

            var req = new DataAdditionRequest(BarSize.OneDay, instrument, data, true);

            _client.PushData(req);

            Thread.Sleep(50);

            _brokerMock.Verify(x => x.AddData(
                It.Is<DataAdditionRequest>(y =>
                    y.Frequency == BarSize.OneDay &&
                    y.Instrument.ID == 1 &&
                    y.Data.Count == 1)
                ), Times.Once);
        }
开发者ID:ychaim,项目名称:qdms,代码行数:27,代码来源:HistoricalDataServerTest.cs

示例4: SetUp

        public void SetUp()
        {
            _instrument = new Instrument
            {
                ID = 1,
                Symbol = "SPY",
                Datasource = new Datasource { ID = 1, Name = "MockSource" }
            };

            _instrument.Exchange = new Exchange()
            {
                ID = 1,
                Name = "Exchange",
                Timezone = "Eastern Standard Time"
            };

            _dataSourceMock = new Mock<IHistoricalDataSource>();
            _dataSourceMock.SetupGet(x => x.Name).Returns("MockSource");
            _dataSourceMock.SetupGet(x => x.Connected).Returns(false);

            _localStorageMock = new Mock<IDataStorage>();

            _cfBrokerMock = new Mock<IContinuousFuturesBroker>();
            _cfBrokerMock.SetupGet(x => x.Connected).Returns(true);

            _broker = new HistoricalDataBroker(_cfBrokerMock.Object, _localStorageMock.Object, new List<IHistoricalDataSource> { _dataSourceMock.Object });

            _dataSourceMock.SetupGet(x => x.Connected).Returns(true);
        }
开发者ID:QANTau,项目名称:QDMS,代码行数:29,代码来源:HistoricalDataBrokerTest.cs

示例5: HistoricalRequestWindow

        public HistoricalRequestWindow(Instrument instrument)
        {
            InitializeComponent();
            DataContext = this;

            Random r = new Random(); //we have to randomize the name of the client, can't reuse the identity

            Title = string.Format("Data Request - {0} @ {1}", instrument.Symbol, instrument.Datasource.Name);

            _client = new QDMSClient.QDMSClient(
            string.Format("DataRequestClient-{0}", r.Next()),
            "localhost",
            Properties.Settings.Default.rtDBReqPort,
            Properties.Settings.Default.rtDBPubPort,
            Properties.Settings.Default.instrumentServerPort,
            Properties.Settings.Default.hDBPort);

            _client.HistoricalDataReceived += _client_HistoricalDataReceived;
            _client.Error += _client_Error;
            _client.Connect();

            Data = new ObservableCollection<OHLCBar>();

            TheInstrument = instrument;

            StartTime = new DateTime(1950, 1, 1, 0, 0, 0, 0);
            EndTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0, 0);

            if (!TheInstrument.ID.HasValue) return;

            ShowDialog();
        }
开发者ID:joyanta,项目名称:qdms,代码行数:32,代码来源:HistoricalRequestWindow.xaml.cs

示例6: RealTimeDataRequest

 public RealTimeDataRequest(Instrument instrument, BarSize frequency, bool rthOnly = true, bool savetoLocalStorage = false)
 {
     Instrument = instrument;
     Frequency = frequency;
     RTHOnly = rthOnly;
     SaveToLocalStorage = savetoLocalStorage;
 }
开发者ID:leo90skk,项目名称:qdms,代码行数:7,代码来源:RealTimeDataRequest.cs

示例7: EmailReportSentOnBrokerError

        public void EmailReportSentOnBrokerError()
        {
            var settings = new UpdateJobSettings(errors: true, timeout: 1, toEmail: "[email protected]", fromEmail: "[email protected]");
            var job = new DataUpdateJob(_brokerMock.Object, _mailMock.Object, settings, _localStorageMock.Object, _instrumentManagerMock.Object);

            _brokerMock
                .Setup(x => x.RequestHistoricalData(It.IsAny<HistoricalDataRequest>()))
                .Throws(new Exception("TestException123"));

            Instrument inst = new Instrument() { ID = 1, Symbol = "SPY", Currency = "USD", Type = InstrumentType.Stock };
            _instrumentManagerMock
                .Setup(x => x.FindInstruments(It.IsAny<Expression<Func<Instrument, bool>>>(), It.IsAny<MyDBContext>()))
                .Returns(new List<Instrument>() { inst });

            _localStorageMock
                .Setup(x => x.GetStorageInfo(It.IsAny<int>()))
                .Returns(new List<StoredDataInfo>() { 
                    new StoredDataInfo() 
                    { 
                        Frequency = BarSize.OneDay, 
                        InstrumentID = inst.ID.Value, 
                        LatestDate = DateTime.Now.AddDays(-2)
                    } });

            job.Execute(_contextMock.Object);

            _mailMock.Verify(x => 
                x.Send(
                    It.IsAny<string>(), 
                    It.Is<string>(y => y == "[email protected]"), 
                    It.IsAny<string>(), 
                    It.Is<string>(y => y.Contains("TestException123"))));
        }
开发者ID:QANTau,项目名称:QDMS,代码行数:33,代码来源:DataUpdateJobTest.cs

示例8: ServerCorrectlyForwardsRealTimeData

        public void ServerCorrectlyForwardsRealTimeData()
        {
            var ds = new Datasource() { ID = 1, Name = "TestDS" };
            var inst = new Instrument() { ID = 15, Datasource = ds, DatasourceID = 1, Symbol = "SPY", Type = InstrumentType.Stock };
            var req = new RealTimeDataRequest(inst, BarSize.FiveSeconds, rthOnly: false, savetoLocalStorage: false);

            _brokerMock.Setup(x => x.RequestRealTimeData(It.IsAny<RealTimeDataRequest>())).Returns(true);

            _client.RequestRealTimeData(req);

            Thread.Sleep(50);

            RealTimeDataEventArgs receivedData = null;
            _client.RealTimeDataReceived += (s,e) => receivedData = e;

            long dt = DateTime.Now.ToBinary();
            _brokerMock.Raise(x => x.RealTimeDataArrived += null, new RealTimeDataEventArgs(15, dt, 100m, 105m, 95m, 99m, 10000000, 101, 500, 1));

            Thread.Sleep(50);

            Assert.IsNotNull(receivedData);
            Assert.AreEqual(15, receivedData.InstrumentID);
            Assert.AreEqual(dt, receivedData.Time);
            Assert.AreEqual(100m, receivedData.Open);
            Assert.AreEqual(105m, receivedData.High);
            Assert.AreEqual(95m, receivedData.Low);
            Assert.AreEqual(99m, receivedData.Close);
            Assert.AreEqual(10000000, receivedData.Volume);
            Assert.AreEqual(500, receivedData.Count);
            Assert.AreEqual(101, receivedData.Wap);
        }
开发者ID:ychaim,项目名称:qdms,代码行数:31,代码来源:RealTimeDataServerTest.cs

示例9: HistoricalDataRequestsAreForwardedToTheBroker

        public void HistoricalDataRequestsAreForwardedToTheBroker()
        {
            var instrument = new Instrument
            {
                ID = 1,
                Symbol = "SPY",
                Datasource = new Datasource { ID = 1, Name = "MockSource" },
                Exchange = new Exchange
                {
                    ID = 1,
                    Name = "Exchange",
                    Timezone = "Eastern Standard Time"
                }
            };
            var request = new HistoricalDataRequest(instrument, BarSize.OneDay, new DateTime(2012, 1, 1), new DateTime(2013, 1, 1));

            _client.RequestHistoricalData(request);
            // TODO: Think about delay amount
            Thread.Sleep(1500);

            _historicalDataBrokerMock.Verify(
                x => x.RequestHistoricalData(
                    It.Is<HistoricalDataRequest>(
                        r =>
                            r.Instrument.ID == 1 &&
                            r.Frequency == BarSize.OneDay &&
                            r.StartingDate == new DateTime(2012, 1, 1) &&
                            r.EndingDate == new DateTime(2013, 1, 1))),
                Times.Once);
        }
开发者ID:QANTau,项目名称:QDMS,代码行数:30,代码来源:HistoricalDataServerTest.cs

示例10: DataAdditionRequest

 public DataAdditionRequest(BarSize frequency, Instrument instrument, List<OHLCBar> data, bool overwrite = true)
 {
     Data = data;
     Frequency = frequency;
     Instrument = instrument;
     Overwrite = overwrite;
 }
开发者ID:KeithNel,项目名称:qdms,代码行数:7,代码来源:DataAdditionRequest.cs

示例11: ContractDetailsToInstrument

        public static Instrument ContractDetailsToInstrument(ContractDetails contract)
        {
            var instrument =  new Instrument
            {
                Symbol = contract.Summary.LocalSymbol,
                UnderlyingSymbol = contract.Summary.Symbol,
                Name = contract.LongName,
                OptionType = RightTypeToOptionType(contract.Summary.Right),
                Type = InstrumentTypeConverter(contract.Summary.SecurityType),
                Multiplier = contract.Summary.Multiplier == null ? 1 : int.Parse(contract.Summary.Multiplier),
                Expiration = string.IsNullOrEmpty(contract.Summary.Expiry) ? (DateTime?)null : DateTime.ParseExact(contract.Summary.Expiry, "yyyyMMdd", CultureInfo.InvariantCulture),
                Strike = (decimal)contract.Summary.Strike,
                Currency = contract.Summary.Currency,
                MinTick = (decimal)contract.MinTick,
                Industry = contract.Industry,
                Category = contract.Category,
                Subcategory = contract.Subcategory,
                IsContinuousFuture = false,
                ValidExchanges = contract.ValidExchanges
            };

            if (!string.IsNullOrEmpty(contract.Summary.PrimaryExchange))
                instrument.PrimaryExchange = new Exchange { Name = contract.Summary.PrimaryExchange };
            return instrument;
        }
开发者ID:kod3r,项目名称:qdms,代码行数:25,代码来源:TWSUtils.cs

示例12: RemoveInstrument

        /// <summary>
        /// Delete an instrument and all locally stored data.
        /// </summary>
        public static void RemoveInstrument(Instrument instrument)
        {
            using (var entityContext = new MyDBContext())
            {
                //hacking around the circular reference issue
                if (instrument.IsContinuousFuture)
                {
                    entityContext.Instruments.Attach(instrument);
                    var tmpCF = instrument.ContinuousFuture;
                    instrument.ContinuousFuture = null;
                    instrument.ContinuousFutureID = null;
                    entityContext.SaveChanges();

                    entityContext.ContinuousFutures.Attach(tmpCF);
                    entityContext.ContinuousFutures.Remove(tmpCF);
                    entityContext.SaveChanges();
                }

                entityContext.Instruments.Attach(instrument);
                entityContext.Instruments.Remove(instrument);
                entityContext.SaveChanges();
            }

            using (var localStorage = DataStorageFactory.Get())
            {
                localStorage.Connect();

                localStorage.DeleteAllInstrumentData(instrument);
            }
        }
开发者ID:ychaim,项目名称:qdms,代码行数:33,代码来源:InstrumentManager.cs

示例13: ServerCorrectlyForwardsCancellationRequestsToBroker

        public void ServerCorrectlyForwardsCancellationRequestsToBroker()
        {
            var ds = new Datasource() { ID = 1, Name = "TestDS" };
            var inst = new Instrument() { ID = 15, Datasource = ds, DatasourceID = 1, Symbol = "SPY", Type = InstrumentType.Stock };
            _client.CancelRealTimeData(inst);

            _brokerMock.Verify(x => x.CancelRTDStream(It.Is<int>(y => y == 15)));
        }
开发者ID:ychaim,项目名称:qdms,代码行数:8,代码来源:RealTimeDataServerTest.cs

示例14: RealTimeStreamInfo

 public RealTimeStreamInfo(Instrument instrument, int requestID, string datasource, BarSize frequency, bool rthOnly) : this()
 {
     Instrument = instrument;
     RequestID = requestID;
     Datasource = datasource;
     Frequency = frequency;
     RTHOnly = rthOnly;
 }
开发者ID:QANTau,项目名称:QDMS,代码行数:8,代码来源:RealTimeStreamInfo.cs

示例15: GetTZInfoThrowsExceptionIfNonExistingTimezoneIsSpecified

 public void GetTZInfoThrowsExceptionIfNonExistingTimezoneIsSpecified()
 {
     var inst = new Instrument { Exchange = new Exchange { Timezone = "asdf____" } };
     Assert.Throws<TimeZoneNotFoundException>(() =>
     {
         TimeZoneInfo tz = inst.GetTZInfo();
     });
 }
开发者ID:QANTau,项目名称:QDMS,代码行数:8,代码来源:InstrumentTest.cs


注:本文中的QDMS.Instrument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。