Skip to main content

Simple Python Wrapper for Kiwoom REST API+

Project description

Kiwoom REST API

  • HTTP Request & Response are handled

Basic Structure

  • HTTP Client : HTTP 요청과 응답 관리
  • API : 키움 API 사용을 위한 입출력 관리
  • Proc : 서버에서 받는 Raw 데이터 가공
  • Bot : 실질적인 사용을 위한 Class
import asyncio
from datetime import datetime, timedelta
from kiwoom import Bot, REAL
from kiwoom.proc import candle, trade

# 초기화
bot = Bot(
    host=REAL,
    appkey='path/to/appkey',  # or raw appkey
    secretkey='path/to/secretkey'  # or raw secretkey
)

# 거래소 종목코드
kospi, kosdaq = '0', '10'
codes = asyncio.run(bot.stock_list(kospi, ats=True))

# 분봉 데이터
code = '005930_AL'  # 거래소 통합코드
df = asyncio.run(
    bot.candle(
        code=code, 
        period='min',   # 'tick' | 'min' | 'day'
        ctype='stock',  # 'stock' | 'sector'
        start='20250801',
        end='',
))
asyncio.run(candle.to_csv(file=code, path='./', df))

# 계좌 체결내역 데이터 (최근 2달만)
fmt = '%Y%m%d'
today = datetime.today()
start = today - timedelta(days=60)
start = start.strftime(fmt)
end = end.strftime(fmt)

trs = asyncio.run(
    bot.trade(start, end)
)
asyncio.run(trade.to_csv('trade.csv', './', trs))

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

kiwoom_restful-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

kiwoom_restful-0.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file kiwoom_restful-0.1.0.tar.gz.

File metadata

  • Download URL: kiwoom_restful-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for kiwoom_restful-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f90757d0d98d97bef53c2f3a9a5f6dbe6133561224f628b910ee09be4a7432c
MD5 dfee42c55b5f3bf044ed961cf8384908
BLAKE2b-256 a54721133edcce282889771a999c76aef827da18e8cfa75b51900adcf6330293

See more details on using hashes here.

File details

Details for the file kiwoom_restful-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kiwoom_restful-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for kiwoom_restful-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3bfc65259237eac4f3f39b29262828b5b8e0eaf77dd41be8cfc9620dccbb1ae
MD5 542bbedd2aa0d33bf2b31a5f4dc815cf
BLAKE2b-256 853bcd2c51057f80830deb34ef3010b3e1fe2260904f89d5649d2c6619b89d84

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