Пример #1
0
        public void ExecuteBSEEQUITYProcessing(string[] strBSECSVArr, string[] strSCBTXTArr, string strOutputFormat, string strOutputFolder, Action <string> AddMessageToLog)
        {
            FileHelperEngine engineBSECSV = new FileHelperEngine(typeof(BSECSV));

            DelimitedClassBuilder cb           = BuildNSECMPFile();
            FileHelperEngine      engineSCBTXT = new FileHelperEngine(typeof(SCBTXT));


            foreach (string obj in strBSECSVArr)
            {
                //Get BSE Equity Filename day, month, year
                string [] words = obj.Split('\\');

                string strbseequityfilename = words[words.Length - 1];
                string strday  = strbseequityfilename.Substring(2, 2);
                string strmon  = strbseequityfilename.Substring(4, 2);
                string stryear = strbseequityfilename.Substring(6, 2);

                int    index = obj.IndexOf("EQ");
                string dt    = strbseequityfilename.Substring(2, 6);

                string scbtxtfilename = "SCBSEALL" + strbseequityfilename.Substring(2, 4) + ".TXT";

                if (!File.Exists(obj))
                {
                    AddMessageToLog("File " + strbseequityfilename + " does not exist!");
                    continue;
                }



                string SCBSETXTfilenamewithpath = GetFileNameWithPath(strSCBTXTArr, scbtxtfilename);

                if (!File.Exists(SCBSETXTfilenamewithpath))
                {
                    AddMessageToLog("File " + scbtxtfilename + " does not exist!");
                    continue;
                }

                BSECSV[] resbsecsv = engineBSECSV.ReadFile(obj) as BSECSV[];



                SCBTXT[] resscbtxt = engineSCBTXT.ReadFile(SCBSETXTfilenamewithpath) as SCBTXT[];



                int iTotalRows = resbsecsv.Length;


                for (int i = 0; i < iTotalRows; i++)
                {
                    //Copy OI from MTO
                    for (int j = 0; j < resscbtxt.Length; j++)
                    {
                        if (resbsecsv[i].sc_code == resscbtxt[j].scripcode)
                        {
                            resbsecsv[i].openint = resscbtxt[j].deliveryqty;
                            break;
                        }
                    }
                }

                int totrows = 0;

                int itmp = 0;
                int cnt  = 0;

                BSECSVFINAL[] finalarr = new BSECSVFINAL[resbsecsv.Length];
                DateTime      myDate;
                itmp = 0;
                int icntr = 0;
                while (icntr < resbsecsv.Length)
                {
                    finalarr[icntr]        = new BSECSVFINAL();
                    finalarr[icntr].ticker = resbsecsv[icntr].sc_code;
                    finalarr[icntr].name   = resbsecsv[icntr].sc_name;

                    //myDate = Convert.ToDateTime(dt);
                    //myDate = DateTime.ParseExact(dt, "ddMMyyyy", CultureInfo.InvariantCulture);

                    //myDate=Convert.ToDateTime(strday + "-"+ strmon + "-20" + stryear);
                    //finalarr[itmp].date = myDate.ToString("yyyyMMdd"); //String.Format("{0:yyyyMMdd}", dt);
                    finalarr[icntr].date   = "20" + stryear + strmon + strday;   // String.Format("{0:yyyyMMdd}", myDate);
                    finalarr[icntr].open   = resbsecsv[icntr].open;
                    finalarr[icntr].high   = resbsecsv[icntr].high;
                    finalarr[icntr].low    = resbsecsv[icntr].low;
                    finalarr[icntr].close  = resbsecsv[icntr].close;
                    finalarr[icntr].volume = resbsecsv[icntr].no_of_shrs;
                    if ((resbsecsv[icntr].openint) == null)
                    {
                        resbsecsv[icntr].openint = 0;
                    }
                    finalarr[icntr].openint = resbsecsv[icntr].openint;      //enint;


                    icntr++;
                }

                FileHelperEngine engineBSECSVFINAL = new FileHelperEngine(typeof(BSECSVFINAL));
                engineBSECSVFINAL.HeaderText = "Ticker,Name,Date,Open,High,Low,Close,Volume,OPENINT";
                engineBSECSVFINAL.WriteFile(obj, finalarr);



                string folder;
                words = null;
                words = strOutputFormat.Split(',');
                foreach (string item in words)
                {
                    if (item == "StdCSV" || item == "Metastock" || item == "Ninja" || item == "FCharts")
                    {
                        folder = Path.Combine(strOutputFolder, item, "BSE", "Equity", strbseequityfilename);
                        File.Copy(obj, folder, true);
                    }
                    else
                    if (item == "Amibroker")
                    {
                        engineBSECSVFINAL.Options.IgnoreFirstLines = 1;
                        engineBSECSVFINAL.WriteFile(obj, finalarr);

                        folder = Path.Combine(strOutputFolder, item, "BSE", "Equity", strbseequityfilename);
                        File.Copy(obj, folder, true);
                    }
                }
                File.Delete(obj);
            }
        }
Пример #2
0
        public void ExecuteBSEEQUITYProcessing(string[] strBSECSVArr, string[] strSCBTXTArr, string strOutputFormat, string strOutputFolder, Action<string> AddMessageToLog)
        {
            FileHelperEngine engineBSECSV = new FileHelperEngine(typeof(BSECSV));

            DelimitedClassBuilder cb = BuildNSECMPFile();
            FileHelperEngine engineSCBTXT = new FileHelperEngine(typeof(SCBTXT));

            foreach (string obj in strBSECSVArr)
            {

                //Get BSE Equity Filename day, month, year
                string [] words = obj.Split('\\');

                string strbseequityfilename = words[words.Length - 1];
                string strday = strbseequityfilename.Substring(2, 2);
                string strmon = strbseequityfilename.Substring(4, 2);
                string stryear = strbseequityfilename.Substring(6, 2);

                int index = obj.IndexOf("EQ");
                string dt = strbseequityfilename.Substring(2,6);

                string scbtxtfilename = "SCBSEALL" + strbseequityfilename.Substring(2, 4) + ".TXT";

                 if (!File.Exists(obj))
                 {
                     AddMessageToLog("File " + strbseequityfilename + " does not exist!");
                    continue;
                 }

                string SCBSETXTfilenamewithpath = GetFileNameWithPath(strSCBTXTArr, scbtxtfilename);

                if (!File.Exists(SCBSETXTfilenamewithpath))
                {
                    AddMessageToLog("File " + scbtxtfilename + " does not exist!");
                    continue;
                }

                BSECSV[] resbsecsv = engineBSECSV.ReadFile(obj) as BSECSV[];

                SCBTXT[] resscbtxt = engineSCBTXT.ReadFile(SCBSETXTfilenamewithpath) as SCBTXT[];

                int iTotalRows = resbsecsv.Length;

                for (int i = 0; i < iTotalRows; i++)
                {

                        //Copy OI from MTO
                        for (int j = 0; j < resscbtxt.Length; j++)
                        {
                            if (resbsecsv[i].sc_code == resscbtxt[j].scripcode)
                            {

                                resbsecsv[i].openint = resscbtxt[j].deliveryqty;
                                break;
                            }
                        }

                }

                int totrows = 0;

                int itmp = 0;
                int cnt = 0;

                BSECSVFINAL[] finalarr = new BSECSVFINAL[resbsecsv.Length];
                DateTime myDate;
                itmp = 0;
                int icntr = 0;
                while (icntr < resbsecsv.Length)
                {
                        finalarr[icntr] = new BSECSVFINAL();
                        finalarr[icntr].ticker = resbsecsv[icntr].sc_code;
                        finalarr[icntr].name = resbsecsv[icntr].sc_name;

                        //myDate = Convert.ToDateTime(dt);
                        //myDate = DateTime.ParseExact(dt, "ddMMyyyy", CultureInfo.InvariantCulture);

                        //myDate=Convert.ToDateTime(strday + "-"+ strmon + "-20" + stryear);
                        //finalarr[itmp].date = myDate.ToString("yyyyMMdd"); //String.Format("{0:yyyyMMdd}", dt);
                        finalarr[icntr].date = "20" + stryear + strmon + strday; // String.Format("{0:yyyyMMdd}", myDate);
                        finalarr[icntr].open = resbsecsv[icntr].open;
                        finalarr[icntr].high = resbsecsv[icntr].high;
                        finalarr[icntr].low = resbsecsv[icntr].low;
                        finalarr[icntr].close = resbsecsv[icntr].close;
                        finalarr[icntr].volume = resbsecsv[icntr].no_of_shrs;
                        if ((resbsecsv[icntr].openint) == null)
                            resbsecsv[icntr].openint = 0;
                        finalarr[icntr].openint = resbsecsv[icntr].openint;  //enint;

                        icntr++;
                }

                FileHelperEngine engineBSECSVFINAL = new FileHelperEngine(typeof(BSECSVFINAL));
                engineBSECSVFINAL.HeaderText = "Ticker,Name,Date,Open,High,Low,Close,Volume,OPENINT";
                engineBSECSVFINAL.WriteFile(obj, finalarr);

                string folder;
                words = null;
                words = strOutputFormat.Split(',');
                foreach (string item in words)
                {
                    if (item == "StdCSV" || item == "Metastock" || item == "Ninja" || item == "FCharts")
                    {
                        folder = Path.Combine(strOutputFolder, item, "BSE", "Equity", strbseequityfilename);
                        File.Copy(obj, folder, true);
                    }
                    else
                        if (item == "Amibroker")
                        {
                            engineBSECSVFINAL.Options.IgnoreFirstLines = 1;
                            engineBSECSVFINAL.WriteFile(obj, finalarr);

                            folder = Path.Combine(strOutputFolder, item, "BSE", "Equity", strbseequityfilename);
                            File.Copy(obj, folder, true);
                        }
                }
                File.Delete(obj);

            }
        }