public void calculation() { int i; int checkExistance = 0; DataGridViewRow tempRow = new DataGridViewRow(); for (i = 0; i < balanceDgv.Rows.Count; i++) { tempRow = balanceDgv.Rows[i]; if ((string)tempRow.Cells[0].Value == buy_data.stockName) { checkExistance = 1; break; } } if (checkExistance == 0) { long totalCost = buy_data.buyCost * buy_data.buyQuantity; balanceDgv.Rows.Add(buy_data.stockName, buy_data.buyQuantity, buy_data.buyCost, buy_data.buyCost, 0, 0, totalCost, totalCost); } else if (checkExistance == 1) { long totalCost = (long)tempRow.Cells[7].Value + buy_data.buyCost * buy_data.buyQuantity; long valuationCost = (long)tempRow.Cells[6].Value + buy_data.buyCost * buy_data.buyQuantity; tempRow.Cells[1].Value = (long)tempRow.Cells[1].Value + buy_data.buyQuantity; tempRow.Cells[3].Value = totalCost / (long)tempRow.Cells[1].Value; tempRow.Cells[6].Value = valuationCost; tempRow.Cells[7].Value = totalCost; } long cash = userBalance.getCash(); cash -= buy_data.buyCost * buy_data.buyQuantity; userBalance.setCash(cash); long totalBuyCost = userBalance.getPurchaseAmount(); totalBuyCost += buy_data.buyCost * buy_data.buyQuantity; userBalance.setPurchaseAmount(totalBuyCost); }
/* * selection == 0 : 매수 , selection == 1 : 매도 * */ private void btnOK_Click(object sender, EventArgs e) { int selection = cmbRequest.SelectedIndex; if (selection == 0) { double howMany = Double.Parse(stockNumberTextBox.Text); if (rdoMarketPrice.Checked == true) { double marketPriceDouble = Double.Parse(marketPrice); double totalCost = howMany * marketPriceDouble; if (userBalance.getCash() < totalCost) { MessageBox.Show("금액 부족\n" + "소유 현금 : " + userBalance.getCash() + "\n" + "가격 총합 : " + totalCost, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } }
private void btnReset_Click(object sender, EventArgs e) { // 잔고 초기화 userBalance = new balance(); long totalAsset = userBalance.getTotalAsset(); long cash = userBalance.getCash(); long profit = userBalance.getProfit(); long purchase = userBalance.getPurchaseAmount(); long currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); lblPurchaseNumber.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
private void btnReset_Click(object sender, EventArgs e) { // 잔고 초기화 userBalance = new balance(); double totalAsset = userBalance.getTotalAsset(); double cash = userBalance.getCash(); double profitPercent = userBalance.calcProfitPercentage(); double profit = userBalance.getProfit(); double purchase = userBalance.getPurchaseAmount(); double currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); purchase_txt.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
public mainForm() { InitializeComponent(); userBalance = new balance(); double totalAsset = userBalance.getTotalAsset(); double cash = userBalance.getCash(); double profitPercent = userBalance.calcProfitPercentage(); double profit = userBalance.getProfit(); double purchase = userBalance.getPurchaseAmount(); double currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); purchase_txt.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
public mainForm() { InitializeComponent(); userBalance = new balance(); buy_data = new buyData(); sell_data = new sellData(); long totalAsset = userBalance.getTotalAsset(); long cash = userBalance.getCash(); double profitPercent = userBalance.getProfitPercentage(); long profit = userBalance.getProfit(); long purchase = userBalance.getPurchaseAmount(); long currentTotalPrice = userBalance.getCurrentTotalPrice(); lblBalance.Text = totalAsset.ToString(); lbl_percent.Text = "0%"; profit_txt.Text = profit.ToString(); lblPurchaseNumber.Text = purchase.ToString(); evaluated_txt.Text = currentTotalPrice.ToString(); cash_txt.Text = cash.ToString(); }
private double returnCash() { return(userBalance.getCash()); }
/* * selection == 0 : 매수 , selection == 1 : 매도 * */ private void btnOK_Click(object sender, EventArgs e) { int selection = cmbRequest.SelectedIndex; if (selection == 0 && stockNumberTextBox.Text != null) { long howMany = long.Parse(stockNumberTextBox.Text); long marketPriceLong = Convert.ToInt64(priceTextBox.Text); long totalCost = howMany * marketPriceLong; /*지정매수목록에 걸려있는 금액 계산*/ long money_must_not_be_used = 0; foreach (Thread thr in limitOrderList) { string[] orderinfo = thr.Name.Split(' '); if (orderinfo[0] == "매수") { money_must_not_be_used += Convert.ToInt64(orderinfo[1]) * Convert.ToInt64(orderinfo[2]); } } /* */ if (rdoMarketPrice.Checked) { if (userBalance.getCash() - money_must_not_be_used < totalCost) { MessageBox.Show("금액 부족\n" + "소유 현금 : " + userBalance.getCash() + "\n" + "가격 총합 : " + totalCost, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } mForm.buy_data.buyQuantity = howMany; mForm.buy_data.buyCost = marketPriceLong; mForm.calculation(); MessageBox.Show("매수 체결되었습니다"); //this.Close(); } else if (rdoCustomPrice.Checked) { if (userBalance.getCash() - money_must_not_be_used < totalCost) { MessageBox.Show("금액 부족\n" + "소유 현금 : " + userBalance.getCash() + "\n" + "가격 총합 : " + totalCost, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <object> parameters = new List <object>(); parameters.Add(marketPriceLong); parameters.Add(howMany); Thread buylimit = new Thread(new ParameterizedThreadStart(limitOrder_BuyingPoint)); buylimit.Start(parameters); limitOrderList.Add(buylimit); limitOrderList[limitOrderList.Count - 1].Name = "매수" + " " + howMany + " " + marketPriceLong; } } if (selection == 1 && stockNumberTextBox.Text != null) { long howMany = long.Parse(stockNumberTextBox.Text); long marketPriceLong = Convert.ToInt64(priceTextBox.Text); long totalCost = howMany * marketPriceLong; // stockName 단순이름에서 market name으로 변경하였습니다 coinName -> code mForm.sell_data.stockName = this.code; mForm.sell_data.sellCost = totalCost; mForm.sell_data.sellQuantity = howMany; /*지정매수목록에 걸려있는 코인 계산*/ long coin_must_not_be_used = 0; foreach (Thread thr in limitOrderList) { string[] orderinfo = thr.Name.Split(' '); if (orderinfo[0] == "매도") { coin_must_not_be_used += long.Parse(orderinfo[1]); } } /* */ if (rdoMarketPrice.Checked) { mForm.sell_data.sellQuantity += coin_must_not_be_used; int result = mForm.beforesellCalc(); if (result == 0) { MessageBox.Show("해당 코인이 없습니다!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 1) { MessageBox.Show("코인 수가 부족합니다", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 2) { mForm.sell_data.sellQuantity -= coin_must_not_be_used; result = mForm.sellCalc(); if (result == 0) { MessageBox.Show("해당 코인이 없습니다!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 1) { MessageBox.Show("코인 수가 부족합니다", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 2) { MessageBox.Show("매도 체결되었습니다."); } } } else if (rdoCustomPrice.Checked) { mForm.sell_data.sellQuantity += coin_must_not_be_used; int result = mForm.beforesellCalc(); if (result == 0) { MessageBox.Show("해당 코인이 없습니다!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 1) { MessageBox.Show("코인 수가 부족합니다", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result == 2) { List <object> parameters = new List <object>(); parameters.Add(marketPriceLong); parameters.Add(totalCost); parameters.Add(howMany); parameters.Add(this.code); Thread selllimit = new Thread(new ParameterizedThreadStart(limitOrder_SellingPoint)); selllimit.Start(parameters); limitOrderList.Add(selllimit); limitOrderList[limitOrderList.Count - 1].Name = "매도" + " " + howMany + " " + marketPriceLong; } } } }