//コンストラクタ…t_allcorpから全銘柄のリストを取得 public static void RefreshCache() { dtCache = new DataTable(); String sql = "select * from t_allcorp where corpCode <10000 order by corpCode;"; //一時変数 DataRow dr_temp; //dt_listに全銘柄リストを取得 dtCache = SQLManager.SendSQL(sql); for (int i = 0; i < dtCache.Rows.Count; i++) { CorpInfo ci_temp = new CorpInfo(); dr_temp = dtCache.Rows[i]; ci_temp.corpCode = dr_temp.Field <int>("corpCode"); ci_temp.corpName = dr_temp.Field <String>("corpName"); ci_temp.gyousyuCode33 = dr_temp.Field <int>("33gyousyuCode"); ci_temp.gyousyuClass33 = dr_temp.Field <String>("33gyousyuClass"); ci_temp.gyousyuCode17 = dr_temp.Field <int>("17gyousyuCode"); ci_temp.gyousyuClass17 = dr_temp.Field <String>("17gyousyuClass"); ci_temp.kiboCode = dr_temp.Field <int>("kiboCode"); ci_temp.kiboClass = dr_temp.Field <String>("kiboClass"); CorpCache.SetData(ci_temp); } }
public static void CalcVoratility(params DateTime[] span) { DateTime start = new DateTime(1990, 01, 01); DateTime end = new DateTime(); end = DateTime.Today; if (span.Length != 2 || span[0] == span[1]) { } else if (span[0] <= span[1]) { start = span[0]; end = span[1]; } else if (span[1] <= span[0]) { start = span[1]; end = span[0]; } CorpInfo ci = new CorpInfo(); try { int[] codelist = new int[CorpCache.KeyLength()]; CorpCache.Keys().CopyTo(codelist, 0); for (int i = 0; i < codelist.Count(); i++) // var codelist = CorpCache.Keys(); // foreach(int code in codelist) { try { int code = codelist[i]; StockDataManager.StockCache.Get(code).CalcLogReturn(); var log_ret = (from row in StockDataManager.StockCache.Get(code).data.AsEnumerable() where (row.date >= start) && (row.date <= end) select row.logReturn).ToArray(); //目的期間の対数差収益率を取得 ci = CorpCache.Get(code); ci.volatility = Statistics.PopulationStandardDeviation(log_ret);//標本平均分散 CorpCache.SetData(ci); } catch { } } } catch (InvalidOperationException ioe) { MessageBox.Show(ioe.Message + "\n" + ioe.Source + "\n" + ioe.StackTrace); } }