[키움] 거래량 가져오는 Open Api

키움증권 Open API에서 주식 거래량을 가져오는 API는 `GetCommData()` 함수를 사용하여 데이터를 요청하고, TR(Code)와 RQName, ScreenNo, GetRepeatCnt() 등을 활용하여 데이터를 수신할 수 있습니다.

다음은 키움증권 Open API를 활용하여 주식 거래량을 가져오는 예시입니다:

```python
import sys
from PyQt5.QtWidgets import *
from PyQt5.QAxContainer import *

class KiwoomAPI(QAxWidget):
    def __init__(self):
        super().__init__()
        self.setControl("KHOPENAPI.KHOpenAPICtrl.1")
        self.OnEventConnect.connect(self.handle_connect)
        self.OnReceiveTrData.connect(self.handle_receive_tr_data)
        self.login()

    def login(self):
        self.dynamicCall("CommConnect()")
        self.login_event_loop = QEventLoop()
        self.login_event_loop.exec_()

    def handle_connect(self, err_code):
        if err_code == 0:
            print("로그인 성공")
        else:
            print("로그인 실패")

        self.login_event_loop.exit()

    def get_stock_volume(self, code):
        self.dynamicCall("SetInputValue(QString, QString)", "종목코드", code)
        self.dynamicCall("CommRqData(QString, QString, int, QString)", "주식거래량", "OPT10001", 0, "0101")

    def handle_receive_tr_data(self, screen_no, rq_name, tr_code, record_name, prev_next):
        if rq_name == "주식거래량":
            volume = self.dynamicCall("GetCommData(QString, QString, int, QString)", tr_code, rq_name, 0, "거래량")
            print("거래량:", volume)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    kiwoom = KiwoomAPI()
    kiwoom.get_stock_volume("종목코드")  # 가져올 주식 종목의 종목코드로 변경
    sys.exit(app.exec_())
```


위의 코드는 PyQt5를 사용한 예시이며, 키움증권 Open API를 활용하여 주식 거래량을 요청하고 받아오는 간단한 기능을 포함하고 있습니다. "종목코드" 부분에 실제 주식의 종목 코드를 입력하여 원하는 종목의 거래량을 가져올 수 있습니다.

위의 예시 코드를 참고하여 키움증권 Open API의 `SetInputValue()`, `CommRqData()`, `GetCommData()` 등의 함수를 활용하여 주식 거래량 데이터를 요청하고 수신하는 로직을 구현할 수 있습니다.