示例#1
0
        public StringBuilder parse_TimeS_SCV(string path, CSVSettingsMap setMap)
        {
            StringBuilder res = new StringBuilder();

            string[] content = File.ReadAllLines(path);

            foreach (var line in content)
            {
                string   newLine = "";
                string[] columns = line.Split(',');

                foreach (var prop in setMap.TimeSerDataProps)
                {
                    newLine  = "";
                    newLine += columns[setMap.DatePosition] + ",";
                    newLine += columns[setMap.IdPosition] + ",";
                    newLine += columns[setMap.AssetTypeIdPosition];
                    newLine += "," + prop.PropertySetType + "," + prop.PropertyId +
                               "," + (columns[prop.Position] == "" ? "0" : columns[prop.Position]) +
                               "," + columns[setMap.CurrencyPosition];
                    res.AppendLine(newLine);
                }
            }
            return(res);
        }
示例#2
0
        public StringBuilder parseSCV(string path, CSVSettingsMap setMap)
        {
            StringBuilder res = new StringBuilder();

            string[]     content = File.ReadAllLines(path);
            List <Asset> assets  = (new AssetMasterSerializator()).DeserializeAssetCSV();

            foreach (var line in content)
            {
                string   newLine = "";
                string[] columns = line.Split(',');

                foreach (var prop in setMap.TimeSerDataProps)
                {
                    var asset = assets.Find(x => x.AssetId == columns[setMap.IdPosition]);
                    if (asset != null)
                    {
                        newLine  = "";
                        newLine += columns[setMap.DatePosition] + ",";
                        newLine += columns[setMap.IdPosition] + ",";
                        newLine += asset.AssetTypeId;
                        newLine += "," + prop.PropertySetType + "," + prop.PropertyId +
                                   "," + (columns[prop.Position] == "" ? "0" : columns[prop.Position]) +
                                   "," + columns[setMap.CurrencyPosition];
                        res.AppendLine(newLine);
                    }
                }
            }
            return(res);
        }
示例#3
0
        public string ParseKPI()
        {
            string         res      = "1";
            CSVSettingsMap settings = DeserilizeSCVSettings(Constants.SetMapKPI);
            ETFParser      parser   = new ETFParser();
            StringBuilder  str      = parser.parseSCV(Constants.Src_KPI, settings);

            File.WriteAllText(Constants.Res_TimeSer_KPI, str.ToString());

            return(res);
        }
示例#4
0
        public string ParseMexBondsDaily()
        {
            string              res      = "1";
            CSVSettingsMap      settings = DeserilizeSCVSettings(Constants.SetMapCSVMexBondsDaily);
            MexBondsDailyParser parser   = new MexBondsDailyParser();
            StringBuilder       str      = parser.parseSCV(Constants.Src_MexBondsDaily, settings);

            File.WriteAllText(Constants.Res_TimeSerMexBondsDaily, str.ToString());

            return(res);
        }
示例#5
0
        public string ParseLongTermFixInc()
        {
            string               res      = "1";
            CSVSettingsMap       settings = DeserilizeSCVSettings(Constants.SetMapCSVLongTerm);
            LongTermFixIncParser parser   = new LongTermFixIncParser();
            StringBuilder        strTS    = parser.parse_TimeS_SCV(Constants.Src_LongTermFixInc, settings);
            StringBuilder        strMD    = parser.parse_MasterD_SCV(Constants.Src_LongTermFixInc, settings);

            File.WriteAllText(Constants.Res_TimeSerLongTermFixInc, strTS.ToString());
            File.WriteAllText(Constants.Res_MasterDLongTermFixInc, strMD.ToString());

            return(res);
        }
示例#6
0
        public CSVSettingsMap DeserilizeSCVSettings(string path)
        {
            CSVSettingsMap result = new CSVSettingsMap();

            string       json = File.ReadAllText(path);
            MemoryStream ms   = new MemoryStream(Encoding.UTF8.GetBytes(json));
            DataContractJsonSerializer ser = new DataContractJsonSerializer(result.GetType());

            result = ser.ReadObject(ms) as CSVSettingsMap;
            ms.Close();

            return(result);
        }
示例#7
0
        public void SerializeSCVSettings(string path, CSVSettingsMap setMap)
        {
            MemoryStream stream            = new MemoryStream();
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(CSVSettingsMap));

            ser.WriteObject(stream, setMap);
            byte[] json = stream.ToArray();
            stream.Close();
            string jsonStr = Encoding.UTF8.GetString(json, 0, json.Length);
            string result  = JValue.Parse(jsonStr).ToString(Formatting.Indented);

            File.WriteAllText(path, result);
        }
        public CSVSettingsMap Simulate()
        {
            CSVSettingsMap res = new CSVSettingsMap();

            res.DatePosition        = 0;
            res.IdPosition          = 6;
            res.AssetTypeIdPosition = 3;
            res.CurrencyPosition    = 16;

            res.TimeSerDataProps = new List <CSVPropertyMap>();
            res.MasterDataProps  = new List <CSVPropertyMap>();

            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 7,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "PrecioSucio"
            });
            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 8,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "PlazoPortafolio"
            });
            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 11,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "DнasAVencimiento"
            });
            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 12,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "Rendimiento"
            });
            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 13,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "Tнtulos"
            });
            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 14,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "Duraciуn"
            });
            res.TimeSerDataProps.Add(new CSVPropertyMap()
            {
                Position        = 15,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "Saldo"
            });
            res.MasterDataProps.Add(new CSVPropertyMap()
            {
                Position        = 9,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "PlazoOriginal"
            });
            res.MasterDataProps.Add(new CSVPropertyMap()
            {
                Position        = 10,
                PropertySetType = "LongTermFixIncSetTimeSeries",
                PropertyId      = "FechaEmisiуn"
            });

            return(res);
        }