public virtual void LoadData(AppTypes.StrategyTypes type,bool onlyEnableItem,bool checkAll) { this.strategyClb.LoadData(type); this.strategyCatCb.LoadData(true); //Check all //strategyClb.CheckAll(selectAllChk.Checked); }
/// <summary> /// Get aggregation date/time from a date/time /// </summary> /// <param name="type"></param> /// <param name="onDateTime"></param> /// <param name="ci"></param> /// <returns></returns> public static DateTime AggregateDateTime(AppTypes.TimeScale timeScale, DateTime onDateTime, CultureInfo ci) { if (timeScale.Type == AppTypes.TimeScaleTypes.RealTime) return onDateTime; switch (timeScale.Type) { case AppTypes.TimeScaleTypes.Minnute: int newMin = ((int)(onDateTime.Minute / timeScale.AggregationValue)) * timeScale.AggregationValue; return onDateTime.Date.AddHours(onDateTime.Hour).AddMinutes(newMin); case AppTypes.TimeScaleTypes.Hour: int newHour = ((int)(onDateTime.Hour / timeScale.AggregationValue)) * timeScale.AggregationValue; return onDateTime.Date.AddHours(newHour); case AppTypes.TimeScaleTypes.Day: int newDay = ((int)((onDateTime.Day - 1) / timeScale.AggregationValue)) * timeScale.AggregationValue + 1; return common.dateTimeLibs.MakeDate(newDay, onDateTime.Month, onDateTime.Year); case AppTypes.TimeScaleTypes.Week: int weekNo = onDateTime.DayOfYear / 7; int newWeek = ((int)(weekNo / timeScale.AggregationValue)) * timeScale.AggregationValue; DateTime newDate = common.dateTimeLibs.MakeDate(1, 1, onDateTime.Year).AddDays(newWeek * 7); return common.dateTimeLibs.StartOfWeek(newDate, ci); case AppTypes.TimeScaleTypes.Month: int newMonth = ((int)((onDateTime.Month - 1) / timeScale.AggregationValue)) * timeScale.AggregationValue + 1; return common.dateTimeLibs.MakeDate(1, newMonth, onDateTime.Year); case AppTypes.TimeScaleTypes.Year: int newYear = ((int)((onDateTime.Year - 1) / timeScale.AggregationValue)) * timeScale.AggregationValue + 1; return common.dateTimeLibs.MakeDate(1, 1, newYear); default: common.system.ThrowException("Invalid argument in AggregateDateTime()"); break; } return onDateTime; }
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); }
public static void LoadStockCode_ByStatus(baseDS.stockCodeDataTable tbl,AppTypes.CommonStatus status) { stockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); }
public static void LoadPortfolioByInvestor(baseDS.portfolioDataTable tbl, string investorCode,AppTypes.PortfolioTypes type) { portfolioTA.ClearBeforeFill = false; portfolioTA.FillByInvestorCodeAndTypeMask(tbl, investorCode,((byte)type).ToString()); }
public static void LoadData(baseDS.portfolioDataTable tbl, AppTypes.PortfolioTypes type) { common.SysLog.WriteLog(DateTime.Now.ToString() + common.Consts.constTab + "ABC "+portfolioDetailTA.Connection.ConnectionString, Settings.sysFileUserLog); portfolioTA.ClearBeforeFill = false; portfolioTA.FillByTypeMask(tbl, ((byte)type).ToString()); }
public static void LoadData(tmpDS.stockCodeDataTable tbl, AppTypes.CommonStatus status) { shortStockCodeTA.ClearBeforeFill = false; shortStockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); }
public static CultureInfo Code2Culture(AppTypes.LanguageCodes value) { switch (value) { case AppTypes.LanguageCodes.VI: return common.language.GetCulture("vi-VN"); default: return common.language.GetCulture("en-US"); } }
/// <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 baseDS.portfolioDetailDataTable GetPortfolioDetail_ByType(AppTypes.PortfolioTypes[] types) { baseDS.portfolioDetailDataTable tbl = new baseDS.portfolioDetailDataTable(); byte typeMask = 0; for (int idx = 0; idx < types.Length; idx++) typeMask += (byte)types[idx]; DbAccess.LoadData(tbl, typeMask); return tbl; }
public static baseDS.tradeAlertRow GetOneAlert(DateTime onDateTime, string portfolio, string stockCode, string strategy, string timeScale, AppTypes.CommonStatus status) { baseDS.tradeAlertDataTable tbl = tradeAlertTA.GetOne(onDateTime, onDateTime, portfolio, stockCode, strategy, timeScale, ((byte)status).ToString()); if (tbl == null || tbl.Count == 0) return null; return tbl[0]; }
public static tmpDS.marketDataDataTable GetMarketData(DateTime frDate, DateTime toDate, string codeList, AppTypes.TimeScale timeScale, AppTypes.MarketDataTypes type) { string sqlCond = ""; if (timeScale != AppTypes.MainDataTimeScale) { sqlCond += (sqlCond == "" ? "" : " AND ") + " type='" + timeScale.Code + "'"; } sqlCond += (sqlCond == "" ? "" : " AND ") + "onDate BETWEEN '" + common.system.ConvertToSQLDateString(frDate) + "'" + " AND '" + common.system.ConvertToSQLDateString(toDate) + "'"; sqlCond += (sqlCond == "" ? "" : " AND "); switch (type) { case AppTypes.MarketDataTypes.Advancing: sqlCond += "closePrice>openPrice"; break; case AppTypes.MarketDataTypes.Declining: sqlCond += "closePrice<openPrice"; break; default: sqlCond += "closePrice=openPrice"; break; } if (codeList != null && codeList != "") { sqlCond += (sqlCond == "" ? "" : " AND ") + " stockCode IN (" + codeList + ")"; } else { sqlCond += (sqlCond == "" ? "" : " AND ") + " stockCode IN (SELECT code FROM stockCode WHERE status & " + ((byte)AppTypes.CommonStatus.Enable).ToString() + ">0)"; } string sqlCmd = "SELECT onDate,COUNT(*) AS val0,SUM(volume) AS val1" + " FROM " + (timeScale == AppTypes.MainDataTimeScale ? "priceData" : "priceDataSum") + " WHERE " + sqlCond + " GROUP BY onDate ORDER BY onDate"; tmpDS.marketDataDataTable tbl = new tmpDS.marketDataDataTable(); DbAccess.LoadFromSQL(tbl, sqlCmd); return tbl; }
public static baseDS.lastPriceDataDataTable GetLastPrice(AppTypes.PriceDataType type, string timeScaleCode, DateTime fromDate) { WriteLog(common.SysSeverityLevel.Informational, "", type.ToString() + " " + timeScaleCode + " " + fromDate.ToString() ); try { switch (type) { case AppTypes.PriceDataType.High: return lastPriceDataTA.GetHighSum(timeScaleCode, fromDate); case AppTypes.PriceDataType.Low: return lastPriceDataTA.GetLowSum(timeScaleCode, fromDate); case AppTypes.PriceDataType.Close: return lastPriceDataTA.GetCloseSum(timeScaleCode, fromDate); case AppTypes.PriceDataType.Open: return lastPriceDataTA.GetOpenSum(timeScaleCode, fromDate); case AppTypes.PriceDataType.Volume: return lastPriceDataTA.GetVolumeSum(timeScaleCode, fromDate); default: WriteLog(common.SysSeverityLevel.Error, "DB004", "Invalid call to GetLastPrice()"); break; } } catch (Exception er) { WriteLog(common.SysSeverityLevel.Error, "DB003" , er); } return null; }
public static void LoadData(baseDS.portfolioDataTable tbl, AppTypes.PortfolioTypes type) { portfolioTA.ClearBeforeFill = false; portfolioTA.FillByTypeMask(tbl, ((byte)type).ToString()); }
public static void LoadStockCode_ByStockExchange(tmpDS.stockCodeDataTable tbl, string stockExchange, AppTypes.CommonStatus status) { shortStockCodeTA.FillByStockExchange(tbl, stockExchange,((byte)status).ToString()); }
public virtual void LoadData(AppTypes.StrategyTypes type,bool onlyEnableItem,bool checkAll) { this.strategyClb.LoadData(type); this.strategyCatCb.LoadData(true); }
public static baseDS.priceDataStatDataTable GetPriceDataStat(AppTypes.TimeScale timeScale, string code) { if (timeScale == AppTypes.MainDataTimeScale) return priceDataStatTA.GetStatByCode(code); return priceDataStatTA.GetStatByTypeAndCode(timeScale.Code, code); }
public static string TimeScaleTypeToCode(AppTypes.TimeScaleTypes type) { foreach (AppTypes.TimeScale item in myTimeScales) { if (item.Type == type) return item.Code; } return MainDataTimeScale.Code; }
public static int GetTotalPriceRow(AppTypes.TimeScale timeScale, DateTime frDate, DateTime toDate, string stockCode) { switch (timeScale.Type) { case AppTypes.TimeScaleTypes.RealTime: return (int)priceDataTA.GetTotalRow(frDate, toDate, stockCode); default: return (int)priceDataTA.GetTotalSumRow(timeScale.Code, frDate, toDate, stockCode); } }
public static bool GetDate(AppTypes.TimeRanges timeRange, out DateTime startDate, out DateTime endDate) { startDate = common.Consts.constNullDate; endDate = common.Consts.constNullDate; bool retVal = true; switch (timeRange) { case AppTypes.TimeRanges.W1: endDate = DateTime.Today; startDate = endDate.AddDays(-7); break; case AppTypes.TimeRanges.W2: endDate = DateTime.Today; startDate = endDate.AddDays(-14); break; case AppTypes.TimeRanges.W3: endDate = DateTime.Today; startDate = endDate.AddDays(-21); break; case AppTypes.TimeRanges.M1: endDate = DateTime.Today; startDate = endDate.AddMonths(-1); break; case AppTypes.TimeRanges.M2: endDate = DateTime.Today; startDate = endDate.AddMonths(-2); break; case AppTypes.TimeRanges.M3: endDate = DateTime.Today; startDate = endDate.AddMonths(-3); break; case AppTypes.TimeRanges.M4: endDate = DateTime.Today; startDate = endDate.AddMonths(-5); break; case AppTypes.TimeRanges.M5: endDate = DateTime.Today; startDate = endDate.AddMonths(-5); break; case AppTypes.TimeRanges.M6: endDate = DateTime.Today; startDate = endDate.AddMonths(-6); break; case AppTypes.TimeRanges.YTD: endDate = DateTime.Today; common.dateTimeLibs.MakeDate(1, 1, endDate.Year, out startDate); break; case AppTypes.TimeRanges.Y1: endDate = DateTime.Today; startDate = endDate.AddYears(-1); break; case AppTypes.TimeRanges.Y2: endDate = DateTime.Today; startDate = endDate.AddYears(-2); break; case AppTypes.TimeRanges.Y3: endDate = DateTime.Today; startDate = endDate.AddYears(-3); break; case AppTypes.TimeRanges.Y4: endDate = DateTime.Today; startDate = endDate.AddYears(-4); break; case AppTypes.TimeRanges.Y5: endDate = DateTime.Today; startDate = endDate.AddYears(-5); break; case AppTypes.TimeRanges.All: startDate = DateTime.MinValue; endDate = DateTime.MaxValue; return true; default: retVal = false; break; } endDate = endDate.Date.AddDays(1).AddSeconds(-1); return retVal; }
public static void LoadData(baseDS.stockCodeDataTable tbl, AppTypes.CommonStatus status) { try { stockCodeTA.ClearBeforeFill = false; stockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); } catch (Exception er) { WriteLog(common.SysSeverityLevel.Alert, "AAA2 ", er); } }