Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Text.RegularExpressions;
- using System.Globalization;
- namespace EKB.FASWS.K4000
- {
- public partial class BloombergDataImport
- {
- private class Blmb_MDuration
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public decimal? DUR_ADJ_MID { get; set; }
- public Blmb_MDuration(DateTime? date, string securities, string error_code, decimal? dur_adj_mid)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- DUR_ADJ_MID = dur_adj_mid;
- }
- }
- private class Blmb_FundBondAmt
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public decimal? FUND_TOTAL_ASSETS { get; set; }
- public decimal? AMT_OUTSTANDING { get; set; }
- public Blmb_FundBondAmt(DateTime? date, string securities, string error_code, decimal? fund_total_assets, decimal? amt_outstanding)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- FUND_TOTAL_ASSETS = fund_total_assets;
- AMT_OUTSTANDING = amt_outstanding;
- }
- }
- private class Blmb_KainosYield
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public decimal? MHIS_CLOSE_ON_PX_1_P { get; set; }
- public decimal? PX_LAST { get; set; }
- public decimal? MHIS_CLOSE_ON_PX_1_Y { get; set; }
- public string CRNCY { get; set; }
- public Blmb_KainosYield(DateTime? date, string securities, string error_code, decimal? mhis_close_on_px_1_p, decimal? px_last,
- decimal? mhis_close_on_px_1_y, string currency)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- MHIS_CLOSE_ON_PX_1_P = mhis_close_on_px_1_p;
- PX_LAST = px_last;
- MHIS_CLOSE_ON_PX_1_Y = mhis_close_on_px_1_y;
- CRNCY = currency;
- }
- }
- private class Blmb_LygInd
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public decimal? MHIS_CLOSE_ON_PX_1_P { get; set; }
- public Blmb_LygInd(DateTime? date, string securities, string error_code, decimal? mhis_close_on_px_1_p)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- MHIS_CLOSE_ON_PX_1_P = mhis_close_on_px_1_p;
- }
- }
- private class Blmb_Interest
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public decimal? INT_ACC { get; set; }
- public Blmb_Interest(DateTime? date, string securities, string error_code, decimal? int_acc)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- INT_ACC = int_acc;
- }
- }
- private class Blmb_SaliuReitingai
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public string RTG_SP_LT_LC_ISSUER_CREDIT { get; set; }
- public string RTG_SP_LT_FC_ISSUER_CREDIT { get; set; }
- public string RTG_MDY_LT_LC_DEBT_RATING { get; set; }
- public string RTG_MDY_LT_FC_DEBT_RATING { get; set; }
- public string RTG_FITCH_LT_LC_DEBT { get; set; }
- public string RTG_FITCH_LT_FC_DEBT { get; set; }
- public Blmb_SaliuReitingai(DateTime? date, string securities, string error_code, string rtg_sp_lt_lc_issuer_credit, string rtg_sp_lt_fc_issuer_credit,
- string rtg_mdy_lt_lc_debt_rating, string rtg_mdy_lt_fc_debt_rating, string rtg_fitch_lt_lc_debt, string rtg_fitch_lt_fc_debt)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- RTG_SP_LT_LC_ISSUER_CREDIT = rtg_sp_lt_lc_issuer_credit;
- RTG_SP_LT_FC_ISSUER_CREDIT = rtg_sp_lt_fc_issuer_credit;
- RTG_MDY_LT_LC_DEBT_RATING = rtg_mdy_lt_lc_debt_rating;
- RTG_MDY_LT_FC_DEBT_RATING = rtg_mdy_lt_fc_debt_rating;
- RTG_FITCH_LT_LC_DEBT = rtg_fitch_lt_lc_debt;
- RTG_FITCH_LT_FC_DEBT = rtg_fitch_lt_fc_debt;
- }
- }
- private class Blmb_BondReitingai
- {
- public DateTime? Date { get; set; }
- public string SECURITIES { get; set; }
- public string ERROR_CODE { get; set; }
- public string RTG_SP { get; set; }
- public string RTG_MOODY { get; set; }
- public string RTG_FITCH { get; set; }
- public Blmb_BondReitingai(DateTime? date, string securities, string error_code, string rtg_sp, string rtg_moody, string rtg_fitch)
- {
- Date = date;
- SECURITIES = securities;
- ERROR_CODE = error_code;
- RTG_SP = rtg_sp;
- RTG_MOODY = rtg_moody;
- RTG_FITCH = rtg_fitch;
- }
- }
- #region Private methods
- private IEnumerable<string> ReadFile(string path, out DateTime? date)
- {
- string[] lines = new string[0];
- date = DateTime.Today;
- List<string> selectedLines = new List<string>();
- bool dataStarted = false;
- try
- {
- lines = File.ReadAllLines(path);
- foreach (string line in lines)
- {
- if (Regex.IsMatch(line, "END-OF-DATA"))
- dataStarted = false;
- if (Regex.IsMatch(line, "RUNDATE"))
- {
- string dateLine = line.Substring(8);
- date = DateTime.ParseExact(dateLine, "yyyyMMdd", null);
- }
- if (dataStarted && !Regex.IsMatch(line, "SECURITIES") && !string.IsNullOrWhiteSpace(line))
- selectedLines.Add(line);
- if (Regex.IsMatch(line, "START-OF-DATA"))
- dataStarted = true;
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return selectedLines.AsEnumerable();
- }
- private List<Blmb_FundBondAmt> GetFundBondAmtValues()
- {
- List<Blmb_FundBondAmt> list = new List<Blmb_FundBondAmt>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_FundBondAmt_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\Fund_Bond.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- decimal parsing1;
- decimal parsing2;
- decimal? amt_outstanding = null;
- decimal? fundTotalAssets = null;
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[3] = Regex.Replace(values[3], @"\s+", string.Empty);
- values[4] = Regex.Replace(values[4], @"\s+", string.Empty);
- decimal.TryParse(values[3], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing1);
- if (parsing1 != 0)
- fundTotalAssets = parsing1;
- decimal.TryParse(values[4], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing2);
- if (parsing2 != 0)
- amt_outstanding = parsing2;
- list.Add(new Blmb_FundBondAmt(date, values[0], values[1], fundTotalAssets, amt_outstanding));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- private List<Blmb_KainosYield> GetKainosYieldValues()
- {
- List<Blmb_KainosYield> list = new List<Blmb_KainosYield>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_KainosYield_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\Kainos_yield.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- decimal parsing1;
- decimal parsing2;
- decimal parsing3;
- decimal? MHIS_CLOSE_ON_PX_1_P = null;
- decimal? PX_LAST = null;
- decimal? MHIS_CLOSE_ON_PX_1_Y = null;
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[6] = values[6].Replace("\"", string.Empty);
- values[3] = Regex.Replace(values[3], @"\s+", string.Empty);
- values[4] = Regex.Replace(values[4], @"\s+", string.Empty);
- values[5] = Regex.Replace(values[5], @"\s+", string.Empty);
- decimal.TryParse(values[3], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing1);
- if (parsing1 != 0)
- MHIS_CLOSE_ON_PX_1_P = parsing1;
- decimal.TryParse(values[4], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing2);
- if (parsing2 != 0)
- PX_LAST = parsing2;
- decimal.TryParse(values[5], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing3);
- if (parsing3 != 0)
- MHIS_CLOSE_ON_PX_1_Y = parsing2;
- list.Add(new Blmb_KainosYield(date, values[0], values[1], MHIS_CLOSE_ON_PX_1_P, PX_LAST, MHIS_CLOSE_ON_PX_1_Y, values[6]));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- private List<Blmb_LygInd> GetLygIndValues()
- {
- List<Blmb_LygInd> list = new List<Blmb_LygInd>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_LygInd_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\Lyginamieji_indeksai.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- decimal parsing1;
- decimal? MHIS_CLOSE_ON_PX_1_P = null;
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[3] = Regex.Replace(values[3], @"\s+", string.Empty);
- decimal.TryParse(values[3], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing1);
- if (parsing1 != 0)
- MHIS_CLOSE_ON_PX_1_P = parsing1;
- list.Add(new Blmb_LygInd(date, values[0], values[1], MHIS_CLOSE_ON_PX_1_P));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- private List<Blmb_MDuration> GetMDurationValues()
- {
- List<Blmb_MDuration> list = new List<Blmb_MDuration>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_MDuration_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\MDuration.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- decimal parsing1;
- decimal? DUR_ADJ_MID = null;
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[3] = Regex.Replace(values[3], @"\s+", string.Empty);
- decimal.TryParse(values[3], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing1);
- if (parsing1 != 0)
- DUR_ADJ_MID = parsing1;
- list.Add(new Blmb_MDuration(date, values[0], values[1], DUR_ADJ_MID));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- private List<Blmb_Interest> GetInterestValues()
- {
- List<Blmb_Interest> list = new List<Blmb_Interest>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_Interest_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\Palūkanos.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- decimal parsing1;
- decimal? INT_ACC = null;
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[3] = Regex.Replace(values[3], @"\s+", string.Empty);
- decimal.TryParse(values[3], System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out parsing1);
- if (parsing1 != 0)
- INT_ACC = parsing1;
- list.Add(new Blmb_Interest(date, values[0], values[1], INT_ACC));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- private List<Blmb_SaliuReitingai> GetSaliuReitingaiValues()
- {
- List<Blmb_SaliuReitingai> list = new List<Blmb_SaliuReitingai>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_SaliuReitingai_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\Šalių_reitingai.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[3] = values[3].Replace("\"", string.Empty);
- values[4] = values[4].Replace("\"", string.Empty);
- values[5] = values[5].Replace("\"", string.Empty);
- values[6] = values[6].Replace("\"", string.Empty);
- values[7] = values[7].Replace("\"", string.Empty);
- values[8] = values[8].Replace("\"", string.Empty);
- list.Add(new Blmb_SaliuReitingai(date, values[0], values[1], values[3], values[4], values[5], values[6], values[7], values[8]));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- private List<Blmb_BondReitingai> GetBondReitingaiValues()
- {
- List<Blmb_BondReitingai> list = new List<Blmb_BondReitingai>();
- try
- {
- DateTime? date;
- //string path = sf.configSQL.GetString("global", "Blmb_BondReitingai_Path", "default path");
- string path = @"E:\Users\martynas\Desktop\Martynui\VP_Reitingai.out";
- var lines = ReadFile(path, out date);
- foreach (string line in lines)
- {
- string[] values = line.Split(':');
- values[0] = values[0].Replace("\"", string.Empty);
- values[3] = values[3].Replace("\"", string.Empty);
- values[4] = values[4].Replace("\"", string.Empty);
- values[5] = values[5].Replace("\"", string.Empty);
- list.Add(new Blmb_BondReitingai(date, values[0], values[1], values[3], values[4], values[5]));
- }
- }
- catch (Exception ex)
- {
- sf.log.regLog(ex.ToString());
- }
- return list;
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement