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);
        }
Esempio n. 2
0
        public static DataTable GetPriceFromCMEDirectFile()
        {
            string FilePath = DirectoryNames.GetDirectoryName(ext: "daily") + FileNames.CMEDirectIntradayPrice;

            string[] csvRows = System.IO.File.ReadAllLines(FilePath);
            string[] fields  = null;

            DataTable PriceTable = new DataTable();

            PriceTable.Columns.Add("Ticker", typeof(string));
            PriceTable.Columns.Add("TickerHead", typeof(string));
            PriceTable.Columns.Add("BidPrice", typeof(double));
            PriceTable.Columns.Add("AskPrice", typeof(double));
            PriceTable.Columns.Add("MidPrice", typeof(double));

            double PriceMultiplier;

            for (int i = 1; i < csvRows.Length; i++)
            {
                fields = csvRows[i].Split(',');
                DataRow Row = PriceTable.NewRow();

                Row["Ticker"]     = fields[0];
                Row["TickerHead"] = ContractUtilities.ContractMetaInfo.GetContractSpecs(fields[0]).tickerHead;

                if (Row.Field <string>("TickerHead") == "JY")
                {
                    PriceMultiplier = 1e7;
                }
                else
                {
                    PriceMultiplier = 1;
                }

                Row["BidPrice"] = Convert.ToDouble(fields[2]) * PriceMultiplier;
                Row["AskPrice"] = Convert.ToDouble(fields[3]) * PriceMultiplier;
                Row["MidPrice"] = (Row.Field <double>("BidPrice") + Row.Field <double>("AskPrice")) / 2;
                PriceTable.Rows.Add(Row);
            }

            return(PriceTable);
        }
Esempio n. 3
0
        public static Dictionary <string, string> GetTTAPICredentials()
        {
            List <string> lineList = IOUtilities.FromTxt2List.LoadFile(DirectoryNames.GetDirectoryName("ttapiConfig") + FileNames.ttapi_credential_file);

            return(FormatUtilities.FromString2Dictionary.Convert(lineList[0]));
        }