Beispiel #1
0
        public static DataTable LoadCovMatrix()
        {
            DateTime  FolderDate;
            string    DirectoyRoot = DirectoryNames.GetDirectoryName("overnightCandlestick");
            string    FullFolderName;
            DataTable CovMatrix = null;

            for (int i = 1; i < 6; i++)
            {
                FolderDate     = BusinessDays.GetBusinessDayShifted(-i);
                FullFolderName = DirectoyRoot + DirectoryNames.GetDirectoryExtension(FolderDate);

                double CovDataIntegrity = Convert.ToDouble(FromTxt2List.LoadFile(FullFolderName + "/covDataIntegrity.txt")[0]);

                if (i > 1)
                {
                    Console.WriteLine("Most recent covFile not available or lower quality! ");
                }

                if (CovDataIntegrity > 80)
                {
                    CovMatrix = IOUtilities.ExcelDataReader.LoadFile(FullFolderName + "/cov_matrix.xlsx").Tables["cov_matrix"];
                    break;
                }
            }
            return(CovMatrix);
        }
        public static IEnumerable <ContractVolume> GetContractVolumes()
        {
            DateTime folderDate = BusinessDays.GetBusinessDayShifted(-1);

            return(GetContractVolumes(folderDate));
        }
        public static IEnumerable <ContractVolume> GetContractVolumes(DateTime folderDate)
        {
            ContractVolumeFolder = DirectoryNames.GetDirectoryName("ttapiContractVolume") + DirectoryNames.GetDirectoryExtension(BusinessDays.GetBusinessDayShifted(-1));
            var sr     = new StreamReader(ContractVolumeFolder + "/ContractList.csv");
            var reader = new CsvHelper.CsvReader(sr);

            reader.Configuration.RegisterClassMap(new MyClassMap());
            ContractVolumeList = reader.GetRecords <ContractVolume>().ToList();

            for (int i = 0; i < ContractVolumeList.Count(); i++)
            {
                string[] words = ContractVolumeList[i].instrumentName.Split();
                ContractVolumeList[i].SeriesKey = words[words.Count() - 1];
            }

            return(ContractVolumeList);
        }
        /// <summary>
        /// Primary constructor
        /// </summary>
        public MarketRecorder(string u, string p)
        {
            m_username = u;
            m_password = p;

            OutputFolder = TA.DirectoryNames.GetDirectoryName(ext: "ttapiBidAsk") + TA.DirectoryNames.GetDirectoryExtension(DateTime.Now.Date);

            System.IO.Directory.CreateDirectory(OutputFolder);

            PriceFileDictionary = new Dictionary <string, StreamWriter>();
            FilteredList        = new List <ttapiTicker>();

            DateTime referanceDate = DateTime.Today;

            EndTime = new DateTime(referanceDate.Year, referanceDate.Month, referanceDate.Day, 15, 45, 0);


            ContractVolumeList = TA.LoadContractVolumeFile.GetContractVolumes(folderDate: BusinessDays.GetBusinessDayShifted(-1));
            FilteredList       = ContractVolumeList.Where(x => x.Volume > 100).ToList().OfType <ttapiTicker>().ToList();

            string [] TickerHeadList = ContractUtilities.ContractMetaInfo.cmeFuturesTickerheadList.Union(ContractUtilities.ContractMetaInfo.iceFuturesTickerheadList).ToArray();

            LiquidContractList = new ContractUtilities.ContractList(TickerHeadList);
            //LiquidDbTickerList = LiquidContractList.dbTickerList;
            LiquidDbTickerList = new List <string>();

            for (int i = 0; i < FilteredList.Count; i++)
            {
                //Console.WriteLine(FilteredList[i].instrumentName);
                PriceFileDictionary.Add(FilteredList[i].instrumentName, new StreamWriter(OutputFolder + "/" + FilteredList[i].instrumentName.Replace("/", "-").Replace(":", "-") + ".csv"));
            }

            TTAPISubs = new ttapiUtils.Subscription(m_username, m_password);
            TTAPISubs.TTAPITickerList    = FilteredList;
            TTAPISubs.LiquidDbTickerList = LiquidDbTickerList;
            TTAPISubs.ilsUpdateList      = new List <EventHandler <InstrumentLookupSubscriptionEventArgs> > {
                TTAPISubs.startPriceSubscriptions
            };
            TTAPISubs.AsuUpdateList = new List <EventHandler <AuthenticationStatusUpdateEventArgs> > {
                TTAPISubs.startInstrumentLookupSubscriptionsFromTTAPITickers
            };
            TTAPISubs.priceUpdatedEventHandler = m_ps_FieldsUpdated;
        }