public void Search() { UnRegistAuto(); m_strJongCode = m_mainForm.txtJongCode.Text; m_strJongCode.Trim(); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "jang", "1", 0); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "jongcode", m_strJongCode, 0); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "outflag", "N", 0); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "tsflag", "0", 0); int nReqID = m_iYuantaAPI.YOA_Request("300001", true, -1); if (CommDef.ERROR_MAX_CODE < nReqID) { m_mapRequestTR[nReqID] = "300001"; string strMsg = "[ReqID:" + nReqID + "] [300001]주식현재가 조회를 요청하였습니다."; m_mainForm.LogMessage(strMsg); } else { string strMsg = "[300001]주식현재가 조회 요청중 오류가 발생하였습니다."; m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR); strMsg = "[" + nReqID + "]" + m_iYuantaAPI.YOA_GetErrorMessage(nReqID); m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR, false); } }
public void Search() { string strAcctPwd = m_mainForm.txtOrdAcctPwd.Text; strAcctPwd.Trim(); if (0 == strAcctPwd.Length) { MessageBox.Show("계좌비밀번호를 입력해주세요."); m_mainForm.txtOrdAcctPwd.Focus(); return; } string strAccount = m_mainForm.cbOrdAccount.SelectedItem.ToString(); strAccount = strAccount.Replace("-", ""); m_iYuantaAPI.YOA_SetTRFieldString("204006", "InBlock1", "kyejwa", strAccount, 0); m_iYuantaAPI.YOA_SetTRFieldString("204006", "InBlock1", "passwd", strAcctPwd, 0); int nReqID = m_iYuantaAPI.YOA_Request("204006", true, -1); if (CommDef.ERROR_MAX_CODE < nReqID) { m_mapRequestTR[nReqID] = "204006"; m_mainForm.LogMessage("[ReqID:" + nReqID + "] [204006]가정산예수현황 조회를 요청하였습니다."); } else { m_mainForm.LogMessage("[204006]가정산예수현황 조회중 오류가 발생하였습니다.", CommDef.YOALOG_ERROR); int nErrorCode = m_iYuantaAPI.YOA_GetLastError(); m_mainForm.LogMessage("[" + nErrorCode + " ]" + m_iYuantaAPI.YOA_GetErrorMessage(nErrorCode), CommDef.YOALOG_ERROR, false); return; } m_iYuantaAPI.YOA_SetTRFieldString("211010", "InBlock1", "acnt_aid", strAccount, 0); m_iYuantaAPI.YOA_SetTRFieldString("211010", "InBlock1", "passwd", strAcctPwd, 0); nReqID = m_iYuantaAPI.YOA_Request("211010", true, -1); if (CommDef.ERROR_MAX_CODE < nReqID) { m_mapRequestTR[nReqID] = "211010"; m_mainForm.LogMessage("[ReqID:" + nReqID + "] [211010]ELW매매기본예탁금 조회를 요청하였습니다."); } else { m_mainForm.LogMessage("[211010]ELW매매기본예탁금 조회중 오류가 발생하였습니다.", CommDef.YOALOG_ERROR); int nErrorCode = m_iYuantaAPI.YOA_GetLastError(); m_mainForm.LogMessage("[" + nErrorCode + " ]" + m_iYuantaAPI.YOA_GetErrorMessage(nErrorCode), CommDef.YOALOG_ERROR, false); } }
/* * [System.Runtime.InteropServices.DllImport("YuantaAPI.dll")] * private static extern int YuantaAPI(); */ //Test 버튼 클릭시 private void textbtn_Click_1(object sender, EventArgs e) { int count = 0; // 일단 코스닥 종목만 돌림 foreach (string jongCode in jongCodeList_kosdaq) { txtBTJongCode.Text = jongCode; // search 과정 셋팅 m_basicTestHandler.m_strJongCode = jongCode; int nErr = m_iYuantaAPI.YOA_SetTRInfo("300001", "InBlock1"); m_iYuantaAPI.YOA_SetFieldString("jang", "1", 0); m_iYuantaAPI.YOA_SetFieldString("jongcode", jongCode, 0); // i로 수정함 m_iYuantaAPI.YOA_SetFieldString("outflag", "N", 0); m_iYuantaAPI.YOA_SetFieldString("tsflag", "0", 0); int nReqID = m_iYuantaAPI.YOA_Request("300001", true, -1); if (CommDef.ERROR_MAX_CODE < nReqID) { m_basicTestHandler.m_mapRequestTR[nReqID] = "300001"; } // ReceiveData - 데이터를 받아야 m_basicTestHandler.ReceiveData(nReqID); // auto 등록 - 가능 m_basicTestHandler.RegistAuto(); // ReceiveRealData - 실행해줘야 함 m_basicTestHandler.ReceiveRealData(nReqID, "11"); count++; if (count % 15 == 0) // 5초당 15개씩 등록 { Delay(4000); //Console.WriteLine(count + "번째 종목 등록-------------------" + jongCode + "-----------" + nReqID); Console.WriteLine("등록 종목수: " + count); } } LogMessage(jongCodeList_kosdaq.Length + "개의 코스닥 종목이 auto 수신이 모두 등록되었습니다."); Console.WriteLine(jongCodeList_kosdaq.Length + "개의 코스닥 종목이 auto 수신이 모두 등록되었습니다."); while (true) { Delay(5000); receive_flag = false; foreach (KeyValuePair <string, List <string> > entry in Master종합정보) { Console.WriteLine(entry.Key + "------------"); foreach (string x in entry.Value) { Console.WriteLine(x); } } Console.WriteLine("------- ------- 등록 종목수: " + regist_count); Delay(1000); receive_flag = true; } }
public void Search() { m_strJongCode = m_mainForm.txtBTJongCode.Text; m_strJongCode.Trim(); int nErr = m_iYuantaAPI.YOA_SetTRInfo("300001", "InBlock1"); nErr = m_iYuantaAPI.YOA_SetFieldString("jang", "1", 0); nErr = m_iYuantaAPI.YOA_SetFieldString("jongcode", m_strJongCode, 0); // i로 수정함 nErr = m_iYuantaAPI.YOA_SetFieldString("outflag", "N", 0); nErr = m_iYuantaAPI.YOA_SetFieldString("tsflag", "0", 0); int nReqID = m_iYuantaAPI.YOA_Request("300001", true, -1); if (CommDef.ERROR_MAX_CODE < nReqID) { m_mapRequestTR[nReqID] = "300001"; m_mainForm.lbLog.Items.Insert(0, "[300001]주식현재가 조회를 요청하였습니다."); } //Console.WriteLine("1"); }
public void Search() { if (0 != m_nReqID_301004) { m_iYuantaAPI.YOA_ReleaseData(m_nReqID_301004); } m_mainForm.lvConTick.Items.Clear(); m_mainForm.lvDaily.Items.Clear(); ListViewItem item = new ListViewItem(); item.UseItemStyleForSubItems = false; item.SubItems.Add("현 재"); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); m_mainForm.lvDaily.Items.Add(item); m_nReqID_301004 = 0; UnRegistAuto(); // 종목코드란에 text를 가져와서 search함 m_strJongCode = m_mainForm.txtJongCode.Text; m_strJongCode.Trim(); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "jang", "1", 0); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "jongcode", m_strJongCode, 0); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "outflag", "N", 0); m_iYuantaAPI.YOA_SetTRFieldString("300001", "InBlock1", "tsflag", "0", 0); int nResult = m_iYuantaAPI.YOA_Request("300001", true, -1); if (CommDef.ERROR_MAX_CODE < nResult) { m_mapRequestTR[nResult] = "300001"; string strMsg = "[ReqID:" + nResult + "] [300001]주식현재가 조회를 요청하였습니다."; m_mainForm.LogMessage(strMsg); } else { string strMsg = "[300001]주식현재가 조회 요청중 오류가 발생하였습니다."; m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR); strMsg = "[" + nResult + "]" + m_iYuantaAPI.YOA_GetErrorMessage(nResult); m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR, false); } string strJang = m_iYuantaAPI.YOA_GetCodeInfo(CommDef.MARKET_TYPE_INTERNAL, CommDef.CODE_INFO_JANG_GUBUN, m_mainForm.txtJongCode.Text); m_iYuantaAPI.YOA_SetTRInfo("300002", "InBlock1"); m_iYuantaAPI.YOA_SetFieldString("jang", strJang, 0); m_iYuantaAPI.YOA_SetFieldString("jongcode", m_strJongCode, 0); m_iYuantaAPI.YOA_SetFieldString("outflag", "N", 0); nResult = m_iYuantaAPI.YOA_Request("300002", true, -1); if (CommDef.ERROR_MAX_CODE < nResult) { m_mapRequestTR[nResult] = "300002"; string strMsg = "[ReqID:" + nResult + "] [300002]주식현재가_호가체결 조회를 요청하였습니다."; m_mainForm.LogMessage(strMsg); } else { string strMsg = "[300002]주식현재가_호가체결 조회 요청중 오류가 발생하였습니다."; m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR); strMsg = "[" + nResult + "]" + m_iYuantaAPI.YOA_GetErrorMessage(nResult); m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR, false); } DateTime dt = DateTime.Now; string strDate = dt.ToString("yyyyMMdd"); m_iYuantaAPI.YOA_SetTRInfo("301004", "InBlock1"); m_iYuantaAPI.YOA_SetFieldString("jongcode", m_strJongCode, 0); m_iYuantaAPI.YOA_SetFieldString("janggubun", strJang, 0); m_iYuantaAPI.YOA_SetFieldString("searchdate", strDate, 0); m_iYuantaAPI.YOA_SetFieldString("daygubun", "1", 0); m_iYuantaAPI.YOA_SetFieldString("querygubun", "0", 0); m_iYuantaAPI.YOA_SetFieldString("bpquery", "0", 0); nResult = m_iYuantaAPI.YOA_Request("301004", false, -1); if (CommDef.ERROR_MAX_CODE < nResult) { m_nReqID_301004 = nResult; m_mapRequestTR[nResult] = "301004"; string strMsg = "[ReqID:" + nResult + "] [301004]수정일자별주가 조회를 요청하였습니다."; m_mainForm.LogMessage(strMsg); } else { string strMsg = "[301004]수정일자별주가 조회 요청중 오류가 발생하였습니다."; m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR); strMsg = "[" + nResult + "]" + m_iYuantaAPI.YOA_GetErrorMessage(nResult); m_mainForm.LogMessage(strMsg, CommDef.YOALOG_ERROR, false); } }