public void BuyStock(string inqDate, string stockCode, string stockName, int price, string option, int waterCnt, string 매수조건) { int qty = EachStockBudget / price; if (qty <= 0) { return; } // 천만원만 우선 사용 (추가매수일땐 무한정) if (string.IsNullOrWhiteSpace(option) && TotalBalance - price * qty <= 0) { log.Info("돈없어서 못사는중 : " + TotalBalance + " 종목코드:" + stockCode + " 종목명:" + stockName); return; } if ("추가매수".Equals(option)) { if (waterCnt == 0) { qty = qty * 2; } else if (waterCnt == 1) { qty = qty * 4; } } StockOrder order = new StockOrder(); order.inqDate = inqDate; order.stockCode = stockCode; order.stockName = stockName; order.Qty = qty.ToString(); order.Price = price.ToString(); order.OrderType = "매수"; order.Status = "요청중"; order.OrderOption = option; order.Reason = 매수조건; int orderSeq = dacStock.주식주문이력추가(order); //dacStock.주식상태매수요청중으로변경(inqDate, stockCode); if (!"추가매수".Equals(option)) { dacStock.대상종목상태변경(inqDate, stockCode, "매수요청중"); } int resultCode = OpenAPI.SendOrder("종목신규매수", orderSeq.ToString(), AccountNo, 1, order.stockCode = stockCode, qty, price, "00", ""); order.APIResult = resultCode.ToString(); dacStock.주문정보업데이트(orderSeq.ToString(), order.APIResult, ""); Console.WriteLine("매수주문[" + orderSeq.ToString() + "] : " + Newtonsoft.Json.JsonConvert.SerializeObject(order)); // 추가매수일땐 무한정 if (string.IsNullOrWhiteSpace(option)) { TotalBalance -= price * qty; } }