//========================================== void showDetailOfGroup(stShareGroup g) { viewState = VIEWSTATE_1_NHOMNGANH; if (g.getTotal() == 1 && (g.getName().CompareTo("^VNINDEX") == 0 || g.getName().CompareTo("^HASTC") == 0 || g.getName().CompareTo("^UPCOM") == 0)) { int cnt = mContext.mShareManager.getShareCount(); int[] market = { 0 }; int marketID = 1; if (g.getName().CompareTo("^HASTC") == 0) { marketID = 2; } else if (g.getName().CompareTo("^UPCOM") == 0) { marketID = 3; } for (int i = 0; i < cnt; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); if (shareID > 0 && market[0] == marketID) { g.addCode(mContext.mShareManager.getShareCode(shareID)); } } } chartG = new ChartTangtruongGroup(); chartG.setGroup(g); chartG.setPosition(0, 0); chartG.onBack += dismissGroupDetail; //chartG.setSize(mPriceboardContainer); int h = getH();// chartG.estimateH(getH(), g.getTotal()); if (h < getH()) { h = getH(); } //list.setSize(W_PRICEBOARD, mPriceboardH); chartG.setSize(getW() - 20, h); chartG.onBack += dismissGroupDetail; chartG.onHistoryClick += delegateShowHistoryChartOfGroup; chartG.onClickShare += delegateShowHistoryChartOfShare; chartG.onProcessingCompleted += onProcessingCompleted; chartG.onProcessingStart += onProcessingStart; invalidate(); }
void delegateShowSortMenu(Control senderControl) { // show popup menu ContextMenuStrip cm = new ContextMenuStrip(); cm.Items.Add("RSI"); cm.Items.Add("MFI"); cm.Items.Add("Vốn hóa"); cm.Items.Add("Giá trị giao dịch"); cm.Items.Add("EPS"); cm.Items.Add("PE"); cm.Items.Add("Khối lượng"); cm.Items.Add("Khối lượng thay đổi (TB3/TB15)"); cm.Items.Add("Điểm RS/VNIndex"); cm.Items.Add("-"); cm.Items.Add("Xuất danh sách ra file excel(csv)"); cm.ItemClicked += new ToolStripItemClickedEventHandler( (sender, item) => { if (item.ClickedItem.Text.CompareTo("Xuất danh sách ra file excel(csv)") == 0) { xVector filteredShares = shareGroupToVector(); ShareSortUtils.exportGroupToCSV(filteredShares, sortedColumn); return; } float[] columnPercents = { 30, 28, 34, 8 }; // code, price, value String[] columnTexts = { "Mã CP", "Giá", "---", "" }; int sortType = ShareSortUtils.SORT_RSI; if (item.ClickedItem.Text.CompareTo("RSI") == 0) { sortType = ShareSortUtils.SORT_RSI; columnTexts[2] = "RSI"; } else if (item.ClickedItem.Text.CompareTo("MFI") == 0) { sortType = ShareSortUtils.SORT_MFI; columnTexts[2] = "MFI"; } else if (item.ClickedItem.Text.CompareTo("EPS") == 0) { sortType = ShareSortUtils.SORT_EPS; columnTexts[2] = "EPS"; } else if (item.ClickedItem.Text.CompareTo("PE") == 0) { sortType = ShareSortUtils.SORT_PE; columnTexts[2] = "PE"; } else if (item.ClickedItem.Text.CompareTo("Vốn hóa") == 0) { sortType = ShareSortUtils.SORT_VonHoa; columnTexts[2] = "VốnHóa(tỉ)"; } else if (item.ClickedItem.Text.CompareTo("Giá trị giao dịch") == 0) { sortType = ShareSortUtils.SORT_TRADE_VALUE; columnTexts[2] = "GTGD (tỉ)"; } else if (item.ClickedItem.Text.CompareTo("Khối lượng") == 0) { sortType = ShareSortUtils.SORT_VOLUME; columnTexts[2] = "Khối lượng"; } else if (item.ClickedItem.Text.CompareTo("Khối lượng thay đổi (TB3/TB15)") == 0) { sortType = ShareSortUtils.SORT_THAYDOI_VOL; columnTexts[2] = "+/-Vol(%)"; } else if (item.ClickedItem.Text.CompareTo("Điểm RS/VNIndex") == 0) { sortType = ShareSortUtils.SORT_RS_RANKING; columnTexts[2] = "Điểm RS/VNIndex"; showGetDaysForRSRankingDialog(); return; } sortedColumn = columnTexts[2]; _sortType = sortType; xVector sorted = shareGroupToVector(); ShareSortUtils.doSort(sorted, sortType, 0); _shareGroup.clear(); for (int i = 0; i < sorted.size(); i++) { Share share = (Share)sorted.elementAt(i); _shareGroup.addCode(share.mCode); } columnTexts[2] = "▼ " + columnTexts[2]; //================== if (mTableType == TABLE_GAINLOSS) { setShareGroupAsFilterResult(_shareGroup, sortType); } else { setShareGroup(_shareGroup, sortType); } }); int posX = (int)((100 - 7.5f) * rowW); posX /= 100; cm.Show(senderControl.PointToScreen(new Point(posX, 15))); }
public void refreshChart() { if (group == null) { group = new stShareGroup(); group.setType(stShareGroup.ID_GROUP_DEFAULT); } group.clear(); if (startDate > 0 && endDate > 0 && startDate <= endDate) { refreshChart2(); return; } currentSelected = null; Share index = mContext.mShareManager.getShare(mShareID); stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(index.getMarketID()); if (index == null || pi == null) { return; } if (mContext.mShareManager.getVnindexCnt() == 0) { return; } _isProcessing = true; index.loadShareFromFile(false); index.appendTodayCandle2(); if (index.getCandleCnt() < 10) { return; // impossible } //--------------------------- endDate = index.getLastCandleDate(); startDate = index.getDate(index.getCandleCnt() - 2); //stCandle cIndex = index.getCan .getCandleByDate(startDate); stCandle cIndex = new stCandle(); index.getCandleByDate(startDate, 0, cIndex); //=============================================== double totalEquity = 0.0; totalIndexInc = 0; totalIndexDec = 0; int cnt = mContext.mShareManager.getVnindexCnt(); double[] indexOfShares = new double[cnt]; double[] changedPercents = new double[cnt]; float[] prices = new float[cnt]; stCandle _c0 = new stCandle(); stCandle _c1 = new stCandle(); // tinh total equity for (int i = 0; i < cnt; i++) { Share share = mContext.mShareManager.getVnindexShareAt(i); if (share.getShareID() == 223) { indexOfShares[i] = 1; } indexOfShares[i] = 0; if (share.getMarketID() == index.getMarketID() && !share.isIndex()) { stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(share.getShareID()); if (inf != null) { share.loadShareFromCommonData(false); share.appendTodayCandle2(); stCandle c0 = share.getCandleByDate(startDate, 0, _c0); stCandle c1 = share.getCandleByDate(endDate, startDate, _c1); if (c0 == null || c1 == null) { continue; } if (c0.close == 0 || c1.close == 0) { continue; } totalEquity += (inf.volume * c0.close); double changedPercent = (c1.close - c0.close) / c0.close; if (changedPercent < 0) { //changedPercent = changedPercent; } indexOfShares[i] = cIndex.close * (inf.volume * c0.close) * changedPercent; if (changedPercent > 0) { totalIndexInc += changedPercent; } else { totalIndexDec += changedPercent; } //--------- changedPercents[i] = (c1.close - c0.close) * 100 / c0.close; prices[i] = c1.close; } } } // cleanup vChangeDec.removeAllElements(); vChangeInc.removeAllElements(); //==================================== totalIndexInc /= totalEquity; totalIndexDec /= totalEquity; totalIndexInc = 0; totalIndexDec = 0; for (int i = 0; i < cnt; i++) { Share share = mContext.mShareManager.getVnindexShareAt(i); //if (strcmp(share.mCode, "VIC") == 0){ // /i = i; //} double indexChanged = indexOfShares[i] / totalEquity; ChangeIndexItem item; if (indexChanged > 0) { item = new ChangeIndexItem(); item.modifiedValue = (float)indexChanged; totalIndexInc += item.modifiedValue; item.shareID = share.getShareID(); vChangeInc.addElement(item); } else { item = new ChangeIndexItem(); item.modifiedValue = (float)(-indexChanged); totalIndexDec += item.modifiedValue; item.shareID = share.getShareID(); vChangeDec.addElement(item); } item.price = prices[i]; item.modifiedPercent = (float)changedPercents[i]; } // end of calc sortChanges(vChangeInc); sortChanges(vChangeDec); while (vChangeInc.size() > 200) { vChangeInc.removeElementAt(vChangeInc.size() - 1); } while (vChangeDec.size() > 200) { vChangeDec.removeElementAt(vChangeDec.size() - 1); } //--------------- // ChangeIndexItem xVector[] vv = { vChangeInc, vChangeDec }; for (int j = 0; j < 2; j++) { for (int i = 0; i < vv[j].size(); i++) { ChangeIndexItem item = (ChangeIndexItem)vv[j].elementAt(i); Share share = mContext.mShareManager.getShare(item.shareID); if (share != null && share.getCode() != null) { group.addCode(share.getCode()); } } } invalidate(); }