Esempio n. 1
0
 public RerunManager(NASDAQConnect _nc)
 {
     nc         = _nc;
     symbolList = new List <string>();
     REngine.SetEnvironmentVariables();
     engine = REngine.GetInstance();
 }
Esempio n. 2
0
 public NewbieManager(string _symbol, NASDAQConnect _nc)
 {
     symbol     = _symbol;
     nc         = _nc;
     OtherDates = new List <DateTime>();
     InitializeTable();
     SymbolFolder = NControl.mainDirectory + symbol + "\\";
     REngine.SetEnvironmentVariables();
     engine = REngine.GetInstance();
     engine.Evaluate("require('bizdays')");
     engine.Evaluate("load_quantlib_calendars('UnitedStates/NYSE', from = '1970-01-01', to = '2021-12-31')");
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            string        symbol     = "";
            List <string> symbolList = new List <string>();
            List <string> NewbieList = new List <string>();
            ConcurrentDictionary <string, DateTime> SymbolEarningDate = new ConcurrentDictionary <string, DateTime>();
            ConcurrentDictionary <string, DateTime> SymbolRecordDate  = new ConcurrentDictionary <string, DateTime>();
            DataTable     DateTable = new DataTable();
            DataColumn    dc;
            DataRow       dr;
            StringBuilder sb = new StringBuilder();
            RerunManager  rm = new RerunManager();
            NASDAQConnect nc = new NASDAQConnect();

            //#################################################################################
            //                      Initialize Datatable
            //#################################################################################
            dc = new DataColumn("Symbol", typeof(string));
            DateTable.Columns.Add(dc);
            dc = new DataColumn("NasdaqDate", typeof(DateTime));
            DateTable.Columns.Add(dc);
            dc = new DataColumn("RecordDate", typeof(DateTime));
            DateTable.Columns.Add(dc);
            dc = new DataColumn("Action", typeof(string));
            DateTable.Columns.Add(dc);


            //#################################################################################
            //                      Read Symbols
            //#################################################################################
            using (StreamReader sr = new StreamReader(NControl.symbolListAdd))
            {
                while (!sr.EndOfStream)
                {
                    symbol = sr.ReadLine();
                    symbolList.Add(symbol);
                    dr           = DateTable.NewRow();
                    dr["Symbol"] = symbol;
                    DateTable.Rows.Add(dr);
                }
            }


            //#################################################################################
            //                      Get Dates and Compare
            //#################################################################################
            Console.WriteLine("Symbol,NasdaqDate,RecordDate,Action");
            foreach (DataRow idr in DateTable.Rows)
            {
                DateTime nasdaqDate = nc.GetNextEarningDate(idr["Symbol"].ToString());
                idr["NasdaqDate"] = nasdaqDate;
                try
                {
                    DateTime RecordDate = FileConnect.GetRecordNextDate(idr["Symbol"].ToString());
                    idr["RecordDate"] = RecordDate;
                    idr["Action"]     = FileConnect.generateAction(nasdaqDate, RecordDate);
                }
                catch (Exception e)
                {
                    if (e is DirectoryNotFoundException || e is FileNotFoundException)
                    {
                        NewbieList.Add(idr["Symbol"].ToString());
                        idr["Action"] = FileConnect.RunAction.New;
                    }
                }
                Console.WriteLine(string.Join(" ; ", idr.ItemArray));
            }

            //#################################################################################
            //                      Take Action for New joiners
            //#################################################################################
            //if (NewbieList.Count > 0)
            //{
            //    Console.WriteLine("Take action for new joiners? (Y/N)");
            //    if (Console.ReadLine().ToUpper() == "Y")
            //    {
            //        foreach (DataRow idr in DateTable.Rows)
            //        {
            //            if (idr["Action"].ToString() == "New")
            //            {
            //                NewbieManager nb = new NewbieManager(idr.Field<string>("Symbol"));
            //                nb.CreateFiles();
            //                idr["Action"] = FileConnect.RunAction.ReRun;
            //            }
            //        }
            //    }
            //}


            //#################################################################################
            //                      Force Rerun Settings
            //#################################################################################
            //DateTable.Select("Symbol = 'NKE'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'XOM'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'CSCO'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'MCD'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'KO'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'INTC'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'HP'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'DIS'")[0]["Action"] = FileConnect.RunAction.ReRun;
            //DateTable.Select("Symbol = 'AMZN'")[0]["Action"] = FileConnect.RunAction.ReRun;



            //#################################################################################
            //                      Take Action
            //#################################################################################
            //Console.WriteLine("Continue to take action? (Y/N)");
            foreach (DataRow idr in DateTable.Rows)
            {
                if (idr["Action"].ToString() == "Move")
                {
                    FileConnect.ModifyShockMatrix(idr.Field <string>("Symbol"), idr.Field <DateTime>("RecordDate"), idr.Field <DateTime>("NasdaqDate"));
                    FileConnect.UpdateDatesConfig(idr.Field <string>("Symbol"), idr.Field <DateTime>("RecordDate"), idr.Field <DateTime>("NasdaqDate"));
                    Console.WriteLine("Modified Matrix - {0}", idr.Field <string>("Symbol"));
                }
                //else
                //{
                //    if (idr["Action"].ToString() == "ReRun")
                //    {
                //        rm.AddSymbol(idr.Field<string>("Symbol"));
                //    }
                //}
            }
            //if (rm.symbolCount() > 0)
            //{
            //    rm.Rerun();
            //}


            //Console.Write("Press key to continue ...");
            //Console.Read();
        }