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

tr-opt90013(종목일별프로그램매매추이요청)

by hyunsoft 2022. 10. 9.

tr-opt90013(종목일별프로그램매매추이요청)

  • REQUEST Code
string trCd = "opt90013";
string trStockCd = "005930"; //삼성전자
string endDate = "20220930";

// 시간일자구분 = 2:일자별
axKHOpenAPI.SetInputValue("시간일자구분", "2");
// 금액수량구분 = 1:금액, 2:수량
axKHOpenAPI.SetInputValue("금액수량구분", "1");
axKHOpenAPI.SetInputValue("종목코드", trStockCd);
// 날짜 = YYYYMMDD (20170101 연도4자리, 월 2자리, 일 2자리 형식)
axKHOpenAPI.SetInputValue("날짜", endDate);

axKHOpenAPI.CommRqData("RQName", trCd, 0, GetScrNum());

 

  • RESPONSE Code
//TR 조회 요구에 대한 데이터 수신 이벤트
private void axKHOpenAPI_OnReceiveTrData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e) {
    switch (e.sTrCode.ToLower()) {
        case "opt90013": // 종목일별프로그램매매추이요청 
            funcOpt90013(sender, e);
            break;
    }
}

// 종목일별프로그램매매추이요청 
private void funcOpt90013(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e) {
    try {
        string[] columns = new string[] { "일자", "현재가", "대비기호", "전일대비", "등락율", "거래량", "프로그램매도금액", "프로그램매수금액", "프로그램순매수금액", "프로그램순매수금액증감", "프로그램매도수량", "프로그램매수수량", "프로그램순매수수량", "프로그램순매수수량증감", "기준가시간", "대차거래상환주수합", "잔고수주합" };

        List<string[]> list = new List<string[]>();
        list.Add(columns);
        Console.WriteLine("<!-- Start funcOpt90013 (종목일별프로그램매매추이요청) -->");
        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 funcOpt90013 (종목일별프로그램매매추이요청) -->");
    }
    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
일자 현재가 대비기호 전일대비 등락율 거래량 프로그램매도금액 프로그램매수금액 프로그램순매수금액 프로그램순매수금액증감 프로그램매도수량 프로그램매수수량 프로그램순매수수량 프로그램순매수수량증감 기준가시간 대차거래상환주수합 잔고수주합
20220930 +53100 2 +500 +0.95 22503249 217939 383149 165210 180425 4122930 7248127 3125197 3409780      
20220929 -52600 5 -300 -0.57 13882080 225369 210154 -15215 66533 4243039 3958456 -284583 1257715      
20220928 -52900 5 -1300 -2.40 19991129 272621 190873 -81748 -7064 5124797 3582499 -1542298 -157170      
20220927 +54200 2 +300 +0.56 16631289 229635 154951 -74684 79446 4255050 2869922 -1385128 1480215      
20220926 -53900 5 -600 -1.10 15008449 288621 134491 -154130 -171239 5365854 2500511 -2865343 -3178287      
20220923 +54500 2 +100 +0.18 10555964 144497 161606 17109 84073 2651361 2964305 312944 1544311      
20220922 -54400 5 -900 -1.63 12786510 162464 95500 -66964 -33161 2985262 1753895 -1231367 -618209      
20220921 -55300 5 -500 -0.90 11863700 147533 113730 -33803 5488 2671500 2058342 -613158 89534      
20220920 -55800 5 -600 -1.06 14041465 196189 156898 -39291 -114137 3500017 2797325 -702692 -2024207      
20220919 +56400 2 +200 +0.36 12278653 125848 200694 74846 148363 2230096 3551611 1321515 2640684      
20220916 +56200 2 +200 +0.36 13456503 268198 194681 -73517 7300 4789797 3470628 -1319169 114359      
20220915 -56000 5 -800 -1.41 11664819 182360 101543 -80817 -81224 3237249 1803721 -1433528 -1442810      
20220914 -56800 5 -1300 -2.24 12524961 182384 182791 407 -74228 3216872 3226154 9282 -1290310      
20220913 +58100 2 +2500 +4.50 17166581 228892 303527 74635 236562 3964649 5264241 1299592 4200126      
20220908 -55600 5 -400 -0.71 18000016 338673 176746 -161927 -75011 6069187 3168653 -2900534 -1349819      
20220907 -56000 5 -1100 -1.93 17384854 202972 116056 -86916 -76843 3615854 2065139 -1550715 -1373535      
20220906 57100 3 0 0.00 7503086 78839 68766 -10073 89514 1379104 1201924 -177180 1565609      
20220905 -57100 5 -400 -0.70 11425977 203858 104271 -99587 49408 3564491 1821702 -1742789 831388      
20220902 -57500 5 -900 -1.54 15040310 249475 100480 -148995 -21768 4304643 1730466 -2574177 -398203      
20220901 -58400 5 -1300 -2.18 14905777 360916 233689 -127227 -308719 6167793 3991819 -2175974 -5234831      

 

키움 open-api TR 목록

728x90

댓글