public void Order() { string strAcctPwd = m_mainForm.txtOrdAcctPwd.Text; strAcctPwd.Trim(); if (0 == strAcctPwd.Length) { MessageBox.Show("계좌비밀번호를 입력해주세요."); m_mainForm.txtOrdAcctPwd.Focus(); return; } string strJongCode = m_mainForm.txtOrdJongCode.Text; strJongCode.Trim(); if (0 == strJongCode.Length) { MessageBox.Show("종목코드를 입력해주세요."); m_mainForm.txtOrdAcctPwd.Focus(); return; } int nOrderType = m_mainForm.cbOrdType.SelectedIndex; int nPrice = Convert.ToInt32(m_mainForm.nudOrdPrice.Value); if (0 == nPrice) { if ( 1 == nOrderType || // 05.시장가 3 == nOrderType || // 12.최유리지정가 4 == nOrderType || // 13.최우선지정가 5 == nOrderType || // 71.시간외종가 8 == nOrderType || // I2.시장가(IOC) 11 == nOrderType // F2.시장가(FOC) ) { } else { MessageBox.Show("가격을 입력해주세요."); m_mainForm.nudOrdPrice.Focus(); return; } } int nQty = Convert.ToInt32(m_mainForm.nudOrdQty.Value); if (0 == nQty) { MessageBox.Show("수량을 입력해주세요."); m_mainForm.nudOrdQty.Focus(); return; } string strDSOID = ""; if (ORDER_TYPE_MESU == m_nOrderMesuMedo) { strDSOID = "100001"; } else if (ORDER_TYPE_MEDO == m_nOrderMesuMedo) { strDSOID = "100002"; } string strAccount = m_mainForm.cbOrdAccount.SelectedItem.ToString(); strAccount = strAccount.Replace("-", ""); string strMemeGubun = m_mainForm.cbOrdType.SelectedItem.ToString(); int nPos = strMemeGubun.IndexOf('.'); strMemeGubun = strMemeGubun.Remove(nPos); string strJumunCond = "00"; if (1 < strMemeGubun.Length) { if ('I' == strMemeGubun[0]) { strJumunCond = "01"; } else if ('F' == strMemeGubun[0]) { strJumunCond = "02"; } } m_iYuantaAPI.YOA_SetTRInfo(strDSOID, "InBlock1"); m_iYuantaAPI.YOA_SetFieldString("acnt_aid", strAccount, 0); m_iYuantaAPI.YOA_SetFieldString("gds_acnt_tp", "A01010001", 0); m_iYuantaAPI.YOA_SetFieldString("passwd", strAcctPwd, 0); m_iYuantaAPI.YOA_SetFieldString("meme_gubun", strMemeGubun, 0); m_iYuantaAPI.YOA_SetFieldString("jong_code", strJongCode, 0); m_iYuantaAPI.YOA_SetFieldString("jang_gubun", "0", 0); m_iYuantaAPI.YOA_SetFieldLong("order_cnt", nQty, 0); m_iYuantaAPI.YOA_SetFieldLong("order_price", nPrice, 0); m_iYuantaAPI.YOA_SetFieldString("jumun_condition", strJumunCond, 0); int nReqID = m_iYuantaAPI.YOA_Request(strDSOID, true, -1); if (ORDER_TYPE_MESU == m_nOrderMesuMedo) { m_nReqID_mesu = nReqID; } else if (ORDER_TYPE_MEDO == m_nOrderMesuMedo) { m_nReqID_medo = nReqID; } if (CommDef.ERROR_MAX_CODE < nReqID) { string strMsg = ""; if (ORDER_TYPE_MESU == m_nOrderMesuMedo) { m_mapRequestTR[nReqID] = "100001"; strMsg = "[ReqID:" + nReqID + "] [100001]현금매수 주문을 요청 하였습니다."; } else if (ORDER_TYPE_MEDO == m_nOrderMesuMedo) { m_mapRequestTR[nReqID] = "100002"; strMsg = "[ReqID:" + nReqID + "] [100002]현금매도 주문을 요청 하였습니다."; } m_mainForm.LogMessage(strMsg); } else { if (ORDER_TYPE_MESU == m_nOrderMesuMedo) { m_mainForm.LogMessage("[100001]현금매수 주문 요청중 오류가 발생하였습니다.", CommDef.YOALOG_ERROR); } else if (ORDER_TYPE_MEDO == m_nOrderMesuMedo) { m_mainForm.LogMessage("[100002]현금매도 주문 요청중 오류가 발생하였습니다.", CommDef.YOALOG_ERROR); } int nErrorCode = m_iYuantaAPI.YOA_GetLastError(); m_mainForm.LogMessage("[" + nErrorCode + " ]" + m_iYuantaAPI.YOA_GetErrorMessage(nErrorCode), CommDef.YOALOG_ERROR, false); } }