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

tr-opt90006(프로그램매매차익잔고추이요청)

by Knowledge Store In Hyunsoft 2022. 10. 9.

tr-opt90006(프로그램매매차익잔고추이요청)

  • REQUEST Code
string endDate = "20220930";
string trCd = "opt90006";

// 날짜 = YYYYMMDD (20160101 연도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 "opt90006": // 프로그램매매차익잔고추이요청 
            funcOpt90006(sender, e);
            break;
    }
}

// 프로그램매매차익잔고추이요청 
private void funcOpt90006(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e) {
    try {
        string[] columns = new string[] { "일자", "매수차익거래수량", "매수차익거래금액", "매수차익거래증감액", "매도차익거래수량", "매도차익거래금액", "매도차익거래증감액" };

        List<string[]> list = new List<string[]>();
        list.Add(columns);
        Console.WriteLine("<!-- Start funcOpt90006 (프로그램매매차익잔고추이요청) -->");
        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 funcOpt90006 (프로그램매매차익잔고추이요청) -->");
    }
    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 1401 64935 22342 993 44494 11172
20220929 914 42593 -43577 720 33322 -62628
20220928 1864 86170 -11157 2005 95951 11043
20220927 2099 97327 41952 1761 84908 42718
20220926 1134 55375 10087 893 42190 -30008
20220923 931 45288 -13340 1472 72199 -45337
20220922 1198 58628 -4099 2433 117535 51065
20220921 1274 62727 -5275 1315 66470 4801
20220920 1357 68003 27718 1209 61669 24522
20220919 897 40284 2521 748 37147 -118913
20220916 751 37763 5678 2999 156061 56926
20220915 633 32085 -27256 1932 99134 18045
20220914 1159 59341 268 1581 81090 51580
20220913 1136 59073 -86353 554 29510 -229216
20220908 2974 145426 99825 5056 258726 155096
20220907 922 45601 18585 2020 103630 66958
20220906 548 27016 -63063 774 36672 -24864
20220905 1751 90079 7468 1197 61536 -165540
20220902 1615 82611 59639 4597 227077 -217397
20220901 418 22971 -25340 8692 444474 316728
20220831 925 48311 1224 2641 127746 72067
20220830 910 47087 11207 1096 55678 3755
20220829 702 35880 -21679 1015 51923 -13624
20220826 1096 57559 -1666 1251 65546 9119
20220825 1128 59225 -15296 1083 56427 -25177
20220824 1433 74522 17827 1580 81604 11932
20220823 1071 56695 4401 1390 69672 16437
20220822 992 52293 27743 1011 53234 24181
20220819 450 24550 -31450 601 29053 -57174
20220818 1053 56000 -7366 1696 86227 27983
20220817 1193 63366 20713 1103 58243 18418
20220816 783 42653 -5631 753 39825 2602
20220812 902 48284 -33727 703 37223 -27951
20220811 1528 82011 60140 1149 65174 27373
20220810 410 21870 -50526 728 37801 -21936
20220809 1345 72397 26171 1117 59737 -19101
20220808 868 46226 -10988 1464 78838 21128
20220805 1071 57214 16143 1084 57710 -8547
20220804 777 41071 -22569 1248 66257 13947
20220803 1206 63640 20012 1000 52311 -5063
20220802 836 43628 -364 1108 57373 8730
20220801 848 43993 -39755 928 48643 -22915
20220729 1602 83748 33443 1360 71558 27178
20220728 951 50304 4426 848 44381 12462
20220727 818 45878 -4836 615 31919 -19255
20220726 980 50713 -18300 993 51174 -1562
20220725 1312 69013 16071 1017 52735 -16907
20220722 1027 52942 -4349 1345 69642 -17317
20220721 1107 57292 7117 1698 86959 33881
20220720 970 50174 32850 1057 53078 17042
20220719 340 17325 -39 689 36037 -12659
20220718 341 17364 -59588 918 48696 -39667
20220715 1525 76952 -10986 1761 88363 14985
20220714 1764 87938 15076 1480 73378 -361
20220713 1459 72862 16189 1488 73739 14400
20220712 1138 56673 31787 1216 59339 25124
20220711 493 24886 -75220 658 34215 -77032
20220708 1973 100106 41648 2186 111247 68848
20220707 1164 58458 -54873 872 42399 -106507
20220706 2276 113332 30538 3011 148905 73603
20220705 1643 82794 -20084 1500 75302 15628
20220704 2091 102878 -18118 1209 59674 -50827
20220701 2427 120995 66803 2225 110502 46627
20220630 1076 54192 24272 1259 63875 10406
20220629 586 29920 -33372 1044 53469 -10273
20220628 1225 63292 5890 1215 63742 -20920
20220627 1110 57402 -138761 1628 84662 53124
20220624 3889 196163 -39779 622 31538 -19803
20220623 4907 235942 169112 1014 51341 -4294
20220622 1412 66830 -37727 1072 55635 -2832
20220621 2059 104557 -7580 1140 58467 -1807
20220620 2261 112136 29598 1191 60274 -10257
20220617 1559 82539 -28882 1357 70531 -9614
20220616 2114 111421 65470 1508 80145 24529
20220615 873 45952 -86020 1049 55616 -54584
20220614 2459 131971 93925 2072 110200 75197
20220613 716 38046 -27919 656 35003 -72331
20220610 1199 65965 -65283 1974 107334 -22840
20220609 2695 131248 47205 2452 130174 55386
20220608 1512 84043 59113 1362 74787 26266
20220607 464 24930 -52181 873 48522 -4584
20220603 1413 77111 12329 932 53105 -40709
20220602 1140 64783 -53094 1633 93814 -39676
20220531 2060 117876 16649 2347 133490 53499
20220530 1796 101227 -9785 1434 79991 -10520
20220527 1982 111012 -24794 1607 90511 -33938
20220526 2431 135806 33807 2224 124449 41561
20220525 1867 101998 -13372 1475 82887 -33287
20220524 2054 115371 24446 2060 116174 43399
20220523 1639 90925 -3833 1284 72775 13652
20220520 1716 94758 -36380 1045 59123 -80259
20220519 2369 131138 45372 2513 139382 56019
20220518 1605 85767 -7754 1463 83363 1355
20220517 1669 93521 -18938 1466 82007 -21947
20220516 1992 112459 23328 1864 103954 57538
20220513 1646 89131 -82949 830 46416 -127959
20220512 3123 172079 72430 3276 174374 35731
20220511 1786 99650 -46573 2544 138644 -6845
20220510 2634 146223 83301 2649 145489 72969
20220509 1123 62922 15431 1300 72519 -39506

 

키움 open-api TR 목록

728x90

댓글