Exemple #1
0
        private bool needSyncViewData(Dictionary <int, StockData> stockPool)
        {
            if (stockPool.Count != viewData_.Count)
            {
                return(true);
            }

            foreach (KeyValuePair <int, StockData> keyValue in stockPool)
            {
                int       code      = keyValue.Key;
                StockData stockData = keyValue.Value;
                int       nowPrice  = stockData.nowPrice(priceType_);

                if (nowPrice == 0)
                {
                    return(true);
                }

                if (viewData_[code] != nowPrice)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        //---- 각 데이터가 달라야 갱신해주도록 한다.
        private void setViewData(Dictionary <int, StockData> stockPool)
        {
            viewData_.Clear();
            foreach (KeyValuePair <int, StockData> keyValue in stockPool)
            {
                int       code      = keyValue.Key;
                StockData stockData = keyValue.Value;

                viewData_.Add(code, stockData.nowPrice(priceType_));
            }
        }
Exemple #3
0
        private void printList(Dictionary <int, StockData> stockPool)
        {
            dataGridView_.Rows.Clear();
            const int INIT_INDEX = 1;
            int       index      = INIT_INDEX;

            var rankDesc = stockPool.OrderByDescending(num => num.Value.valuation_);

            foreach (KeyValuePair <int, StockData> keyValue in rankDesc)
            {
                int       code    = keyValue.Key;
                StockData orgData = keyValue.Value;

                StockData stockData = (StockData)orgData.Clone();
                //정렬을 위해...
                string column = "2_감시";
                if (stockData.isBuyedStock())
                {
                    column = "1_보유";
                }
                string valuation  = String.Format("{0:D4}", stockData.valuation_);
                string codeString = stockData.codeString();
                string name       = stockData.name_;
                string nowPrice   = stockData.nowPrice(priceType_).ToString();

                string buyCount        = "";
                string buyPrice        = "";
                string totalBuyPrice   = "";
                string profitPrice     = "";
                string profitPriceRate = "";

                if (stockData.isBuyedStock())
                {
                    BuyedStockData buyedStockData = (BuyedStockData)stockData;
                    buyCount        = buyedStockData.buyCount_.ToString();
                    buyPrice        = buyedStockData.buyPrice_.ToString();
                    totalBuyPrice   = buyedStockData.totalBuyPrice().ToString();
                    profitPrice     = buyedStockData.profitPrice().ToString();
                    profitPriceRate = buyedStockData.profitPriceRate().ToString();
                }
                string   indexStr = String.Format("{0:D3}", index);
                string[] row      = new string[] { column, valuation, indexStr, codeString, name, nowPrice, buyCount, buyPrice, totalBuyPrice, profitPrice, profitPriceRate };
                dataGridView_.Rows.Add(row);
                index++;
            }
            dataGridView_.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            //첫열을 기준으로 정렬을 시켜서 구입한 주식을 위로 올린다.
            dataGridView_.Sort(dataGridView_.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
Exemple #4
0
        private void consolePrintList(Dictionary <int, StockData> stockPool)
        {
            Logger.getInstance.consolePrint("=============================================================");
            foreach (KeyValuePair <int, StockData> keyValue in stockPool)
            {
                int       code    = keyValue.Key;
                StockData orgData = keyValue.Value;

                StockData stockData = (StockData)orgData.Clone();
                //정렬을 위해...
                string column = "2_감시";
                if (stockData.isBuyedStock())
                {
                    column = "1_보유";
                }

                string codeString = stockData.codeString();
                string name       = stockData.name_;
                string nowPrice   = stockData.nowPrice(priceType_).ToString();

                string buyCount        = "";
                string buyPrice        = "";
                string totalBuyPrice   = "";
                string profitPrice     = "";
                string profitPriceRate = "";

                if (stockData.isBuyedStock())
                {
                    BuyedStockData buyedStockData = (BuyedStockData)stockData;
                    buyCount        = buyedStockData.buyCount_.ToString();
                    buyPrice        = buyedStockData.buyPrice_.ToString();
                    totalBuyPrice   = buyedStockData.totalBuyPrice().ToString();
                    profitPrice     = buyedStockData.profitPrice().ToString();
                    profitPriceRate = buyedStockData.profitPriceRate().ToString();
                }

                Logger.getInstance.consolePrint("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8}",
                                                column, codeString, name, nowPrice, buyCount, buyPrice, totalBuyPrice, profitPrice, profitPriceRate);
            }
        }