private void GetOpt10060Caller(Opt10060TransType opt10060TransType, string stockCode, string MaxDate, string MinDate) { if (_opt10060 != null) { _opt10060.Dispose(); _opt10060 = null; } _opt10060 = new ClsOpt10060(); TaskCompletionSource <bool> tcs = null; tcs = new TaskCompletionSource <bool>(); if (tcs == null || tcs.Task.IsCompleted) { return; } DataTable dtDate = new DataTable(); KiwoomQuery kiwoom = new KiwoomQuery(); _opt10060.SetInit(_FormId); switch (opt10060TransType) { case Opt10060TransType.PriceMaesu: WriteTextSafe(stockCode + "(" + ClsAxKH.GetMasterCodeName(stockCode) + ")" + " Price(매수)_" + _StockQueue.Count.ToString()); ClsAxKH.AxKH_10060_OnReceived += new ClsAxKH.OnReceivedEventHandler(OnReceiveTrData_Opt10060PriceMaeSu); _opt10060.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "1", MaeMaeGb: "1", UnitG: "", nPrevNext: 0); break; case Opt10060TransType.PriceMaedo: WaitTime(); WriteTextSafe(stockCode + " Price(매도)_" + _StockQueue.Count.ToString()); ClsAxKH.AxKH_10060_OnReceived += new ClsAxKH.OnReceivedEventHandler(OnReceiveTrData_Opt10060PriceMaedo); _opt10060.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "1", MaeMaeGb: "2", UnitG: "", nPrevNext: 0); break; case Opt10060TransType.QtyMaesu: WaitTime(); WriteTextSafe(stockCode + " QTY(매수)_" + _StockQueue.Count.ToString()); ClsAxKH.AxKH_10060_OnReceived += new ClsAxKH.OnReceivedEventHandler(OnReceiveTrData_Opt10060MaeSu); _opt10060.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "2", MaeMaeGb: "1", UnitG: "", nPrevNext: 0); break; case Opt10060TransType.QtyMaeDo: WaitTime(); WriteTextSafe(stockCode + " QTY(매도)_" + _StockQueue.Count.ToString()); ClsAxKH.AxKH_10060_OnReceived += new ClsAxKH.OnReceivedEventHandler(OnReceiveTrData_Opt10060Maedo); _opt10060.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "2", MaeMaeGb: "2", UnitG: "", nPrevNext: 0); break; default: break; } tcs.SetResult(true); }
private void ExecQd(string stockCode) { if (_opt10060Qd != null) { _opt10060Qd.Dispose(); _opt10060Qd = null; } _opt10060Qd = new ClsOpt10060(); _opt10060Qd.Opt10060_OnReceived += new ClsOpt10060.OnReceivedEventHandler(OnReceiveTrData_Opt10060QtyMaedo); WriteTextSafe(stockCode + " Qty 매도 작업 중 "); Task t = new Task(() => { _opt10060Qd.SetInit(_FormId + "04"); _opt10060Qs.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "2", MaeMaeGb: "2", UnitG: "1", nPrevNext: 0); }); t.Start(); return; }
private void ExecPs(string stockCode) { if (_opt10060Ps != null) { _opt10060Ps.Dispose(); _opt10060Ps = null; } _opt10060Ps = new ClsOpt10060(); _opt10060Ps.Opt10060_OnReceived += new ClsOpt10060.OnReceivedEventHandler(OnReceiveTrData_Opt10060PriceMaeSu); WriteTextSafe(stockCode + " Price 매수 작업 중 "); Action StartExecPs = (() => { _opt10060Ps.SetInit(_FormId + "01"); _opt10060Ps.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "1", MaeMaeGb: "1", UnitG: "1", nPrevNext: 0); }); StartExecPs(); return; }
private async void OnReceiveTrData_Opt10060QtyMaedo(string stockCode, DataTable dt, int sPreNext) { // lblStockName.Text = stockCode + "Qty 매도 작업 중"; ArrayParam arrParam = new ArrayParam(); Sql oSql = new Sql(SDataAccess.ClsServerInfo.VADISSEVER, "KIWOOMDB"); Task <int> funcTaskAsync = Task.Run(() => { if (dt != null) { foreach (DataRow dr in dt.Rows) { WriteTextSafe(stockCode + " QTY 매도 " + dr["일자"]); if (dr["일자"].ToString() == _LastQdDate) { Sql oSql2 = new Sql(SDataAccess.ClsServerInfo.VADISSEVER, "RICHDB"); arrParam.Clear(); arrParam.Add("@ACTION_GB", "C6"); arrParam.Add("@STOCK_CODE", stockCode); arrParam.Add("@STOCK_NAME", ""); arrParam.Add("@YBJONG_CODE", ""); arrParam.Add("@OPT10059_QTY", ""); arrParam.Add("@OPT10059_PRICE", ""); arrParam.Add("@OPT10081", ""); arrParam.Add("@OPT10060_QTY", "Y"); arrParam.Add("@OPT10060_PRICE", ""); arrParam.Add("@R_ERRORCD", -1, SqlDbType.Int, ParameterDirection.InputOutput); oSql2.ExecuteNonQuery("p_ScodeAdd", CommandType.StoredProcedure, arrParam); // 다음 자료가 없으면 return(1); } arrParam.Clear(); arrParam.Add("@ACTION_GB", "A"); arrParam.Add("@STOCK_CODE", stockCode); arrParam.Add("@STOCK_DATE", dr["일자"]); arrParam.Add("@MAEME_GB", "2"); arrParam.Add("@DATE_SEQNO", 0); arrParam.Add("@NUJUK_TRDAEGUM", dr["누적거래대금"]); arrParam.Add("@GAIN_QTY", dr["개인투자자"]); arrParam.Add("@FORE_QTY", dr["외국인투자자"]); arrParam.Add("@GIGAN_QTY", dr["기관계"]); arrParam.Add("@GUMY_QTY", dr["금융투자"]); arrParam.Add("@BOHUM_QTY", dr["보험"]); arrParam.Add("@TOSIN_QTY", dr["투신"]); arrParam.Add("@GITA_QTY", dr["기타금융"]); arrParam.Add("@BANK_QTY", dr["은행"]); arrParam.Add("@YEONGI_QTY", dr["연기금등"]); arrParam.Add("@SAMO_QTY", dr["사모펀드"]); arrParam.Add("@NATION_QTY", dr["국가"]); arrParam.Add("@BUBIN_QTY", dr["기타법인"]); arrParam.Add("@IOFORE_QTY", dr["내외국인"]); arrParam.Add("@GIGAN_SUM_QTY", Convert.ToInt32(dr["금융투자"]) + Convert.ToInt32(dr["보험"]) + Convert.ToInt32(dr["투신"]) + Convert.ToInt32(dr["기타금융"]) + Convert.ToInt32(dr["은행"]) + Convert.ToInt32(dr["연기금등"]) + Convert.ToInt32(dr["사모펀드"]) + Convert.ToInt32(dr["국가"])); arrParam.Add("@R_ERRORCD", -1, SqlDbType.Int, ParameterDirection.InputOutput); oSql.ExecuteNonQuery("p_Opt10060QtyAdd", CommandType.StoredProcedure, arrParam); } return(0); } else { return(1); } }); if (await funcTaskAsync == 1) { WriteTextSafe(stockCode + " Qty 매도" + "완료 다음으로.."); OnGetEndData(valueType: 3, strStockCode: stockCode); return; } Task <int> t = Task.Run(() => { if (sPreNext == 2) { return(0); } else { Sql oSql2 = new Sql(SDataAccess.ClsServerInfo.VADISSEVER, "RICHDB"); arrParam.Clear(); arrParam.Add("@ACTION_GB", "C6"); arrParam.Add("@STOCK_CODE", stockCode); arrParam.Add("@STOCK_NAME", ""); arrParam.Add("@YBJONG_CODE", ""); arrParam.Add("@OPT10059_QTY", ""); arrParam.Add("@OPT10059_PRICE", ""); arrParam.Add("@OPT10081", ""); arrParam.Add("@OPT10060_QTY", "Y"); arrParam.Add("@OPT10060_PRICE", ""); arrParam.Add("@R_ERRORCD", -1, SqlDbType.Int, ParameterDirection.InputOutput); oSql2.ExecuteNonQuery("p_ScodeAdd", CommandType.StoredProcedure, arrParam); // 다음 자료가 없으면 WriteTextSafe(stockCode + " Qty 매도" + "완료 다음으로.."); OnGetEndData(valueType: 3, strStockCode: stockCode); return(1); } }); if (await t == 1) { WriteTextSafe(stockCode + " Qty 매도" + "완료 다음으로.."); OnGetEndData(valueType: 3, strStockCode: stockCode); return; } else { WriteTextSafe(stockCode + " Qty 매도" + "(다음일자로..)"); _opt10060Qd.JustRequest(StartDate: _stdDate, StockCode: stockCode, StockName: "", AmountQtyGb: "2", MaeMaeGb: "2", UnitG: "1", nPrevNext: 1); } }