public BusinessInfo(AppTypes.MarketTrend shortTerm, AppTypes.MarketTrend mediumTerm, AppTypes.MarketTrend longTerm, double weight) { this.ShortTermTrend = shortTerm; this.MediumTermTrend = mediumTerm; this.LongTermTrend = longTerm; this.Weight = weight; }
public TradeAlert(string stockCode, string strategy, AppTypes.TimeScale timeScale, DateTime onDateTime, double price, double volume, TradePointInfo tradePoint) { this.StockCode = stockCode; this.TimeScale = timeScale; this.Strategy = strategy; this.OnDateTime = onDateTime; this.Price = price; this.Volume = volume; this.TradePoint = tradePoint; }
public data.baseDS.portfolioRow ShowNew(AppTypes.PortfolioTypes type,string investorCode) { codeEd.Text = commonClass.Consts.constNotMarkerNEW; nameEd.Text = ""; descriptionEd.Text = ""; this.nameEd.Focus(); this.myInvestorCode = investorCode; this.myPortfolioType = type; this.ShowDialog(); return (myPortfolioTbl.Count>0?myPortfolioTbl[0]:null); }
public void ShowForm(string stockCode, StringCollection strategyCodes, AppTypes.TimeScale timeScale) { watchListLb.LoadData(commonClass.SysLibs.sysLoginCode, false); this.myStrategyCodes = strategyCodes; this.codeEd.Text = stockCode; this.timeScaleCb.myValue = timeScale; strategyLb.Items.Clear(); for (int idx = 0; idx < strategyCodes.Count; idx++) { strategyLb.Items.Add(application.Strategy.Libs.GetMetaName(strategyCodes[idx])); } this.timeScaleCb.myValue = timeScale; this.ShowDialog(); }
protected void ShowTradeTransactions(data.tmpDS.stockCodeRow stockCodeRow, string strategyCode, AppTypes.TimeRanges timeRange,AppTypes.TimeScale timeScale) { string formName = stockCodeRow.code.Trim() + "," + timeRange.ToString() + "," + application.Strategy.Libs.GetMetaName(strategyCode) + "," + timeScale.Code; profitEstimate myForm = profitEstimate.GetForm(formName); myForm.myTimeRange = timeRange; myForm.myTimeScale = timeScale; myForm.myStockCode = stockCodeRow.code; myForm.myOptions = new EstimateOptions(); myForm.myStrategyCode = strategyCode; myForm.ReLoad(); myForm.Text = "(" + formName + ")"; if (this.myDockedPane != null) myForm.Show(this.myDockedPane); else myForm.ShowDialog(); }
public static decimal[][] Estimate_Matrix_Profit(AppTypes.TimeRanges timeRange, string timeScaleCode, string[] stocks, string[] strategyList, EstimateOptions option) { return myClient.Estimate_Matrix_Profit(timeRange, timeScaleCode, stocks, strategyList, option); }
public static data.baseDS.transactionsDataTable MakeTransaction(AppTypes.TradeActions type, string stockCode, string portfolioCode, int qty, decimal feePerc) { string errorText = ""; data.baseDS.transactionsDataTable retVal = myClient.MakeTransaction(out errorText, type, stockCode, portfolioCode, qty, feePerc); if (retVal == null) common.system.ShowErrorMessage(errorText); return retVal; }
private static void CreateTradeAlert(data.baseDS.tradeAlertDataTable tradeAlertTbl,string portfolioCode, string stockCode, string strategy, AppTypes.TimeScale timeScale, TradePointInfo info, DateTime onTime, string msg) { data.baseDS.tradeAlertRow row = tradeAlertTbl.NewtradeAlertRow(); data.AppLibs.InitData(row); row.onTime = onTime; row.portfolio = portfolioCode; row.stockCode = stockCode; row.timeScale = timeScale.Code; row.strategy = strategy; row.status = (byte)AppTypes.CommonStatus.New; row.tradeAction = (byte)info.TradeAction; row.subject = info.TradeAction.ToString(); row.msg = msg; tradeAlertTbl.AddtradeAlertRow(row); }
public static double[][] Estimate_Matrix_LastBizWeight(AppTypes.TimeRanges timeRange, string timeScaleCode, string[] stockCodeList, string[] strategyList) { return myClient.Estimate_Matrix_LastBizWeight(timeRange, timeScaleCode, stockCodeList, strategyList); }
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 void LoadStockCode_ByStatus(data.baseDS.stockCodeDataTable tbl,AppTypes.CommonStatus status) { stockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); }
public static tradeAnalysis GetForm(string stockCode,AppTypes.TimeRanges timeRange, AppTypes.TimeScale timeScale) { string cacheKey = typeof(tradeAnalysis).ToString(); tradeAnalysis form = (tradeAnalysis)common.Data.dataCache.Find(cacheKey); if (form == null || form.IsDisposed) { form = new Forms.tradeAnalysis(); common.Data.dataCache.Add(cacheKey, form); } form.ChartTimeRange = timeRange; form.ChartTimeScale = timeScale; form.ChartPriceType = AppTypes.ChartTypes.Line; form.UseStock(DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode)); form.Visible = true; return form; }
public BaseAnalysisData() { this.DataTimeScale = AppTypes.TimeScaleFromCode(Settings.sysGlobal.DefaultTimeScaleCode); this.DataTimeRange = AppTypes.TimeRanges.None; this.DataStockCode = ""; }
public TradePointInfo(AppTypes.TradeActions action, int dataIdx, BusinessInfo info) { this.TradeAction = action; this.DataIdx = dataIdx; this.BusinessInfo.Set(info); }
public static CultureInfo Code2Culture(AppTypes.LanguageCodes value) { switch (value) { case AppTypes.LanguageCodes.VI: return common.language.CreateCulture("vi-VN"); default: return common.language.CreateCulture("en-US"); } }
public TradePointInfo(AppTypes.TradeActions action, int dataIdx) { this.TradeAction = action; this.DataIdx = dataIdx; }
//Agrregate date time for hourly,daily data... //public static DateTime AggregateDateTime(AppTypes.timeScales type, DateTime onDateTime, CultureInfo ci) //{ // switch (type) // { // case AppTypes.timeScales.Hour1: // return onDateTime.Date.AddHours(onDateTime.Hour); // case AppTypes.timeScales.Hour2: // return onDateTime.Date.AddHours(onDateTime.Hour / 2); // case AppTypes.timeScales.Hour4: // return onDateTime.Date.AddHours(onDateTime.Hour / 4); // case AppTypes.timeScales.Daily: // return onDateTime.Date; // case AppTypes.timeScales.Weekly: // return common.dateTimeLibs.StartOfWeek(onDateTime, ci); // case AppTypes.timeScales.Monthly: // return common.dateTimeLibs.MakeDate(1, onDateTime.Month, onDateTime.Year); // case AppTypes.timeScales.Yearly: // return common.dateTimeLibs.MakeDate(1, 1, onDateTime.Year); // default: // common.system.ThrowException("Invalid argument in AggregateDateTime()"); // break; // } // return onDateTime; //} /// <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(data.baseDS.priceDataRow priceRow, decimal changeVolume, AppTypes.TimeScale timeScale, CultureInfo cultureInfo,data.baseDS.priceDataSumDataTable toSumTbl) { DateTime dataDate = AggregateDateTime(timeScale, priceRow.onDate, cultureInfo); int dataTimeOffset = common.dateTimeLibs.DateDiffInMilliseconds(dataDate, priceRow.onDate); data.baseDS.priceDataSumRow priceDataSumRow; priceDataSumRow = libs.FindAndCache(toSumTbl, priceRow.stockCode, timeScale.Code, dataDate); if (priceDataSumRow == null) { priceDataSumRow = toSumTbl.NewpriceDataSumRow(); commonClass.AppLibs.InitData(priceDataSumRow); priceDataSumRow.type = timeScale.Code; priceDataSumRow.stockCode = priceRow.stockCode; priceDataSumRow.onDate = dataDate; priceDataSumRow.openPrice = priceRow.openPrice; priceDataSumRow.closePrice = priceRow.closePrice; toSumTbl.AddpriceDataSumRow(priceDataSumRow); } if (priceDataSumRow.openTimeOffset > dataTimeOffset) { priceDataSumRow.openPrice = priceRow.openPrice; priceDataSumRow.openTimeOffset = dataTimeOffset; } if (priceDataSumRow.closeTimeOffset <= dataTimeOffset) { priceDataSumRow.closePrice = priceRow.closePrice; priceDataSumRow.closeTimeOffset = dataTimeOffset; } if (priceDataSumRow.highPrice < priceRow.highPrice) priceDataSumRow.highPrice = priceRow.highPrice; if (priceDataSumRow.lowPrice > priceRow.lowPrice) priceDataSumRow.lowPrice = priceRow.lowPrice; priceDataSumRow.volume += changeVolume; }
/// <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(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 TradePointInfo[] GetTradePointWithEstimationDetail(AppTypes.TimeRanges timeRange, string timeScaleCode, string stockCode, string strategyCode, EstimateOptions options, out data.tmpDS.tradeEstimateDataTable toTbl) { return myClient.GetTradePointWithEstimationDetail(out toTbl, timeRange, timeScaleCode, stockCode, strategyCode, options); }
public static void LoadData(data.baseDS.portfolioDataTable tbl, AppTypes.PortfolioTypes type) { portfolioTA.ClearBeforeFill = false; portfolioTA.FillByTypeMask(tbl, ((byte)type).ToString()); }
public static void SetLanguage() { AppTypes.ReLoadTimeScales(); }
private void AddStockToWatchList(string stockCode,StringCollection strategyCodes,AppTypes.TimeScale timeScale) { baseClass.Forms.addToWatchList_StockAndStrategy myForm = baseClass.Forms.addToWatchList_StockAndStrategy.GetForm(""); myForm.ShowForm(stockCode,strategyCodes,timeScale); }
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 void SetTrend(AppTypes.MarketTrend shortTerm, AppTypes.MarketTrend mediumTerm, AppTypes.MarketTrend longTerm) { this.ShortTermTrend = shortTerm; this.MediumTermTrend = mediumTerm; this.LongTermTrend = longTerm; }
public static void LoadData(data.tmpDS.stockCodeDataTable tbl, AppTypes.CommonStatus status) { shortStockCodeTA.ClearBeforeFill = false; shortStockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); }
public void SetFilterStatus(AppTypes.CommonStatus status) { myAlertFilterForm.myStatus = status; }
public static data.baseDS.portfolioDetailDataTable GetPortfolioDetail_ByType(AppTypes.PortfolioTypes[] types) { data.baseDS.portfolioDetailDataTable tbl = new data.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 data.baseDS.portfolioDataTable GetPortfolio_ByType(AppTypes.PortfolioTypes type) { return myClient.GetPortfolio_ByType(type); }
public static void LoadPortfolioByInvestor(data.baseDS.portfolioDataTable tbl, string investorCode,AppTypes.PortfolioTypes type) { portfolioTA.ClearBeforeFill = false; portfolioTA.FillByInvestorCodeAndTypeMask(tbl, investorCode,((byte)type).ToString()); }
public static data.baseDS.portfolioDataTable GetPortfolio_ByInvestorAndType(string investorCode, AppTypes.PortfolioTypes type) { return myClient.GetPortfolio_ByInvestorAndType(investorCode,type); }
public static void LoadStockCode_ByStockExchange(data.tmpDS.stockCodeDataTable tbl, string stockExchange, AppTypes.CommonStatus status) { shortStockCodeTA.FillByStockExchange(tbl, stockExchange,((byte)status).ToString()); }
public static data.baseDS.portfolioDetailDataTable GetPortfolioDetail_ByType(AppTypes.PortfolioTypes[] types) { return myClient.GetPortfolioDetail_ByType(types); }