/// <summary> /// Write OTC major investors buy and sell data into SQLites /// </summary> /// <param name="date"></param> /// <returns></returns> public bool WriteOTCBuySellToSQL(string date) { List <string> Data = new List <string>(); string HolidayDate = myFunction.SolarToVids(date, false); // 爬取資料 var AlertIndfo = ParseOTCBuySell(date); if (AlertIndfo != null) { foreach (var item in AlertIndfo) { Data.Add(HolidayDate + "_" + "櫃_" + item.Key + "_" + item.Value); } // 寫入SQLite SQliteDb sQlite = new SQliteDb(); string insertString = ""; if (sQlite.DataAdd(FilePath.DB_saveDir, "OTCBuySell", Header.OTCBuySell_header, Data, insertString)) { return(true); } } //Stock_Form.Log.Debug($"{date}:上櫃三大法人買賣超取得失敗!"); return(false); }
/// <summary> /// Read OTC data write into SQLite /// </summary> /// <param name="date">日期</param> public bool WriteOTCToSQL(string date) { List <string> Data = new List <string>(); string HolidayDate = myFunction.SolarToVids(date, false); // 爬取資料 var ListedInfo = ParseOTCInfo(date); if (ListedInfo != null) { foreach (var item in ListedInfo) { //Console.WriteLine($"{item.Key} : {string.Join("/", item.Value)}"); Data.Add(HolidayDate + "_" + "櫃_" + string.Join("_", item.Value)); } // 寫入SQLite SQliteDb sQlite = new SQliteDb(); string insertString = ""; if (sQlite.DataAdd(FilePath.DB_saveDir, "OTC", Header.OTC_header, Data, insertString)) { Console.WriteLine("新增成功!"); return(true); } } //Stock_Form.Log.Debug($"{date}:上櫃盤後資訊取得失敗!"); return(false); }
/// <summary> /// Read OTC alert data write into SQLite /// </summary> /// <param name="date">日期</param> public bool WriteOTCAlertToSQL(string date) { List <string> Data = new List <string>(); string Date = myFunction.SolarToVids(date, false); // parse data var AlertIndfo = ParseOTCAlertInfo(date); if (AlertIndfo != null) { foreach (var item in AlertIndfo) { Data.Add(Date + "_" + "櫃_" + item.Key + "_" + item.Value); } // write into SQLite SQliteDb sQlite = new SQliteDb(); string insertString = ""; if (sQlite.DataAdd(FilePath.DB_saveDir, "OTCAlert", Header.OTCAlert_header, Data, insertString)) { return(true); } } //Stock_Form.Log.Debug($"{date}:上櫃當沖標的取得失敗!"); return(false); }
/// <summary> /// Read Listed data and capital data(Calculate turnover) write into SQLite /// </summary> /// <param name="date">日期</param> public bool WriteListedToSQL(string date, Dictionary <string, string> CapitalDic) { List <string> Data = new List <string>(); // 爬取資料 var ListedInfo = ParseAllInfo(date, CapitalDic); if (ListedInfo != null) { foreach (var item in ListedInfo) { //Console.WriteLine($"{item.Key} : {string.Join("/", item.Value)}"); Data.Add(date + "_" + "市_" + string.Join("_", item.Value)); } // 寫入SQLite SQliteDb sQlite = new SQliteDb(); string insertString = ""; if (sQlite.DataAdd(FilePath.DB_saveDir, "Listed", Header.Listed_header, Data, insertString)) { Console.WriteLine("新增成功!"); return(true); } } //Stock_Form.Log.Debug($"{date}:上市盤後資訊取得失敗!"); return(false); }
/// <summary> /// Read Listed alert data write into SQLite /// </summary> /// <param name="date">日期</param> public bool WriteListedAlertToSQL(string date) { List <string> Data = new List <string>(); // 爬取資料 var AlertIndfo = ParseListedAlert(date); if (AlertIndfo != null) { foreach (var item in AlertIndfo) { Data.Add(date + "_" + "市_" + item.Key + "_" + item.Value); } // 寫入SQLite SQliteDb sQlite = new SQliteDb(); string insertString = ""; if (sQlite.DataAdd(FilePath.DB_saveDir, "ListedAlert", Header.ListedAlert_header, Data, insertString)) { return(true); } } //Stock_Form.Log.Debug($"{date}:上市當沖標的取得失敗!"); return(false); }
/// <summary> /// Check data table exist /// </summary> public void DataTableCheckExist() { SQliteDb SQlite = new SQliteDb(); Dictionary <string, List <string> > TableList = new Dictionary <string, List <string> > { { "Capital", Header.Capital_header }, { "Listed", Header.Listed_header }, { "ListedAlert", Header.ListedAlert_header }, { "ListedBuySell", Header.ListedBuySell_header }, { "OTC", Header.OTC_header }, { "OTCAlert", Header.OTCAlert_header }, { "OTCBuySell", Header.OTCBuySell_header } }; foreach (var item in TableList) { if (!SQlite.CheckDatatable(item.Key)) { SQlite.CreateTable(FilePath.DB_saveDir, SQlite.CreateTableString(item.Key, item.Value)); } } }