본문 바로가기
키움자동매매

tr-opt10003(체결정보요청)

by Knowledge Store In Hyunsoft 2022. 10. 8.

tr-opt10003(체결정보요청)

  • REQUEST Code
string trStockCd = tbTrStockCd.Text;
string trCd = "opt10003";
axKHOpenAPI.SetInputValue("종목코드", trStockCd);
axKHOpenAPI.CommRqData("RQName", trCd, 0, GetScrNum());

 

  • RESPONSE Code
//TR 조회 요구에 대한 데이터 수신 이벤트
private void axKHOpenAPI_OnReceiveTrData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e) {
    switch (e.sTrCode.ToLower()) {
        case "opt10003": //체결정보요청 
            funcOpt10003(sender, e);
            break;
    }
}

// 체결정보요청 
private void funcOpt10003(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e) {
    try {
        string[] columns = new string[] { "시간", "현재가", "전일대비", "대비율", "우선매도호가단위", "우선매수호가단위", "체결거래량", "sign", "누적거래량", "누적거래대금", "체결강도" };

        List<string[]> list = new List<string[]>();
        list.Add(columns);
        Console.WriteLine("<!-- Start funcOpt10003 (체결정보요청) -->");
        int nCnt = axKHOpenAPI.GetRepeatCnt(e.sTrCode, e.sRQName);
        for (int ni = 0; ni < nCnt; ni++) {
            string[] row = new string[columns.Length];
            for (int i = 0; i < columns.Length; i++) {
                row[i] = axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, ni, columns[i]).Trim();
            }
            list.Add(row);
        }
        PrintHtmlTable(list);
        Console.WriteLine("<!-- End funcOpt10003 (체결정보요청) -->");
    }
    catch (Exception e1) {
        Console.WriteLine(e1.StackTrace);
    }
}

public void PrintHtmlTable(List<string[]> list) {
    string table = "<table>\r\n";
    for (int i = 0; i < list.Count; i++) {
        table +="<tr>";
        for (int j = 0; j < list[i].Length; j++) {
            table += string.Format("<td>{0}</td>", list[i][j]);
        }
        table +="</tr>\r\n";
    }
    table +="</table>";
    Console.WriteLine(table);
    tbLog.Text = table;
}
  • RESPONSE Data Sample
시간 현재가 전일대비 대비율 우선매도호가단위 우선매수호가단위 체결거래량 sign 누적거래량 누적거래대금 체결강도
155927 +91200 +1300 +1.45 +91200 +91100 +150 2 2405984 217769504200 137.52
155821 +91200 +1300 +1.45 +91200 +91100 +5 2 2405834 217755824200 137.51
155803 +91200 +1300 +1.45 +91200 +91100 +2 2 2405829 217755368200 137.51
155715 +91200 +1300 +1.45 +91200 +91100 +1 2 2405827 217755185800 137.51
155224 +91200 +1300 +1.45 +91200 +91100 +1 2 2405826 217755094600 137.51
155134 +91200 +1300 +1.45 +91200 +91100 +10 2 2405825 217755003400 137.51
154909 +91200 +1300 +1.45 +91200 +91100 +1 2 2405815 217754091400 137.51
154815 +91200 +1300 +1.45 +91200 +91100 +1500 2 2405814 217754000200 137.51
154726 +91200 +1300 +1.45 +91200 +91100 +1 2 2404314 217617200200 137.34
154706 +91200 +1300 +1.45 +91200 +91100 +2 2 2404313 217617109000 137.34
154658 +91200 +1300 +1.45 +91200 +91100 +1 2 2404311 217616926600 137.34
154645 +91200 +1300 +1.45 +91200 +91100 +1 2 2404310 217616835400 137.34
154610 +91200 +1300 +1.45 +91200 +91100 +2 2 2404309 217616744200 137.34
154546 +91200 +1300 +1.45 +91200 +91100 +10 2 2404307 217616561800 137.34
154528 +91200 +1300 +1.45 +91200 +91100 +2 2 2404297 217615649800 137.34
154451 +91200 +1300 +1.45 +91200 +91100 +1 2 2404295 217615467400 137.34
154340 +91200 +1300 +1.45 +91200 +91100 +3 2 2404294 217615376200 137.34
154321 +91200 +1300 +1.45 +91200 +91100 +2 2 2404291 217615102600 137.34
154312 +91200 +1300 +1.45 +91200 +91100 +1 2 2404289 217614920200 137.34
154203 +91200 +1300 +1.45 +91200 +91100 +10 2 2404288 217614829000 137.34
154133 +91200 +1300 +1.45 +91200 +91100 +2 2 2404278 217613917000 137.34
154056 +91200 +1300 +1.45 +91200 +91100 +5 2 2404276 217613734600 137.34
154050 +91200 +1300 +1.45 +91200 +91100 +2 2 2404271 217613278600 137.34
154000 +91200 +1300 +1.45 +91200 +91100 190 2 2404269 217613096200 137.34
153006 +91200 +1300 +1.45 +91200 +91100 151211 2 2404079 217595768200 137.34
151958 +91100 +1200 +1.33 +91200 +91100 -5 2 2252868 203805325000 137.34
151958 +91100 +1200 +1.33 +91200 +91100 -12 2 2252863 203804869500 137.34
151958 +91200 +1300 +1.45 +91200 +91100 +43 2 2252851 203803776300 137.34
151958 +91100 +1200 +1.33 +91200 +91100 -10 2 2252808 203799854700 137.33
151958 +91100 +1200 +1.33 +91200 +91100 -100 2 2252798 203798943700 137.33

 

키움 open-api TR 목록

728x90

댓글