본문 바로가기

Language

(77)
[ Python library ] 우선주를 보통주로 변환 함수 import numpy as np import pandas as pd shcode = '005930' #삼성전자 보통주 shcode_2 = '005935' #삼성전자 우선주 # 우선주인지 체크하여 우선주면 보통주의 종목코드로 변경하여 반환하는 함수 [우선주, 보통주] 세트들을 보강 필요 def get_commonstock(shcode): np_preference = np.array([["004365", "004360"], ["005945", "005940"], ["001045", "001040"], ["000815", "000810"], ["00088K", "000880"],["078935", "078930"], ["005935", "005930"]]) df_preference = pd.DataFrame..
[ Python library ] 주식 종목명 추출 함수(naver증권 web crolling) import requests import urllib3 import re # 주식의 종목명을 추출하는 함수 def get_hname(shcode): urllib3.disable_warnings() URL = "https://finance.naver.com/item/main.nhn?code=" + shcode response_data = requests.get(URL, verify=False, headers={ 'referer': "https://navercomp.wisereport.co.kr/v2/company/c1030001.aspx?cmp_cd=005930&cn="}) html = response_data.text regex = re.compile("종목명 .*") mo = regex.search(h..
[ Python library ] 주식 현재가 추출 함수(naver증권 webcrolling) import requests from bs4 import BeautifulSoup import urllib3 shcode ='004960' #한신공영 # 주식의 현재가 추출 함수 def get_currentprice(shcode): urllib3.disable_warnings() URL = "https://finance.naver.com/item/main.nhn?code=" + shcode response_data = requests.get(URL, verify=False, headers={ 'referer': "https://navercomp.wisereport.co.kr/v2/company/c1030001.aspx?cmp_cd=005930&cn="}) html = response_data.text s..
[ Python library ] 네이버 encparam 추출 함수 import requests import re import urllib3 # 네이버 이용시 필요한 encparam 파라미터 값을 추출하는 함수 def get_encparam(): urllib3.disable_warnings() encparam="" URL = "https://navercomp.wisereport.co.kr/v2/company/c1010001.aspx?cmp_cd=005930" response_data = requests.get(URL, verify=False, headers={'referer': "https://finance.naver.com/item/coinfo.nhn?code=005930"}) html = response_data.text regex = re.compile("encpa..
로그인 및 현재가조회(xingapi이용) import win32com.client import pythoncom class XASessionEventHandler: login_state = 0 def OnLogin(self, code, msg): if code == "0000": print("로그인 성공") XASessionEventHandler.login_state = 1 else: print("로그인 실패") class XAQueryEventHandlerT1102: query_state = 0 def OnReceiveData(self, code): XAQueryEventHandlerT1102.query_state = 1 # ------------------------------------------------------------------..
Dash board https://hwangheek.github.io/2021/neat-xingapi-with-python/ Python으로 이베스트증권 xingAPI 깔끔하게 사용하기 (w/ pandas) 0. Introduction이베스트증권은 COM 형태와 dll 형태로 사용할 수 있는 xingAPI를 제공합니다. Python에서 COM object를 사용하는 라이브러리를 사용하면 xingAPI를 사용할 수 있지만, 사용법이 깔끔하지 못합 hwangheek.github.io https://wikidocs.net/3683 위키독스 온라인 책을 제작 공유하는 플랫폼 서비스 wikidocs.net
로드러너 스크립트에서 mip호출 url건수 세어 엑셀 만들기 2021-05-17일 사진 참조
http 호출 url들을 추출하여 엑셀생성 특정 폴더안에 엑셀파일들을 읽어들여 url들을 호출하여 엑셀생성 import openpyxl import pandas as pd import os # url리스트가 있는 파일들이 D:/files에 있고 해당 디렉토리에 파일리스트를 출력 path_dir = 'D:/files' file_list = os.listdir(path_dir) print(file_list) # 새로생성할 엑셀시트 생성 new_wb = openpyxl.Workbook() new_wb.remove(new_wb['Sheet']) for t in file_list: wb = openpyxl.load_workbook(path_dir+'/'+t) sheet1 = wb['Sheet'] sheet1.title = "이름 변경" print(shee..