private void DoRefreshPrice(databases.tmpDS.stockCodeDataTable dataTbl) { databases.baseDS.lastPriceDataDataTable openPriceTbl = DataAccess.Libs.myLastDailyOpenPrice; databases.baseDS.lastPriceDataDataTable closePriceTbl = DataAccess.Libs.myLastDailyClosePrice; //databases.baseDS.lastPriceDataDataTable volumeTbl = DataAccess.Libs.myLastDailyVolume; if (openPriceTbl == null || closePriceTbl == null) { return; } dataTbl.priceColumn.ReadOnly = false; dataTbl.priceVariantColumn.ReadOnly = false; databases.tmpDS.stockCodeRow stockCodeRow; databases.baseDS.lastPriceDataRow openPriceRow, closePriceRow; //databases.baseDS.lastPriceDataRow volumeRow; for (int idx = 0; idx < stockGV.RowCount; idx++) { //Lay stock code stockCodeRow = dataTbl.FindBycode(stockGV.Rows[idx].Cells[codeColumn.Name].Value.ToString()); if (stockCodeRow == null) { continue; } //Lay gia dong cua closePriceRow = closePriceTbl.FindBystockCode(stockCodeRow.code); if (closePriceRow == null) { continue; } if (stockCodeRow.price == closePriceRow.value) { continue; } //Lay chenh lech Open/Close stockCodeRow.price = closePriceRow.value; openPriceRow = openPriceTbl.FindBystockCode(stockCodeRow.code); if (openPriceRow != null && openPriceRow.value != 0) { stockCodeRow.priceVariant = (closePriceRow.value - openPriceRow.value) / openPriceRow.value; } else { stockCodeRow.priceVariant = 0; } //Lay volume //volumeRow = volumeTbl.FindBystockCode(stockCodeRow.code); //if (volumeRow == null) continue; //if (stockCodeRow.volume == volumeRow.value) continue; //stockCodeRow.volume = volumeRow.value; } SetColor(); }
private void DoRefreshPrice(databases.tmpDS.stockCodeDataTable dataTbl) { databases.baseDS.lastPriceDataDataTable openPriceTbl = DataAccess.Libs.myLastDailyOpenPrice; databases.baseDS.lastPriceDataDataTable closePriceTbl = DataAccess.Libs.myLastDailyClosePrice; if (openPriceTbl == null || closePriceTbl == null) { return; } dataTbl.priceColumn.ReadOnly = false; dataTbl.priceVariantColumn.ReadOnly = false; databases.tmpDS.stockCodeRow stockCodeRow; databases.baseDS.lastPriceDataRow openPriceRow, closePriceRow; for (int idx = 0; idx < stockGV.RowCount; idx++) { stockCodeRow = dataTbl.FindBycode(stockGV.Rows[idx].Cells[codeColumn.Name].Value.ToString()); if (stockCodeRow == null) { continue; } closePriceRow = closePriceTbl.FindBystockCode(stockCodeRow.code); if (closePriceRow == null) { continue; } if (stockCodeRow.price == closePriceRow.value) { continue; } stockCodeRow.price = closePriceRow.value; openPriceRow = openPriceTbl.FindBystockCode(stockCodeRow.code); if (openPriceRow != null) { stockCodeRow.priceVariant = closePriceRow.value - openPriceRow.value; } else { stockCodeRow.priceVariant = 0; } } SetColor(); }
protected void UpdatePrice(databases.tmpDS.porfolioWatchDataTable reportTbl) { databases.baseDS.lastPriceDataDataTable lastOpenPriceTbl = DataAccess.Libs.myLastDailyOpenPrice; databases.baseDS.lastPriceDataDataTable lastClosePriceTbl = DataAccess.Libs.myLastDailyClosePrice; databases.tmpDS.porfolioWatchRow reportRow; databases.baseDS.lastPriceDataRow priceRow; databases.baseDS.stockExchangeRow stockExchangeRow; for (int idx1 = 0; idx1 < reportTbl.Count; idx1++) { reportRow = reportTbl[idx1]; stockExchangeRow = DataAccess.Libs.myStockExchangeTbl.FindBycode(reportRow.stockExchange); if (stockExchangeRow == null || stockExchangeRow.priceRatio == 0) { continue; } decimal priceWeight = stockExchangeRow.priceRatio; decimal volumeWeight = stockExchangeRow.volumeRatio; reportRow.boughtPrice = (reportRow.qty == 0 ? 0 : reportRow.boughtAmt / reportRow.qty) / priceWeight; priceRow = lastClosePriceTbl.FindBystockCode(reportRow.code); if (priceRow != null) { reportRow.price = priceRow.value; priceRow = lastOpenPriceTbl.FindBystockCode(reportRow.code); if (priceRow != null) { reportRow.priceVariant = reportRow.price - priceRow.value; } else { reportRow.priceVariant = 0; } } reportRow.amt = reportRow.qty * reportRow.price * priceWeight; reportRow.profitVariantAmt = reportRow.amt - reportRow.boughtAmt; reportRow.profitVariantPerc = (reportRow.boughtAmt == 0 ? 0 : reportRow.profitVariantAmt / reportRow.boughtAmt) * 100; } }
private databases.tmpDS.dataVarrianceDataTable Market_DataDailyChange(StringCollection codes) { databases.baseDS.lastPriceDataRow lastPriceRowOpen, lastPriceRowClose; databases.baseDS.lastPriceDataDataTable openTbl = DataAccess.Libs.myLastDailyOpenPrice; databases.baseDS.lastPriceDataDataTable closeTbl = DataAccess.Libs.myLastDailyClosePrice; databases.tmpDS.dataVarrianceRow varrianceRow; databases.tmpDS.dataVarrianceDataTable tbl = new databases.tmpDS.dataVarrianceDataTable(); for (int idx = 0; idx < codes.Count; idx++) { lastPriceRowOpen = openTbl.FindBystockCode(codes[idx]); lastPriceRowClose = closeTbl.FindBystockCode(codes[idx]); if (lastPriceRowOpen == null || lastPriceRowClose == null) { continue; } decimal closePrice = lastPriceRowClose.value; decimal openPrice = lastPriceRowOpen.value; if (openPrice == 0 || closePrice == 0) { continue; } varrianceRow = tbl.NewdataVarrianceRow(); databases.AppLibs.InitData(varrianceRow); varrianceRow.code = codes[idx]; varrianceRow.val1 = openPrice; varrianceRow.val2 = closePrice; varrianceRow.value = (closePrice - openPrice); varrianceRow.percent = ((closePrice - openPrice) / openPrice) * 100; //DataRowView[] foundRows = alertView.FindRows(codes[idx]); //if (foundRows.Length > 0) //{ // varrianceRow.notes = (foundRows[0].Row as databases.baseDS.tradeAlertRow).msg; //} tbl.AdddataVarrianceRow(varrianceRow); } return(tbl); }