protected override void SaveData() { data.baseDS.portfolioDetailDataTable defaultStrategyTbl = DataAccess.Libs.GetPortfolioDetail_ByCode(DataAccess.Libs.GetPortfolio_DefaultStrategy().code); data.baseDS.portfolioDetailDataTable portfolioDetailTbl; for (int portfolioIdx = 0; portfolioIdx < watchListLb.myCheckedValues.Count; portfolioIdx++) { data.baseDS.portfolioRow portfolioRow = DataAccess.Libs.GetPortfolio_ByCode(watchListLb.myCheckedValues[portfolioIdx]); if (portfolioRow == null) { continue; } portfolioDetailTbl = DataAccess.Libs.GetPortfolioDetail_ByCode(portfolioRow.code); mvString.myFormatString = portfolioRow.interestedStock; for (int stockIdx = 0; stockIdx < myStockCodes.Count; stockIdx++) { if (!mvString.Add(myStockCodes[stockIdx])) { continue; } mvString.Add(myStockCodes[stockIdx]); //Add default portfolio data DeletePortfolioData(portfolioDetailTbl, portfolioRow.code, myStockCodes[stockIdx]); commonClass.AppLibs.CopyPortfolioData(defaultStrategyTbl, portfolioDetailTbl, portfolioRow.code, myStockCodes[stockIdx]); } portfolioRow.interestedStock = mvString.myFormatString; DataAccess.Libs.UpdateData(portfolioRow); DataAccess.Libs.UpdateData(portfolioDetailTbl); } common.system.ShowMessage(Languages.Libs.GetString("dataSaved")); }
public watchListEdit() { try { InitializeComponent(); this.LoadDataOnLoad = false; myMasterSource = portfolioSource; codeEd.MaxLength = myDataSet.portfolio.codeColumn.MaxLength; nameEd.MaxLength = myDataSet.portfolio.nameColumn.MaxLength; descriptionEd.MaxLength = myDataSet.portfolio.descriptionColumn.MaxLength; interestedStockClb.maxLen = myDataSet.portfolio.interestedStockColumn.MaxLength; interestedStrategy.Init(); interestedStockClb.LoadData(); //Load default Portfolio Data this.defaultStrategyTbl = DataAccess.Libs.GetPortfolioDetail_ByCode(DataAccess.Libs.GetPortfolio_DefaultStrategy().code); codeEd.BackColor = common.settings.sysColorDisableBG; codeEd.ForeColor = common.settings.sysColorDisableFG; LockEdit(true); Form_Resize(null, null); } catch (Exception er) { ShowError(er); } }
private void CreateTreeView(data.baseDS.portfolioDetailDataTable dataTbl, TreeGridView treeGV) { if (this.myPorfolioCode == null || this.myStockCode == null) { return; } DataView dataView = new DataView(dataTbl); dataView.Sort = dataTbl.subCodeColumn.ColumnName; dataView.RowFilter = dataTbl.portfolioColumn + "='" + this.myPorfolioCode + "' AND " + dataTbl.codeColumn + "='" + this.myStockCode + "'"; data.baseDS.portfolioDetailRow dataRow; Font boldFont = new Font(treeGV.DefaultCellStyle.Font, FontStyle.Bold); string lastStrategy = ""; TreeGridNodeCollection strategyNodes = null; for (int idx = 0; idx < dataView.Count; idx++) { dataRow = (data.baseDS.portfolioDetailRow)dataView[idx].Row; if (lastStrategy != dataRow.subCode.Trim()) { strategyNodes = AddNode(treeGV.Nodes, dataRow.subCode, GetStrategyDescription(dataRow.subCode), boldFont).Nodes; lastStrategy = dataRow.subCode.Trim(); } AddNodes((strategyNodes == null ? treeGV.Nodes : strategyNodes), dataRow, null); } }
public watchListEdit() { try { InitializeComponent(); this.LoadDataOnLoad = false; myMasterSource = portfolioSource; codeEd.MaxLength = myDataSet.portfolio.codeColumn.MaxLength; nameEd.MaxLength = myDataSet.portfolio.nameColumn.MaxLength; descriptionEd.MaxLength = myDataSet.portfolio.descriptionColumn.MaxLength; interestedStockClb.maxLen = myDataSet.portfolio.interestedStockColumn.MaxLength; interestedStrategy.Init(); interestedStockClb.LoadData(); //Load default Portfolio Data this.defaultStrategyTbl = DataAccess.Libs.GetPortfolioDetail_ByCode(DataAccess.Libs.GetPortfolio_DefaultStrategy().code); codeEd.BackColor = common.settings.sysColorDisableBG; codeEd.ForeColor = common.settings.sysColorDisableFG; LockEdit(true); Form_Resize(null, null); } catch (Exception er) { ShowError(er); } }
/// <summary> /// Create alerts for all stock in portfolio /// </summary> /// <param name="alertList"> all alert resulted from analysis </param> /// <param name="frDate">Alert will only create alert in range [frDate,toDate]. /// It also ensure that in the same day,there in ONLY one new alert of the same type</param> /// <param name="toDate"></param> private static void CreateTradeAlert(TradeAlert[] alertList,DateTime frDate,DateTime toDate) { decimal availabeQty; string msg; StringCollection timeScaleList; data.baseDS.tradeAlertRow tradeAlertRow; data.baseDS.tradeAlertDataTable tradeAlertTbl = new data.baseDS.tradeAlertDataTable(); data.baseDS.portfolioDetailDataTable portfolioDetailTbl = new data.baseDS.portfolioDetailDataTable(); DataView portfolioDetailView = new DataView(portfolioDetailTbl); //Sort by Stock code + Strategy code portfolioDetailView.Sort = portfolioDetailTbl.codeColumn.ColumnName + "," + portfolioDetailTbl.subCodeColumn.ColumnName; DataRowView[] portfolioDetailFound; data.baseDS.portfolioDetailRow portfolioDataRow; portfolioDetailTbl = data.DbAccess.GetPortfolioDetail_ByType(new AppTypes.PortfolioTypes[] { AppTypes.PortfolioTypes.WatchList, AppTypes.PortfolioTypes.Portfolio }); // Only alert on stock codes that were selected by user. for (int alertId = 0; alertId < alertList.Length; alertId++) { // Check if alert's strategy in user's wish list ?? portfolioDetailFound = portfolioDetailView.FindRows(new object[] { alertList[alertId].StockCode, alertList[alertId].Strategy.Trim() }); for (int dataIdx = 0; dataIdx < portfolioDetailFound.Length; dataIdx++) { // Check if time alert's time scale in user's wish list ?? portfolioDataRow = ((data.baseDS.portfolioDetailRow)portfolioDetailFound[dataIdx].Row); timeScaleList = common.MultiValueString.String2List(portfolioDataRow.data.Trim()); if (!timeScaleList.Contains(alertList[alertId].TimeScale.Code)) continue; //Do not crete alert if there is a NEW one. tradeAlertRow = data.DbAccess.GetLastAlert( frDate, toDate, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy, alertList[alertId].TimeScale.Code, (byte)AppTypes.CommonStatus.New); if (tradeAlertRow != null) continue; //Availabe stock if (withAplicableCheckInAlert) { availabeQty = data.AppLibs.GetAvailableStock(alertList[alertId].StockCode, portfolioDataRow.portfolio, Settings.sysStockSell2BuyInterval, alertList[alertId].OnDateTime); } else availabeQty = int.MaxValue; //Aplicable to sell if ((alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.Sell || alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.ClearAll) && (availabeQty <= 0)) continue; msg = " - Giá : " + alertList[alertId].Price.ToString() + common.Consts.constCRLF + " - K/L giao dịch : " + alertList[alertId].Volume.ToString() + common.Consts.constCRLF + " - Xu hướng : (" + alertList[alertId].TradePoint.BusinessInfo.ToString() + "," + alertList[alertId].TradePoint.BusinessInfo.LongTermTrend + ")" + common.Consts.constCRLF + " - K/L sở hữu hợp lệ : " + availabeQty.ToString() + common.Consts.constCRLF; CreateTradeAlert(tradeAlertTbl, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy, alertList[alertId].TimeScale, alertList[alertId].TradePoint, toDate, msg); } } data.DbAccess.UpdateData(tradeAlertTbl); }
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); }
private void DeletePortfolioData(data.baseDS.portfolioDetailDataTable dataTbl, string portfolioCode, string code) { for (int idx = 0; idx < dataTbl.Count; idx++) { if (dataTbl[idx].RowState == DataRowState.Deleted) { continue; } if ((dataTbl[idx].portfolio == portfolioCode) && (dataTbl[idx].code == code)) { dataTbl[idx].Delete(); } } }
/// <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(data.baseDS.portfolioDetailDataTable frDataTbl, data.baseDS.portfolioDetailDataTable toDataTbl, string porfolioCode, string stockCode) { data.baseDS.portfolioDetailRow row; for (int idx = 0; idx < frDataTbl.Rows.Count; idx++) { row = toDataTbl.NewportfolioDetailRow(); InitData(row); row.portfolio = porfolioCode; row.code = stockCode; row.subCode = frDataTbl[idx].subCode;; row.data = frDataTbl[idx].data; toDataTbl.AddportfolioDetailRow(row); } }
public void UpdatePortfolioDetail(ref data.baseDS.portfolioDetailDataTable tbl) { DbAccess.UpdateData(tbl); }
public data.baseDS.portfolioDetailDataTable GetPortfolioDetail_ByCode(string portfolioCode) { data.baseDS.portfolioDetailDataTable tbl = new data.baseDS.portfolioDetailDataTable(); DbAccess.LoadData(tbl, portfolioCode); return(tbl); }
public static void UpdateData(data.baseDS.portfolioDetailDataTable tbl) { myClient.UpdatePortfolioDetail(ref tbl); tbl.AcceptChanges(); }
public static void LoadData(data.baseDS.portfolioDetailDataTable tbl, string portfolioCode) { portfolioDetailTA.ClearBeforeFill = false; portfolioDetailTA.FillByPortfolio(tbl, portfolioCode); }
/// <summary> /// Create alerts for all stock in portfolio /// </summary> /// <param name="alertList"> all alert resulted from analysis </param> private static void CreateTradeAlert(TradeAlert[] alertList) { decimal availabeQty; string msg; StringCollection timeScaleList; data.baseDS.tradeAlertRow tradeAlertRow; data.baseDS.tradeAlertDataTable tradeAlertTbl = new data.baseDS.tradeAlertDataTable(); data.baseDS.portfolioDetailDataTable portfolioDetailTbl = application.DbAccess.GetPortfolioDetail_ByType(new AppTypes.PortfolioTypes[] { AppTypes.PortfolioTypes.WatchList, AppTypes.PortfolioTypes.Portfolio }); DataView portfolioDetailView = new DataView(portfolioDetailTbl); //Sort by Stock code + Strategy code portfolioDetailView.Sort = portfolioDetailTbl.codeColumn.ColumnName + "," + portfolioDetailTbl.subCodeColumn.ColumnName; DataRowView[] portfolioDetailFound; data.baseDS.portfolioDetailRow portfolioDataRow; // Only alert on stock codes that were selected by user. for (int alertId = 0; alertId < alertList.Length; alertId++) { // Check if alert's strategy in user's wish list ?? portfolioDetailFound = portfolioDetailView.FindRows(new object[] { alertList[alertId].StockCode, alertList[alertId].Strategy.Trim() }); for (int dataIdx = 0; dataIdx < portfolioDetailFound.Length; dataIdx++) { // Check if time alert's time scale in user's wish list ?? portfolioDataRow = ((data.baseDS.portfolioDetailRow)portfolioDetailFound[dataIdx].Row); timeScaleList = common.MultiValueString.String2List(portfolioDataRow.data.Trim()); if (!timeScaleList.Contains(alertList[alertId].TimeScale.Code)) { continue; } //Ignore duplicate alerts. tradeAlertRow = application.DbAccess.GetAlert(alertList[alertId].OnDateTime, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy, alertList[alertId].TimeScale.Code, AppTypes.CommonStatus.All); if (tradeAlertRow != null) { continue; } //Availabe stock if (withAplicableCheckInAlert) { data.baseDS.stockExchangeRow stockExchangeRow = application.AppLibs.GetStockExchange(alertList[alertId].StockCode); int sell2BuyInterval = (stockExchangeRow == null?0:stockExchangeRow.minBuySellDay); availabeQty = application.DbAccess.GetAvailableStock(alertList[alertId].StockCode, portfolioDataRow.portfolio, sell2BuyInterval, alertList[alertId].OnDateTime); } else { availabeQty = 0; } //Aplicable to sell if ((alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.Sell || alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.ClearAll) && (availabeQty <= 0)) { continue; } string infoText = alertList[alertId].TradePoint.BusinessInfo.ToText().Trim(); infoText = (infoText != "" ? infoText : common.Consts.constNotAvailable); //Create alert template message, AlertMessageText() will convert it to specified-language text. msg = commonClass.Consts.constTextMergeMarkerLEFT + "price" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + alertList[alertId].Price.ToString() + common.Consts.constCRLF + commonClass.Consts.constTextMergeMarkerLEFT + "volume" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + alertList[alertId].Volume.ToString() + common.Consts.constCRLF + commonClass.Consts.constTextMergeMarkerLEFT + "marketInfo" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + infoText + common.Consts.constCRLF; if (availabeQty > 0) { msg += commonClass.Consts.constTextMergeMarkerLEFT + "ownedQty" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + availabeQty.ToString() + common.Consts.constCRLF; } CreateTradeAlert(tradeAlertTbl, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy, alertList[alertId].TimeScale, alertList[alertId].TradePoint, alertList[alertId].OnDateTime, msg); } } application.DbAccess.UpdateData(tradeAlertTbl); }
public data.baseDS.portfolioDetailDataTable GetPortfolioDetail_ByCode(string portfolioCode) { data.baseDS.portfolioDetailDataTable tbl = new data.baseDS.portfolioDetailDataTable(); DbAccess.LoadData(tbl, portfolioCode); return tbl; }
public static void UpdateData(data.baseDS.portfolioDetailDataTable tbl) { portfolioDetailTA.Update(tbl); tbl.AcceptChanges(); }
public static void LoadData(data.baseDS.portfolioDetailDataTable tbl, byte typeMask) { portfolioDetailTA.ClearBeforeFill = false; portfolioDetailTA.FillByTypeMask(tbl, ((byte)typeMask).ToString()); }
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; }
/// <summary> /// Create alerts for all stock in portfolio /// </summary> /// <param name="alertList"> all alert resulted from analysis </param> /// <param name="frDate">Alert will only create alert in range [frDate,toDate]. /// It also ensure that in the same day,there in ONLY one new alert of the same type</param> /// <param name="toDate"></param> private static void CreateTradeAlert(TradeAlert[] alertList, DateTime frDate, DateTime toDate) { decimal availabeQty; string msg; StringCollection timeScaleList; data.baseDS.tradeAlertRow tradeAlertRow; data.baseDS.tradeAlertDataTable tradeAlertTbl = new data.baseDS.tradeAlertDataTable(); data.baseDS.portfolioDetailDataTable portfolioDetailTbl = new data.baseDS.portfolioDetailDataTable(); DataView portfolioDetailView = new DataView(portfolioDetailTbl); //Sort by Stock code + Strategy code portfolioDetailView.Sort = portfolioDetailTbl.codeColumn.ColumnName + "," + portfolioDetailTbl.subCodeColumn.ColumnName; DataRowView[] portfolioDetailFound; data.baseDS.portfolioDetailRow portfolioDataRow; portfolioDetailTbl = data.DbAccess.GetPortfolioDetail_ByType(new AppTypes.PortfolioTypes[] { AppTypes.PortfolioTypes.WatchList, AppTypes.PortfolioTypes.Portfolio }); // Only alert on stock codes that were selected by user. for (int alertId = 0; alertId < alertList.Length; alertId++) { // Check if alert's strategy in user's wish list ?? portfolioDetailFound = portfolioDetailView.FindRows(new object[] { alertList[alertId].StockCode, alertList[alertId].Strategy.Trim() }); for (int dataIdx = 0; dataIdx < portfolioDetailFound.Length; dataIdx++) { // Check if time alert's time scale in user's wish list ?? portfolioDataRow = ((data.baseDS.portfolioDetailRow)portfolioDetailFound[dataIdx].Row); timeScaleList = common.MultiValueString.String2List(portfolioDataRow.data.Trim()); if (!timeScaleList.Contains(alertList[alertId].TimeScale.Code)) { continue; } //Do not crete alert if there is a NEW one. tradeAlertRow = data.DbAccess.GetLastAlert(frDate, toDate, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy, alertList[alertId].TimeScale.Code, (byte)AppTypes.CommonStatus.New); if (tradeAlertRow != null) { continue; } //Availabe stock if (withAplicableCheckInAlert) { availabeQty = data.AppLibs.GetAvailableStock(alertList[alertId].StockCode, portfolioDataRow.portfolio, Settings.sysStockSell2BuyInterval, alertList[alertId].OnDateTime); } else { availabeQty = int.MaxValue; } //Aplicable to sell if ((alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.Sell || alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.ClearAll) && (availabeQty <= 0)) { continue; } msg = " - Giá : " + alertList[alertId].Price.ToString() + common.Consts.constCRLF + " - K/L giao dịch : " + alertList[alertId].Volume.ToString() + common.Consts.constCRLF + " - Xu hướng : (" + alertList[alertId].TradePoint.BusinessInfo.ToString() + "," + alertList[alertId].TradePoint.BusinessInfo.LongTermTrend + ")" + common.Consts.constCRLF + " - K/L sở hữu hợp lệ : " + availabeQty.ToString() + common.Consts.constCRLF; CreateTradeAlert(tradeAlertTbl, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy, alertList[alertId].TimeScale, alertList[alertId].TradePoint, toDate, msg); } } data.DbAccess.UpdateData(tradeAlertTbl); }