public static void LoadStockCode_ByWatchList(tmpDS.stockCodeDataTable stockCodeTbl, StringCollection codes) { StringCollection retList = new StringCollection(); StringCollection list; tmpDS.stockCodeDataTable tmpTbl = new tmpDS.stockCodeDataTable(); baseDS.portfolioDataTable portfolioTbl = new baseDS.portfolioDataTable(); baseDS.portfolioRow portfolioRow; for (int idx1 = 0; idx1 < codes.Count; idx1++) { portfolioRow = AppLibs.FindAndCache(portfolioTbl, codes[idx1]); if (portfolioRow == null) { continue; } list = common.MultiValueString.String2List(portfolioRow.interestedStock); if (list.Count <= 0) { continue; } tmpTbl.Clear(); LoadStockCode_ByCodeList(tmpTbl, list); for (int idx2 = 0; idx2 < tmpTbl.Count; idx2++) { if (stockCodeTbl.FindBycode(tmpTbl[idx2].code) == null) { stockCodeTbl.ImportRow(tmpTbl[idx2]); } } } portfolioTbl.Dispose(); }
public static baseDS.stockExchangeRow GetStockExchange(string stockCode) { baseDS.stockCodeRow stockRow = AppLibs.FindAndCache_StockCode(stockCode); if (stockRow == null) { return(null); } baseDS.stockExchangeRow stockExchangeRow = AppLibs.FindAndCache_StockExchange(stockRow.stockExchange); return(stockExchangeRow); }
/// <summary> /// Copy data from one portfolioDetail data table to another /// </summary> /// <param name="frDataTbl">Source data</param> /// <param name="toDataTbl">Destination data</param> /// <param name="porfolioCode">Porfolio code of the data added to destination</param> /// <param name="stockCode">Stock code of the data added to destination</param> public static void CopyPortfolioData(databases.baseDS.portfolioDetailDataTable frDataTbl, databases.baseDS.portfolioDetailDataTable toDataTbl, string porfolioCode, string stockCode) { databases.baseDS.portfolioDetailRow row; for (int idx = 0; idx < frDataTbl.Rows.Count; idx++) { row = toDataTbl.NewportfolioDetailRow(); AppLibs.InitData(row); row.portfolio = porfolioCode; row.code = stockCode; row.subCode = frDataTbl[idx].subCode;; row.data = frDataTbl[idx].data; toDataTbl.AddportfolioDetailRow(row); } }
/// <summary> /// Agrregate a data row to hourly,daily data... /// </summary> /// <param name="priceRow"> source data arregated to [toSumTbl] </param> /// <param name="changeVolume"> volume qty changed and is cumulated to total volume </param> /// <param name="timeScale"> aggregate to hour,day,week... data </param> /// <param name="cultureInfo"> culture info that need to caculate the start of the week param> /// <param name="toSumTbl"> destination table</param> public static void AggregatePriceData(databases.baseDS.priceDataRow priceRow, decimal changeVolume, AppTypes.TimeScale timeScale, CultureInfo cultureInfo, databases.baseDS.priceDataSumDataTable toSumTbl) { DateTime dataDate = AggregateDateTime(timeScale, priceRow.onDate, cultureInfo); databases.baseDS.priceDataSumRow priceDataSumRow; priceDataSumRow = AppLibs.FindAndCache(toSumTbl, priceRow.stockCode, timeScale.Code, dataDate); if (priceDataSumRow == null) { priceDataSumRow = toSumTbl.NewpriceDataSumRow(); databases.AppLibs.InitData(priceDataSumRow); priceDataSumRow.type = timeScale.Code; priceDataSumRow.stockCode = priceRow.stockCode; priceDataSumRow.onDate = dataDate; priceDataSumRow.openPrice = priceRow.openPrice; priceDataSumRow.closePrice = priceRow.closePrice; object lastPriceObj = lastClosePrices.Find(timeScale.Code + priceRow.stockCode); if (lastPriceObj != null) { priceDataSumRow.openPrice = (decimal)lastPriceObj; } else { priceDataSumRow.openPrice = priceDataSumRow.closePrice; } toSumTbl.AddpriceDataSumRow(priceDataSumRow); } priceDataSumRow.closePrice = priceRow.closePrice; lastClosePrices.Add(timeScale.Code + priceRow.stockCode, priceRow.closePrice); if (priceDataSumRow.highPrice < priceRow.highPrice) { priceDataSumRow.highPrice = priceRow.highPrice; } if (priceDataSumRow.lowPrice > priceRow.lowPrice) { priceDataSumRow.lowPrice = priceRow.lowPrice; } priceDataSumRow.volume += changeVolume; }
public static void WriteSyslog(AppTypes.SyslogTypes logType, string investorCode, string desc, string source, string msg) { syslogRow = syslogTbl.NewsysLogRow(); AppLibs.InitData(syslogRow); syslogRow.investorCode = investorCode; syslogRow.type = (byte)logType; if (desc != null) { syslogRow.description = desc; } if (source != null) { syslogRow.source = source; } if (msg != null) { syslogRow.message = msg; } syslogTbl.AddsysLogRow(syslogRow); UpdateData(syslogRow); }