Esempio n. 1
0
        private void setUpInsturment(DateTime start, DateTime end, string security, Security.SecurityType secType)
        {
            var sec = new DataFactory(new Security(security, 0, secType));

            _factories.Add(sec);
            _markets.AddSecurity(sec);
            sec.AddReferenceToMarkets(_markets);
            sec.AddReferenceToDatafeed((ITickDataFeed)_histFeed);

            var query = new TickDataQuery()
            {
                Security             = sec.SecurityName,
                CorrelationIdObj     = sec,
                StartDate            = start,
                EndDate              = end,
                IncludeConditionCode = true,
                IncludeExchangeCode  = true
            };

            var queryGenerator = new TickDataQueries();
            var queries        = queryGenerator.GetTickDataQueries(query);
            var queriesPM      = new List <ITickDataQuery>();

            foreach (var q in queries)
            {
                queriesPM.Add(new TickDataQuery()
                {
                    Security             = q.Security,
                    StartDate            = new DateTime(q.EndDate.Year, q.EndDate.Month, q.EndDate.Day, 7, 15, 00),
                    EndDate              = new DateTime(q.EndDate.Year, q.EndDate.Month, q.EndDate.Day, 18, 20, 00),
                    Fields               = q.Fields,
                    CorrelationIdObj     = q.CorrelationIdObj,
                    IncludeConditionCode = q.IncludeConditionCode,
                    IncludeExchangeCode  = q.IncludeExchangeCode,
                });

                //q.StartDate = q.StartDate.AddHours(-1);
                q.EndDate = new DateTime(q.EndDate.Year, q.EndDate.Month, q.EndDate.Day, 6, 20, 00);
            }


            if (useBB)
            {
                // Historical playback From Bloomberg
                var histBBTickData = new BloombergHistTickDataHandler();
                histBBTickData.BBHTDUpdate += histTickData_Update;

                histBBTickData.AddDataQueries(queries);
                histBBTickData.AddDataQueries(queriesPM);

                histBBTickData.DataHandler = _histFeed;
                _histFeed.AddHistoricalAdapter(histBBTickData);
            }
            else
            {
                // Historical playback from SQL DB
                const string dsPath = "TickData.qbd";

                var histTickData = new HistoricalData.HistoricalAdapterSqlDB(dsPath);
                histTickData.HistTDUpdate += histTickData_Update;

                histTickData.AddDataQueries(queries);
                //histTickData.AddDataQueries(queriesPM);

                histTickData.DataHandler = _histFeed;
                _histFeed.AddHistoricalAdapter(histTickData);
            }



            responded.Add(security, false);
        }