public void SetDataSource(System.Windows.Forms.BindingSource dataSrc) { this.myDataSource = dataSrc; data.baseDS.stockCodeDataTable tbl = (data.baseDS.stockCodeDataTable) this.myDataSource.DataSource; this.codeEd.DataBindings.Clear(); this.codeEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.codeColumn.ColumnName, true)); this.enNameEd.DataBindings.Clear(); this.enNameEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.nameColumn.ColumnName, true)); this.nameEd.DataBindings.Clear(); this.nameEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.nameEnColumn.ColumnName, true)); this.addressEd1.DataBindings.Clear(); this.addressEd1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.address1Column.ColumnName, true)); this.addressEd2.DataBindings.Clear(); this.addressEd2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.address2Column.ColumnName, true)); this.phoneEd.DataBindings.Clear(); this.phoneEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.phoneColumn.ColumnName, true)); this.faxEd.DataBindings.Clear(); this.faxEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.faxColumn.ColumnName, true)); this.emailEd.DataBindings.Clear(); this.emailEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.emailColumn.ColumnName, true)); this.websiteEd.DataBindings.Clear(); this.websiteEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.websiteColumn.ColumnName, true)); this.countryCb.DataBindings.Clear(); this.countryCb.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.myDataSource, tbl.countryColumn.ColumnName, true)); }
public void SetDataSource(System.Windows.Forms.BindingSource dataSrc) { this.myDataSource = dataSrc; data.baseDS.stockCodeDataTable tbl = (data.baseDS.stockCodeDataTable) this.myDataSource.DataSource; this.bizSectorLb.DataBindings.Clear(); this.bizSectorLb.DataBindings.Add(new System.Windows.Forms.Binding("myItemString", this.myDataSource, tbl.bizSectorsColumn.ColumnName, true)); }
private StringCollection GetStockList() { StringCollection stockCodeList = new StringCollection(); //Load stocks in selected subsectors if existed data.baseDS.stockCodeDataTable selectedStockCodeTbl = null; StringCollection subSectorCodeList = subSectorSelect.myCheckedValues; if (subSectorCodeList != null && subSectorCodeList.Count > 0) { selectedStockCodeTbl = new data.baseDS.stockCodeDataTable(); dataLibs.LoadStockCode_ByBizSectors(selectedStockCodeTbl, subSectorCodeList); if (selectedStockCodeTbl.Count == 0) { selectedStockCodeTbl.Dispose(); selectedStockCodeTbl = null; } } //User specify screening criteria ?? data.baseDS.stockCodeDataTable tmpStockCodeTbl = new data.baseDS.stockCodeDataTable(); bool haveScrList = application.dataLibs.LoadStockCode_ByCriteria(tmpStockCodeTbl, GetScrCriteria()); if (haveScrList) { DataView myStockView = new DataView(tmpStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = tmpStockCodeTbl.codeColumn.ColumnName + "," + tmpStockCodeTbl.stockExchangeColumn.ColumnName; for (int idx = 0; idx < myStockView.Count; idx++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx].Row; //Ignore stock NOT in selected subsectors if (selectedStockCodeTbl != null && selectedStockCodeTbl.FindBycode(stockRow.code) == null) { continue; } //Ignore duplicate stocks if (stockCodeList.Contains(stockRow.code)) { continue; } stockCodeList.Add(stockRow.code); } return(stockCodeList); } //If user NOT specify screening criteria BUT specify stock code if (selectedStockCodeTbl != null) { for (int idx = 0; idx < selectedStockCodeTbl.Count; idx++) { //Ignore duplicate stocks if (stockCodeList.Contains(selectedStockCodeTbl[idx].code)) { continue; } stockCodeList.Add(selectedStockCodeTbl[idx].code); } } return(stockCodeList); }
public static data.baseDS.stockCodeRow UpdateData(data.baseDS.stockCodeRow row) { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); tbl.ImportRow(row); myClient.UpdateStock(ref tbl); row.AcceptChanges(); return(tbl[0]); }
public string GetSQL() { string investorCode = commonClass.SysLibs.sysLoginCode; data.baseDS.transactionsDataTable transactionsTbl = new data.baseDS.transactionsDataTable(); data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable(); data.baseDS.portfolioDataTable portfolioTbl = new data.baseDS.portfolioDataTable(); string sqlCmd = "SELECT * FROM " + transactionsTbl.TableName; string filter = ""; string portfolioCond = ""; if (investorCode.Trim() != "") { portfolioCond += (portfolioCond == "" ? "" : " AND ") + portfolioTbl.investorCodeColumn.ColumnName + "=N'" + investorCode.Trim() + "'"; } if (portfolioCond != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.portfolioColumn.ColumnName + " IN " + common.Consts.constCRLF + "(SELECT " + portfolioTbl.codeColumn.ColumnName + " FROM " + portfolioTbl.TableName + " WHERE " + portfolioCond + ")"; } if (this.stockExchangeChk.Checked && this.stockExchangeCb.myValue != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.stockCodeColumn.ColumnName + " IN (SELECT " + stockCodeTbl.codeColumn.ColumnName + " FROM " + stockCodeTbl.TableName + " WHERE " + stockCodeTbl.stockExchangeColumn.ColumnName + "=N'" + this.stockExchangeCb.myValue.Trim() + "')"; } if (this.dateRangeChk.Checked && this.dateRange.GetDateRange()) { filter += (filter == "" ? "" : " AND ") + "(" + transactionsTbl.onTimeColumn.ColumnName + " BETWEEN '" + common.system.ConvertToSQLDateString(this.dateRange.frDate) + "' AND '" + common.system.ConvertToSQLDateString(this.dateRange.toDate) + "')"; } if (this.stockCodeEd.Enabled && this.stockCodeEd.Text.Trim() != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.stockCodeColumn.ColumnName + " =N'" + this.stockCodeEd.Text.Trim() + "'"; } if (portfolioChk.Checked && portfolioCb.myValue.Trim() != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.portfolioColumn.ColumnName + " =N'" + portfolioCb.myValue.Trim() + "'"; } if (filter != "") { sqlCmd += " WHERE " + filter; } return(sqlCmd); }
public static void LoadStockCode_ByBizSectors(data.tmpDS.stockCodeDataTable tbl, StringCollection bizSectors) { data.baseDS.stockCodeDataTable comTbl = new data.baseDS.stockCodeDataTable(); string cond = common.system.MakeConditionStr(bizSectors, comTbl.bizSectorsColumn.ColumnName + " LIKE N'" + common.Consts.SQL_CMD_ALL_MARKER + common.settings.sysListSeparatorPrefix, common.settings.sysListSeparatorPostfix + common.Consts.SQL_CMD_ALL_MARKER + "'", "OR"); string sqlCmd = "SELECT code, stockExchange, tickerCode, name,nameEn,0 AS price,0 AS priceVariant FROM stockCode WHERE " + cond; LoadFromSQL(tbl, sqlCmd); }
public static void LoadData(data.baseDS.stockCodeDataTable tbl, string code) { stockCodeTA.ClearBeforeFill = false; if (code == null) { stockCodeTA.Fill(tbl); } else { stockCodeTA.FillByCode(tbl, code); } }
private void SetMaxLength() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); codeEd.MaxLength = tbl.codeColumn.MaxLength; enNameEd.MaxLength = tbl.nameColumn.MaxLength; addressEd1.MaxLength = tbl.address1Column.MaxLength; addressEd2.MaxLength = tbl.address2Column.MaxLength; phoneEd.MaxLength = tbl.phoneColumn.MaxLength; faxEd.MaxLength = tbl.faxColumn.MaxLength; emailEd.MaxLength = tbl.emailColumn.MaxLength; websiteEd.MaxLength = tbl.websiteColumn.MaxLength; }
private void SetMaxLength() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); codeEd.MaxLength = tbl.codeColumn.MaxLength; enNameEd.MaxLength = tbl.nameColumn.MaxLength; addressEd1.MaxLength = tbl.address1Column.MaxLength; addressEd2.MaxLength = tbl.address2Column.MaxLength; phoneEd.MaxLength = tbl.phoneColumn.MaxLength; faxEd.MaxLength = tbl.faxColumn.MaxLength; emailEd.MaxLength = tbl.emailColumn.MaxLength; websiteEd.MaxLength = tbl.websiteColumn.MaxLength; }
public string GetSQL() { string investorCode = commonClass.SysLibs.sysLoginCode; data.baseDS.transactionsDataTable transactionsTbl = new data.baseDS.transactionsDataTable(); data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable(); data.baseDS.portfolioDataTable portfolioTbl = new data.baseDS.portfolioDataTable(); string sqlCmd = "SELECT * FROM " + transactionsTbl.TableName; string filter = ""; string portfolioCond = ""; if (investorCode.Trim() != "") { portfolioCond +=(portfolioCond == "" ? "" : " AND ") + portfolioTbl.investorCodeColumn.ColumnName + "=N'" + investorCode.Trim() + "'"; } if (portfolioCond != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.portfolioColumn.ColumnName + " IN " + common.Consts.constCRLF + "(SELECT " + portfolioTbl.codeColumn.ColumnName + " FROM " + portfolioTbl.TableName + " WHERE " + portfolioCond + ")"; } if (this.stockExchangeChk.Checked && this.stockExchangeCb.myValue != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.stockCodeColumn.ColumnName + " IN (SELECT " +stockCodeTbl.codeColumn.ColumnName + " FROM " + stockCodeTbl.TableName + " WHERE " + stockCodeTbl.stockExchangeColumn.ColumnName + "=N'" + this.stockExchangeCb.myValue.Trim() + "')"; } if (this.dateRangeChk.Checked && this.dateRange.GetDateRange()) { filter += (filter == "" ? "" : " AND ") + "("+ transactionsTbl.onTimeColumn.ColumnName + " BETWEEN '" + common.system.ConvertToSQLDateString(this.dateRange.frDate) + "' AND '" + common.system.ConvertToSQLDateString(this.dateRange.toDate) + "')"; } if (this.stockCodeEd.Enabled && this.stockCodeEd.Text.Trim()!="") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.stockCodeColumn.ColumnName + " =N'" + this.stockCodeEd.Text.Trim() + "'"; } if (portfolioChk.Checked && portfolioCb.myValue.Trim() != "") { filter += (filter == "" ? "" : " AND ") + transactionsTbl.portfolioColumn.ColumnName + " =N'" + portfolioCb.myValue.Trim() + "'"; } if (filter != "") sqlCmd += " WHERE " + filter; return sqlCmd; }
public static data.baseDS.stockCodeDataTable GetStockFull(bool force) { string cacheKey = MakeCacheKey("StockFull", "All"); if (!force) { object obj = GetCache(cacheKey); if (obj != null) { return((data.baseDS.stockCodeDataTable)obj); } } data.baseDS.stockCodeDataTable tbl = myClient.GetStockFull(); AddCache(cacheKey, tbl); return(tbl); }
public static void AddNewCode(data.baseDS.priceDataDataTable tbl, string stockEchangeCode, OnAddData onAddstockCodeFunc) { data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable(); for (int count = 0; count < tbl.Count; count++) { if (tbl[count].RowState == DataRowState.Deleted) { continue; } if (AddNewCode(tbl[count].stockCode, stockEchangeCode, stockCodeTbl) != null && onAddstockCodeFunc != null) { onAddstockCodeFunc(tbl[count].stockCode); } } application.DbAccess.UpdateData(stockCodeTbl); }
public static data.baseDS.stockCodeRow FindAndCache(data.baseDS.stockCodeDataTable tbl, string code) { data.baseDS.stockCodeRow row = tbl.FindBycode(code); if (row != null) { return(row); } data.baseDSTableAdapters.stockCodeTA dataTA = new data.baseDSTableAdapters.stockCodeTA(); dataTA.ClearBeforeFill = false; dataTA.FillByCode(tbl, code); row = tbl.FindBycode(code); if (row != null) { return(row); } return(null); }
public static data.baseDS.stockCodeRow AddNewCode(string comCode, string stockEchangeCode, data.baseDS.stockCodeDataTable toStockCodeTbl) { data.baseDS.stockCodeRow stockCodeRow; stockCodeRow = libs.FindAndCache(toStockCodeTbl, comCode); if (stockCodeRow == null) { stockCodeRow = toStockCodeTbl.NewstockCodeRow(); commonClass.AppLibs.InitData(stockCodeRow); stockCodeRow.code = comCode; stockCodeRow.name = "<New>"; stockCodeRow.code = comCode; stockCodeRow.tickerCode = comCode; stockCodeRow.stockExchange = stockEchangeCode; stockCodeRow.regDate = DateTime.Today; toStockCodeTbl.AddstockCodeRow(stockCodeRow); } return(stockCodeRow); }
protected void LoadStockList(data.tmpDS.portfolioListDataTable toTbl, string[] watchCodes) { //Load stocks in portfolio data.baseDS.stockCodeDataTable myStockCodeTbl = new data.baseDS.stockCodeDataTable(); switch (watchListCb.WatchType) { case myTypes.portfolioType.Portfolio: dataLibs.LoadStockCode_ByPortfolios(myStockCodeTbl, common.system.List2Collection(watchCodes)); break; case myTypes.portfolioType.WatchList: dataLibs.LoadStockCode_ByWatchList(myStockCodeTbl, common.system.List2Collection(watchCodes)); break; default: common.system.ThrowException("Imvalid WatchType"); break; } DataView myStockView = new DataView(myStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName; data.tmpDS.portfolioListRow reportRow; for (int idx1 = 0; idx1 < myStockView.Count; idx1++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx1].Row; //Ignore duplicate stocks reportRow = toTbl.FindBystockCode(stockRow.code); if (reportRow != null) { continue; } reportRow = toTbl.NewportfolioListRow(); dataLibs.InitData(reportRow); reportRow.stockCode = stockRow.code; reportRow.stockExCode = stockRow.stockExchange; toTbl.AddportfolioListRow(reportRow); } }
public void SetDataSource(System.Windows.Forms.BindingSource dataSrc) { this.myDataSource = dataSrc; data.baseDS.stockCodeDataTable tbl = (data.baseDS.stockCodeDataTable) this.myDataSource.DataSource; this.stockMarketCb.DataBindings.Clear(); this.stockMarketCb.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.myDataSource, tbl.stockExchangeColumn.ColumnName, true)); this.tickerCodeEd.DataBindings.Clear(); this.tickerCodeEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.tickerCodeColumn.ColumnName, true)); this.treasuryStockEd.DataBindings.Clear(); this.treasuryStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noTreasuryStockColumn.ColumnName, true)); this.listedStockEd.DataBindings.Clear(); this.listedStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noListedStockColumn.ColumnName, true)); this.outstandingStockEd.DataBindings.Clear(); this.outstandingStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noOutstandingStockColumn.ColumnName, true)); this.foreignOwnStockEd.DataBindings.Clear(); this.foreignOwnStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noForeignOwnedStockColumn.ColumnName, true)); this.bookPriceEd.DataBindings.Clear(); this.bookPriceEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.bookPriceColumn.ColumnName, true)); this.targetPriceEd.DataBindings.Clear(); this.targetPriceEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.targetPriceColumn.ColumnName, true)); this.targetPriceVariantEd.DataBindings.Clear(); this.targetPriceVariantEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.targetPriceVariantColumn.ColumnName, true)); this.regDateEd.DataBindings.Clear(); this.regDateEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.regDateColumn.ColumnName, true)); this.statusCb.DataBindings.Clear(); this.statusCb.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.myDataSource, tbl.statusColumn.ColumnName, true)); }
private void bizSectorTypeSelection_mySectorSelectionChange(object sender, EventArgs e) { try { data.baseDS.stockCodeDataTable dataTbl = new data.baseDS.stockCodeDataTable(); StringCollection subSectorCodeList = bizSectorTypeSelection.myCurrentSubSectorCodes; if (subSectorCodeList == null) { stockCodeClb.myDataTbl = this.allStockCodeTbl; } else { application.dataLibs.LoadStockCode_ByBizSector(dataTbl, subSectorCodeList); stockCodeClb.myDataTbl = dataTbl; } selectAllChk.Checked = false; showOnlyCheckedChk.Checked = false; } catch (Exception er) { ErrorHandler(this, er); } }
public static data.baseDS.stockCodeRow UpdateData(data.baseDS.stockCodeRow row) { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); tbl.ImportRow(row); myClient.UpdateStock(ref tbl); row.AcceptChanges(); return tbl[0]; }
private void BackTest() { StringCollection strategyList = strategyClb.myCheckedValues; StringCollection stockCodeList; if (stockCodeSelect.Enabled) { stockCodeList = stockCodeSelect.myCheckedValues; } else { stockCodeList = new StringCollection(); //Load stocks in portfolio data.baseDS.stockCodeDataTable myStockCodeTbl = new data.baseDS.stockCodeDataTable(); StringCollection portfolioList = common.system.List2Collection(portfolioCb.GetValues()); dataLibs.LoadStockCode_ByPortfolios(myStockCodeTbl, portfolioList); DataView myStockView = new DataView(myStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName; for (int idx1 = 0; idx1 < myStockView.Count; idx1++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx1].Row; //Ignore duplicate stocks if (stockCodeList.Contains(stockRow.code)) { continue; } stockCodeList.Add(stockRow.code); } } DataTable testRetsultTbl = CreateDataTable(strategyList); SetDataGrid(testResultDataGrid, testRetsultTbl); progressBar.Value = 0; progressBar.Maximum = stockCodeList.Count; //Data analysisData = new Data(dateRangeEd.frDate, dateRangeEd.toDate, dateRangeEd.myTimeScale, stockCodeRow.co); //analysisData.Init(dateRangeEd.myTimeScale, dateRangeEd.frDate, dateRangeEd.toDate, stockCodeRow); myDataSet.strategy.Clear(); data.baseDS.strategyRow strategyRow; for (int idx = 0; idx < strategyList.Count; idx++) { strategyRow = application.dataLibs.FindAndCache(myDataSet.strategy, strategyList[idx]); if (strategyRow == null) { common.system.ThrowException("Invalid strategy " + strategyList[idx]); } strategyList[idx] = strategyList[idx].Trim(); } data.baseDS.stockCodeRow stockCodeRow; for (int rowId = 0; rowId < stockCodeList.Count; rowId++) { stockCodeRow = application.dataLibs.FindAndCache(myDataSet.stockCode, stockCodeList[rowId]); if (stockCodeRow == null) { continue; } Data analysisData = new Data(dateRangeEd.frDate, dateRangeEd.toDate, dateRangeEd.myTimeScale, stockCodeRow.code); DataRow row = testRetsultTbl.Rows.Add(stockCodeList[rowId]); for (int colId = 0; colId < strategyList.Count; colId++) { decimal revenue = 0; Analysis.AnalysisResult advices = appHub.strategy.TradeAnalysis(analysisData, strategyList[colId]); if (advices != null) { myTmpDS.tradeEstimate.Clear(); Analysis.EstimateAdvice(analysisData, advices, new application.Analysis.EstimateOptions(), myTmpDS.tradeEstimate); revenue = (myTmpDS.tradeEstimate.Count == 0 ? 0 : revenue = myTmpDS.tradeEstimate[myTmpDS.tradeEstimate.Count - 1].revenue); } row[colId + 1] = revenue; } progressBar.Value++; Application.DoEvents(); } SetEstimateStrateDataGrid(Analysis.GetStrategyStats(testRetsultTbl)); }
private void BackTest() { StringCollection strategyList = strategyClb.myCheckedValues; StringCollection stockCodeList; if (stockCodeSelect.Enabled) stockCodeList = stockCodeSelect.myCheckedValues; else { stockCodeList = new StringCollection(); //Load stocks in portfolio data.baseDS.stockCodeDataTable myStockCodeTbl = new data.baseDS.stockCodeDataTable(); StringCollection portfolioList = common.system.List2Collection(portfolioCb.GetValues()); dataLibs.LoadStockCode_ByPortfolios(myStockCodeTbl, portfolioList); DataView myStockView = new DataView(myStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName; for (int idx1 = 0; idx1 < myStockView.Count; idx1++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx1].Row; //Ignore duplicate stocks if (stockCodeList.Contains(stockRow.code)) continue; stockCodeList.Add(stockRow.code); } } DataTable testRetsultTbl = CreateDataTable(strategyList); SetDataGrid(testResultDataGrid, testRetsultTbl); progressBar.Value = 0; progressBar.Maximum = stockCodeList.Count; //Data analysisData = new Data(dateRangeEd.frDate, dateRangeEd.toDate, dateRangeEd.myTimeScale, stockCodeRow.co); //analysisData.Init(dateRangeEd.myTimeScale, dateRangeEd.frDate, dateRangeEd.toDate, stockCodeRow); myDataSet.strategy.Clear(); data.baseDS.strategyRow strategyRow; for (int idx = 0; idx < strategyList.Count; idx++) { strategyRow = application.dataLibs.FindAndCache(myDataSet.strategy, strategyList[idx]); if (strategyRow == null) common.system.ThrowException("Invalid strategy " + strategyList[idx]); strategyList[idx] = strategyList[idx].Trim(); } data.baseDS.stockCodeRow stockCodeRow; for (int rowId = 0; rowId < stockCodeList.Count; rowId++) { stockCodeRow = application.dataLibs.FindAndCache(myDataSet.stockCode, stockCodeList[rowId]); if (stockCodeRow == null) continue; Data analysisData = new Data(dateRangeEd.frDate, dateRangeEd.toDate,dateRangeEd.myTimeScale, stockCodeRow.code); DataRow row = testRetsultTbl.Rows.Add(stockCodeList[rowId]); for (int colId = 0; colId < strategyList.Count; colId++) { decimal revenue = 0; Analysis.AnalysisResult advices = appHub.strategy.TradeAnalysis(analysisData, strategyList[colId]); if (advices != null) { myTmpDS.tradeEstimate.Clear(); Analysis.EstimateAdvice(analysisData, advices,new application.Analysis.EstimateOptions(), myTmpDS.tradeEstimate); revenue = (myTmpDS.tradeEstimate.Count == 0 ? 0 : revenue = myTmpDS.tradeEstimate[myTmpDS.tradeEstimate.Count - 1].revenue); } row[colId + 1] = revenue; } progressBar.Value++; Application.DoEvents(); } SetEstimateStrateDataGrid(Analysis.GetStrategyStats(testRetsultTbl)); }
public static void LoadData(data.baseDS.stockCodeDataTable tbl, AppTypes.CommonStatus status) { stockCodeTA.ClearBeforeFill = false; stockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); }
private void bizSectorTypeSelection_mySectorSelectionChange(object sender, EventArgs e) { try { data.baseDS.stockCodeDataTable dataTbl = new data.baseDS.stockCodeDataTable(); StringCollection subSectorCodeList = bizSectorTypeSelection.myCurrentSubSectorCodes; if (subSectorCodeList == null) { stockCodeClb.myDataTbl = this.allStockCodeTbl; } else { application.dataLibs.LoadStockCode_ByBizSector(dataTbl, subSectorCodeList); stockCodeClb.myDataTbl = dataTbl; } selectAllChk.Checked = false; showOnlyCheckedChk.Checked = false; } catch (Exception er) { ErrorHandler(this, er); } }
public static void UpdateData(data.baseDS.stockCodeDataTable tbl) { stockCodeTA.Update(tbl); tbl.AcceptChanges(); }
//Use the idea from http://www.codeproject.com/KB/database/CsvReader.aspx by Sebastien Lorion public static bool ImportOHLCV_CSV(string csvFileName, char delimiter, common.dateTimeLibs.DateTimeFormats dataDateFormat, string stockExchangeForNewCode, CultureInfo culture, data.baseDS.priceDataDataTable priceDataTbl, ImportRow ImportRowFunc, OnUpdatePriceData onUpdateDataFunc, OnEndImportPriceData onEndImportFunc) { libs.importStat myImportStat = new libs.importStat(); myImportStat.Reset(); myImportStat.dateFormat = dataDateFormat; myImportStat.culture = culture; data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable(); data.baseDS.priceDataRow priceDataRow; DataRowView[] foundRows; application.DbAccess.LoadData(stockCodeTbl, AppTypes.CommonStatus.Enable); DataView stockCodeView = new DataView(stockCodeTbl); stockCodeView.Sort = stockCodeTbl.codeColumn.ColumnName; bool fCanceled = false; DateTime lastPriceDate = common.Consts.constNullDate; importOHLCV data; // open the file "data.csv" which is a CSV file with headers using (CsvReader csv = new CsvReader(new StreamReader(csvFileName), true, delimiter)) { // missing fields will not throw an exception, // but will instead be treated as if there was a null value csv.MissingFieldAction = MissingFieldAction.ReplaceByNull; int fieldCount = csv.FieldCount; if (fieldCount < 7) { return(false); } while (csv.ReadNextRecord()) { Application.DoEvents(); myImportStat.dataCount++; data = ImportRowFunc(csv, myImportStat); if (myImportStat.cancel) { fCanceled = true; break; } if (data == null) { myImportStat.errorCount++; continue; } //Assume that all price must be valid if (data.Open <= 0 || data.High <= 0 || data.Low <= 0 || data.Close <= 0) { continue; } foundRows = stockCodeView.FindRows(data.code); if (foundRows.Length == 0) { //Try to add new stock code libs.AddNewCode(data.code, stockExchangeForNewCode, stockCodeTbl); application.DbAccess.UpdateData(stockCodeTbl); } // Ignore all data that was in database //if (!foundLastPriceDate) //{ // lastPriceDate = libs.FindLastPriceDate(data.code); // foundLastPriceDate = true; //} if (lastPriceDate != common.Consts.constNullDate && data.dateTime <= lastPriceDate) { continue; } if (priceDataTbl.FindBystockCodeonDate(data.code, data.dateTime) != null) { myImportStat.errorCount++; continue; } myImportStat.updateCount++; priceDataRow = priceDataTbl.NewpriceDataRow(); commonClass.AppLibs.InitData(priceDataRow); priceDataRow.stockCode = data.code; priceDataRow.onDate = data.dateTime; //Try to fix some error in data priceDataRow.openPrice = (decimal)data.Open; priceDataRow.highPrice = (decimal)data.High; priceDataRow.lowPrice = (decimal)data.Low; priceDataRow.closePrice = (decimal)data.Close; priceDataRow.volume = (decimal)data.Volume; priceDataTbl.AddpriceDataRow(priceDataRow); if (onUpdateDataFunc != null) { onUpdateDataFunc(priceDataRow, myImportStat); } } } if (fCanceled) { priceDataTbl.Clear(); return(false); } if (onEndImportFunc != null) { onEndImportFunc(priceDataTbl); } return(true); }
public data.baseDS.stockCodeDataTable GetStockFull() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); DbAccess.LoadData(tbl); return tbl; }
public static void LoadData(data.baseDS.stockCodeDataTable tbl) { stockCodeTA.ClearBeforeFill = false; stockCodeTA.Fill(tbl); }
public void UpdateStock(ref data.baseDS.stockCodeDataTable tbl) { DbAccess.UpdateData(tbl); }
public static void LoadStockCode_ByStatus(data.baseDS.stockCodeDataTable tbl, AppTypes.CommonStatus status) { stockCodeTA.FillByStatusMask(tbl, ((byte)status).ToString()); }
private void SetMaxLength() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); stockCodeEd.MaxLength = tbl.codeColumn.MaxLength; tickerCodeEd.MaxLength = tbl.tickerCodeColumn.MaxLength; }
private void SetMaxLength() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); stockCodeEd.MaxLength = tbl.codeColumn.MaxLength; tickerCodeEd.MaxLength = tbl.tickerCodeColumn.MaxLength; }
protected void LoadStockList(data.tmpDS.portfolioListDataTable toTbl, string[] watchCodes) { //Load stocks in portfolio data.baseDS.stockCodeDataTable myStockCodeTbl = new data.baseDS.stockCodeDataTable(); switch (watchListCb.WatchType) { case myTypes.portfolioType.Portfolio: dataLibs.LoadStockCode_ByPortfolios(myStockCodeTbl, common.system.List2Collection(watchCodes)); break; case myTypes.portfolioType.WatchList: dataLibs.LoadStockCode_ByWatchList(myStockCodeTbl, common.system.List2Collection(watchCodes)); break; default: common.system.ThrowException("Imvalid WatchType"); break; } DataView myStockView = new DataView(myStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName; data.tmpDS.portfolioListRow reportRow; for (int idx1 = 0; idx1 < myStockView.Count; idx1++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx1].Row; //Ignore duplicate stocks reportRow = toTbl.FindBystockCode(stockRow.code); if (reportRow != null) continue; reportRow = toTbl.NewportfolioListRow(); dataLibs.InitData(reportRow); reportRow.stockCode = stockRow.code; reportRow.stockExCode = stockRow.stockExchange; toTbl.AddportfolioListRow(reportRow); } }
public void SetDataSource(System.Windows.Forms.BindingSource dataSrc) { this.myDataSource = dataSrc; data.baseDS.stockCodeDataTable tbl = (data.baseDS.stockCodeDataTable) this.myDataSource.DataSource; this.stockCodeEd.DataBindings.Clear(); this.stockCodeEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.codeColumn.ColumnName, true)); this.stockMarketCb.DataBindings.Clear(); this.stockMarketCb.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.myDataSource, tbl.stockExchangeColumn.ColumnName, true)); this.tickerCodeEd.DataBindings.Clear(); this.tickerCodeEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.tickerCodeColumn.ColumnName, true)); this.treasuryStockEd.DataBindings.Clear(); this.treasuryStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noTreasuryStockColumn.ColumnName, true)); this.listedStockEd.DataBindings.Clear(); this.listedStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noListedStockColumn.ColumnName, true)); this.outstandingStockEd.DataBindings.Clear(); this.outstandingStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noOutstandingStockColumn.ColumnName, true)); this.foreignOwnStockEd.DataBindings.Clear(); this.foreignOwnStockEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.noForeignOwnedStockColumn.ColumnName, true)); this.capitalUnitCb.DataBindings.Clear(); this.capitalUnitCb.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.myDataSource, tbl.capitalUnitColumn.ColumnName, true)); this.workingCapitalEd.DataBindings.Clear(); this.workingCapitalEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.workingCapColumn.ColumnName, true)); this.equityEd.DataBindings.Clear(); this.equityEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.equityColumn.ColumnName, true)); this.totalAssetEd.DataBindings.Clear(); this.totalAssetEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.totaAssetsColumn.ColumnName, true)); this.totalDebtEd.DataBindings.Clear(); this.totalDebtEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.totalDebtColumn.ColumnName, true)); this.salesEd.DataBindings.Clear(); this.salesEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.salesColumn.ColumnName, true)); this.profitEd.DataBindings.Clear(); this.profitEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.profitColumn.ColumnName, true)); this.pricePerBookEd.DataBindings.Clear(); this.pricePerBookEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.PBColumn.ColumnName, true)); this.earnPerShareEd.DataBindings.Clear(); this.earnPerShareEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.EPSColumn.ColumnName, true)); this.prixePerEarningEd.DataBindings.Clear(); this.prixePerEarningEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.PEColumn.ColumnName, true)); this.roaEd.DataBindings.Clear(); this.roaEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.ROAColumn.ColumnName, true)); this.roeEd.DataBindings.Clear(); this.roeEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.ROEColumn.ColumnName, true)); this.betaEd.DataBindings.Clear(); this.betaEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.BETAColumn.ColumnName, true)); this.bookPriceEd.DataBindings.Clear(); this.bookPriceEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.bookPriceColumn.ColumnName, true)); this.targetPriceEd.DataBindings.Clear(); this.targetPriceEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.targetPriceColumn.ColumnName, true)); this.targetPriceVariantEd.DataBindings.Clear(); this.targetPriceVariantEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.targetPriceVariantColumn.ColumnName, true)); this.regDateEd.DataBindings.Clear(); this.regDateEd.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataSource, tbl.regDateColumn.ColumnName, true)); this.statusCb.DataBindings.Clear(); this.statusCb.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.myDataSource, tbl.statusColumn.ColumnName, true)); }
//Use the idea from http://www.codeproject.com/KB/database/CsvReader.aspx by Sebastien Lorion public static bool ImportOHLCV_CSV(string csvFileName, char delimiter, common.dateTimeLibs.DateTimeFormats dataDateFormat, string stockExchangeForNewCode, CultureInfo culture, data.baseDS.priceDataDataTable priceDataTbl, ImportRow ImportRowFunc, OnUpdatePriceData onUpdateDataFunc, OnEndImportPriceData onEndImportFunc) { libs.importStat myImportStat = new libs.importStat(); myImportStat.Reset(); myImportStat.dateFormat = dataDateFormat; myImportStat.culture = culture; data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable(); data.baseDS.priceDataRow priceDataRow; DataRowView[] foundRows; application.DbAccess.LoadData(stockCodeTbl, AppTypes.CommonStatus.Enable); DataView stockCodeView = new DataView(stockCodeTbl); stockCodeView.Sort = stockCodeTbl.codeColumn.ColumnName; bool fCanceled = false; DateTime lastPriceDate = common.Consts.constNullDate; importOHLCV data; // open the file "data.csv" which is a CSV file with headers using (CsvReader csv = new CsvReader(new StreamReader(csvFileName), true, delimiter)) { // missing fields will not throw an exception, // but will instead be treated as if there was a null value csv.MissingFieldAction = MissingFieldAction.ReplaceByNull; int fieldCount = csv.FieldCount; if (fieldCount < 7) return false; while (csv.ReadNextRecord()) { Application.DoEvents(); myImportStat.dataCount++; data = ImportRowFunc(csv, myImportStat); if (myImportStat.cancel) { fCanceled = true; break; } if (data == null) { myImportStat.errorCount++; continue; } //Assume that all price must be valid if (data.Open <= 0 || data.High <= 0 || data.Low <= 0 || data.Close <= 0) continue; foundRows = stockCodeView.FindRows(data.code); if (foundRows.Length == 0) { //Try to add new stock code libs.AddNewCode(data.code, stockExchangeForNewCode, stockCodeTbl); application.DbAccess.UpdateData(stockCodeTbl); } // Ignore all data that was in database //if (!foundLastPriceDate) //{ // lastPriceDate = libs.FindLastPriceDate(data.code); // foundLastPriceDate = true; //} if (lastPriceDate != common.Consts.constNullDate && data.dateTime <= lastPriceDate) { continue; } if (priceDataTbl.FindBystockCodeonDate(data.code, data.dateTime) != null) { myImportStat.errorCount++; continue; } myImportStat.updateCount++; priceDataRow = priceDataTbl.NewpriceDataRow(); commonClass.AppLibs.InitData(priceDataRow); priceDataRow.stockCode = data.code; priceDataRow.onDate = data.dateTime; //Try to fix some error in data priceDataRow.openPrice = (decimal)data.Open; priceDataRow.highPrice = (decimal)data.High; priceDataRow.lowPrice = (decimal)data.Low; priceDataRow.closePrice = (decimal)data.Close; priceDataRow.volume = (decimal)data.Volume; priceDataTbl.AddpriceDataRow(priceDataRow); if (onUpdateDataFunc != null) onUpdateDataFunc(priceDataRow, myImportStat); } } if (fCanceled) { priceDataTbl.Clear(); return false; } if (onEndImportFunc != null) onEndImportFunc(priceDataTbl); return true; }
public data.baseDS.stockCodeDataTable GetStockFull() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); DbAccess.LoadData(tbl); return(tbl); }
public static void AddNewCode(data.baseDS.priceDataDataTable tbl, string stockEchangeCode, OnAddData onAddstockCodeFunc) { data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable(); for (int count = 0; count < tbl.Count; count++) { if (tbl[count].RowState == DataRowState.Deleted) continue; if (AddNewCode(tbl[count].stockCode, stockEchangeCode, stockCodeTbl)!=null && onAddstockCodeFunc != null) onAddstockCodeFunc(tbl[count].stockCode); } application.DbAccess.UpdateData(stockCodeTbl); }
private void SetMaxLength() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); bizSectorLb.maxLen = tbl.bizSectorsColumn.MaxLength; }
private void SetMaxLength() { data.baseDS.stockCodeDataTable tbl = new data.baseDS.stockCodeDataTable(); bizSectorLb.maxLen = tbl.bizSectorsColumn.MaxLength; }
public static void LoadStockCode_ByBizSectors(data.tmpDS.stockCodeDataTable tbl, StringCollection bizSectors) { data.baseDS.stockCodeDataTable comTbl = new data.baseDS.stockCodeDataTable(); string cond = common.system.MakeConditionStr(bizSectors, comTbl.bizSectorsColumn.ColumnName + " LIKE N'" + common.Consts.SQL_CMD_ALL_MARKER + common.settings.sysListSeparatorPrefix, common.settings.sysListSeparatorPostfix + common.Consts.SQL_CMD_ALL_MARKER + "'", "OR"); string sqlCmd = "SELECT code, stockExchange, tickerCode, name,nameEn,0 AS price,0 AS priceVariant FROM stockCode WHERE " + cond; LoadFromSQL(tbl, sqlCmd); }
private StringCollection GetStockList() { StringCollection stockCodeList = new StringCollection(); //Load stocks in selected subsectors if existed data.baseDS.stockCodeDataTable selectedStockCodeTbl = null; StringCollection subSectorCodeList = subSectorSelect.myCheckedValues; if (subSectorCodeList != null && subSectorCodeList.Count > 0) { selectedStockCodeTbl = new data.baseDS.stockCodeDataTable(); dataLibs.LoadStockCode_ByBizSectors(selectedStockCodeTbl, subSectorCodeList); if (selectedStockCodeTbl.Count == 0) { selectedStockCodeTbl.Dispose(); selectedStockCodeTbl = null; } } //User specify screening criteria ?? data.baseDS.stockCodeDataTable tmpStockCodeTbl = new data.baseDS.stockCodeDataTable(); bool haveScrList = application.dataLibs.LoadStockCode_ByCriteria(tmpStockCodeTbl, GetScrCriteria()); if (haveScrList) { DataView myStockView = new DataView(tmpStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = tmpStockCodeTbl.codeColumn.ColumnName + "," + tmpStockCodeTbl.stockExchangeColumn.ColumnName; for (int idx = 0; idx < myStockView.Count; idx++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx].Row; //Ignore stock NOT in selected subsectors if (selectedStockCodeTbl != null && selectedStockCodeTbl.FindBycode(stockRow.code) == null) continue; //Ignore duplicate stocks if (stockCodeList.Contains(stockRow.code)) continue; stockCodeList.Add(stockRow.code); } return stockCodeList; } //If user NOT specify screening criteria BUT specify stock code if (selectedStockCodeTbl != null) { for (int idx = 0; idx < selectedStockCodeTbl.Count; idx++) { //Ignore duplicate stocks if (stockCodeList.Contains(selectedStockCodeTbl[idx].code)) continue; stockCodeList.Add(selectedStockCodeTbl[idx].code); } } return stockCodeList; }