def main(): # 로그인 kiwoom = Kiwoom() kiwoom.CommConnect() # 전종목 종목코드 kospi = kiwoom.GetCodeListByMarket("0") # kosdaq = kiwoom.GetCodeListByMarket("10") codes = kospi # + kosdaq # 문자열로 오늘 날짜 얻기 now = datetime.datetime.now() today = now.strftime("%Y%m%d") # 전 종목의 일봉 데이터 for i, code in enumerate(codes): if i > 10: break print(f"{i}/{len(codes)} {code}") df = kiwoom.block_request("opt10081", 종목코드=code, 기준일자=today, 수정주가구분=1, output="주식일봉차트조회", next=0) dirname = get_dir_path() out_name = f"{code}.csv" out_path = os.path.join(dirname, out_name) df.to_csv(out_path) time.sleep(3.5)
def main(): kiwoom = Kiwoom() kiwoom.CommConnect(block=True) # 컴포트 연결 print("It's been a while to write a program")
def get_data_opt10086(self, code, date): try: data = pd.read_hdf("../data/hdf/%s.hdf" % code, 'day').sort_index() start = str(data.index[-2]) except (FileNotFoundError, IndexError) as e: start = "20010101" print("get 86 data from %s" % start) self.kiwoom.start_date = datetime.strptime(start, "%Y%m%d") self.kiwoom.data_opt10086 = [] * 23 self.kiwoom.set_input_value("종목코드", code) self.kiwoom.set_input_value("조회일자", date) self.kiwoom.set_input_value("표시구분", 1) self.kiwoom.comm_rq_data("일별주가요청", "opt10086", 0, "0101") while self.kiwoom.inquiry == '2': time.sleep(TR_REQ_TIME_INTERVAL) self.kiwoom.set_input_value("종목코드", code) self.kiwoom.set_input_value("조회일자", date) self.kiwoom.set_input_value("표시구분", 1) self.kiwoom.comm_rq_data("일별주가요청", "opt10086", 2, "0101") self.kiwoom.data_opt10086.index = self.kiwoom.data_opt10086.loc[:, '일자'] return self.kiwoom.data_opt10086 if __name__ == '__main__': from pykiwoom.kiwoom import Kiwoom kiwoom = Kiwoom() kiwoom_wrapper = KiwoomWrapper(kiwoom) kiwoom_wrapper.get_data_opt10081('000660', "20161231")
from pprint import pprint from pykiwoom.kiwoom import Kiwoom kiwoom = Kiwoom() kiwoom.CommConnect(block=True) login_info_keys = [ "ACCOUNT_CNT", "ACCNO", "USER_ID", "USER_NAME", "KEY_BSECGB", "FIREW_SECGB" ] login_info_dic = {key: kiwoom.GetLoginInfo(key) for key in login_info_keys} pprint(login_info_dic)
""" https://wikidocs.net/77481 """ from pykiwoom.kiwoom import Kiwoom kiwoom = Kiwoom() kiwoom.CommConnect(block=True) print("blocking login done")
from pykiwoom.kiwoom import Kiwoom kw = Kiwoom() kw.CommConnect(block=True) kospi = kw.GetCodeListByMarket("0") kosdaq = kw.GetCodeListByMarket("10") etf = kw.GetCodeListByMarket("8") print(len(kospi), kospi) print(len(kosdaq), kosdaq) print(len(etf), etf)