Skip to main content

package for db openapi

Project description

DB증권 OpenApi Package

This is a simple package for DB RestAPI version.

Installation

pip install dbopenapi

Usage

모든 요청은 비동기로 처리되며, 요청에 대한 응답은 await 키워드를 사용하여 받을 수 있습니다.
Samples: https://github.com/teranum/db-openapi-samples

로그인 요청은 반드시 먼저 수행되어야 하며, 로그인이 성공하면 다른 요청을 수행할 수 있습니다.

import asyncio
import dbopenapi
from app_keys import appkey, appsecretkey # app_keys.py 파일에 appkey, appsecretkey 변수를 정의하고 사용하세요

async def main():
    api=dbopenapi.OpenApi()
    
    logined:bool = False
    logined = await api.login(appkey, appsecretkey)
    
    # 옵션1: 당일 발급받은 access_token 이 있는 경우, access_token 으로 로그인
    # logined = await api.login('', '', access_token=saved__access_token)
    
    # 옵션2: 모의투자 일 경우 is_simulation 옵션을 True 로 설정
    # logined = await api.login(appkey, appsecretkey, is_simulation=True)
    
    # 옵션3: 해외선물옵션인 경우 wss_domain 옵션을 dbopenapi.WSS_URL_GLOBAL 로 설정
    # logined = await api.login(appkey, appsecretkey, wss_domain=dbopenapi.WSS_URL_GLOBAL)

    if not logined:
        print(f'연결실패: {api.last_message}')
        return
    
    print('연결성공, 접속서버: ' + ('모의투자' if api.is_simulation else '실투자'))
    
    # 발급된 access_token 출력
    print('access_token: ', api.access_token)
    
    ... # 다른 작업 수행
    await api.close()

asyncio.run(main())

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

dbopenapi-0.0.8.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbopenapi-0.0.8-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file dbopenapi-0.0.8.tar.gz.

File metadata

  • Download URL: dbopenapi-0.0.8.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for dbopenapi-0.0.8.tar.gz
Algorithm Hash digest
SHA256 e3226283a951a4afd2e52c6151fd0bf88bd6316a65c39cf58d36168a522dfb97
MD5 b82002523d199e774220b50a18e9dfbb
BLAKE2b-256 46239273819cb335e03451cf1e86f85214115354c97dcc0cf181bced94f192c4

See more details on using hashes here.

File details

Details for the file dbopenapi-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: dbopenapi-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for dbopenapi-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3e7d194b1afcf282c415a57f6255223519b41b8c9eb196b38f4f78e8306d3ed3
MD5 19117620b8726c9baf5162be43dc6456
BLAKE2b-256 b8ba3ed0c64ef20e5f1f22ef11a60f9d64e4c1e448c3e68157504b6d76290797

See more details on using hashes here.

Supported by

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