Skip to main content

Windows COM 기반으로 파이썬 32비트로만 동작하는 키움증권 오픈API 패키지

Project description

KiwoomOpenAPI

Windows COM 기반으로 파이썬 32비트로만 동작하는 키움증권 오픈API 패키지.

KiwoomTraderV2 프로젝트 패키지의 내부 모듈을 독립적인 패키지로 분리하는 작업 완료.

사용법

데이터 요청할 때는 패키지의 함수들을 사용해야 한다.

import kiwoomapi as api
api.CommConnect()

데이터 수신할 때는 PyQt-QAxWidget 객체인 'OpenAPI'의 pyqtSinal 을 사용해야 한다.

키움증권으로부터 메시지를 수신하기 위해서는 아래와 같이 코드를 작성해야 한다.

from kiwoomapi import OpenAPI
OpenAPI.OnReceiveMessage.connect(YOUR_METHOD) 

로그인 객체 구현 예시:

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, QEventLoop
import kiwoomapi as api
from kiwoomapi import OpenAPI

class LoginAPI(QObject):

    LoginSucceeded = pyqtSignal()

    def __init__(self):
        super().__init__()
        OpenAPI.OnReceiveMessage.connect(self.__recv_msg__)
        OpenAPI.OnEventConnect.connect(self.__recv_login__)

    @pyqtSlot(str, str, str, str)
    def __recv_msg__(self, ScrNo, RQName, TrCode, Msg):
        print([ScrNo, RQName, TrCode, Msg])
    
    @pyqtSlot(int)
    def __recv_login__(self, ErrCode):
        print(ErrCode)
        if ErrCode == 0:
            self.LoginSucceeded.emit()
        else:
            print('로그인 실패)
        self._event_loop.exit()

    def login(self):
        api.CommConnect()
        self._event_loop = QEventLoop()
        self._event_loop.exec()


app = QApplication(sys.argv)

LoginAPI = LoginAPI()
LoginAPI.login()

sys.exit(app.exec())

개발 가이드 문서

로그인-버전처리\기본설명

모의투자

로그인-버전처리

조건검색

조회와-실시간데이터처리

주문과-잔고처리

OpenAPI-오류코드

OpenAPI-사용제한

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiwoomapi-0.5.4.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

kiwoomapi-0.5.4-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file kiwoomapi-0.5.4.tar.gz.

File metadata

  • Download URL: kiwoomapi-0.5.4.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for kiwoomapi-0.5.4.tar.gz
Algorithm Hash digest
SHA256 1a4172b5f7675ce1b2ca731dba83f86b364a5c06659de92e3be244b50c8332de
MD5 98e07f2416eeb717c4cd93fe61f769fc
BLAKE2b-256 f11f1df1c1d840451f5f5e95d9a913b6b9bb04bdb333f556784ea65bd6fa7926

See more details on using hashes here.

File details

Details for the file kiwoomapi-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: kiwoomapi-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for kiwoomapi-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f3aee4723eb00d3f7118d4dafc51b8347a0825fb859a3d06123bc54ccb8a5c92
MD5 5b785420b86cd47158077c9b818799e7
BLAKE2b-256 53beca5502709f22a510548082f15a83b7ee23b2a01b299a9e343b2301bf7960

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page