koreainvestment / open-trading-api

Korea Investment & Securities Open API Github https://apiportal.koreainvestment.com
402 stars 115 forks source link

OHLC 지원 가능 할까요? #3

Closed binsoore closed 2 years ago

binsoore commented 2 years ago

기존 대신증권 크레온에서 OHLC 를 지원했는데 ( 20일 평균, 60일 평균으로 매수, 매도전략을 구할려고 )

앞으로 지원 가능할까요?

크레온 Python 예제)

def get_ohlc(code, qty): """인자로 받은 종목의 OHLC 가격 정보를 qty 개수만큼 반환한다.""" cpOhlc.SetInputValue(0, code) # 종목코드 cpOhlc.SetInputValue(1, ord('2')) # 1:기간, 2:개수 cpOhlc.SetInputValue(4, qty) # 요청개수 cpOhlc.SetInputValue(5, [0, 2, 3, 4, 5]) # 0:날짜, 2~5:OHLC cpOhlc.SetInputValue(6, ord('D')) # D:일단위 cpOhlc.SetInputValue(9, ord('1')) # 0:무수정주가, 1:수정주가 cpOhlc.BlockRequest() count = cpOhlc.GetHeaderValue(3) # 3:수신개수 columns = ['open', 'high', 'low', 'close'] index = [] rows = [] for i in range(count): index.append(cpOhlc.GetDataValue(0, i)) rows.append([cpOhlc.GetDataValue(1, i), cpOhlc.GetDataValue(2, i), cpOhlc.GetDataValue(3, i), cpOhlc.GetDataValue(4, i)]) df = pd.DataFrame(rows, columns=columns, index=index) return df

binsoore commented 2 years ago

자답 : 국내주식기간별시세(일/주/월/년)[v1_국내주식-016] https://openapi.koreainvestment.com:9443 이걸로 가능하겠네요.

koreainvestment commented 2 years ago

감사합니다.