Skip to content

Instantly share code, notes, and snippets.

@SnowyPainter
Created February 17, 2023 12:40
Show Gist options
  • Save SnowyPainter/235fb27502cbbcc28c91efe671840d37 to your computer and use it in GitHub Desktop.
Save SnowyPainter/235fb27502cbbcc28c91efe671840d37 to your computer and use it in GitHub Desktop.
오픈api 전날 국내 선물 시세 불러오기
import requests
import urllib
#OpenAPI 금융위원회 파생상품시세정보
key = ""
#numOfRows : 1
#pageNo : 1
#beginBasDt : ex) 20230215. 2023년 2월 15일~... 현재-1 까지.
#resultType : json / xml
#serviceKey : key
#itmsNm : 코스피200 F 202303
#res--
#sptPrc : 현물가
#clpr, hipr, lopr : 종, 고, 저가
params = urllib.parse.urlencode({
"serviceKey" : key,
"resultType" : "json",
"beginBasDt" : "20230212", #언제부터.
"itmsNm" : "코스피200 F 202303"
}, quote_via=urllib.parse.quote)
r = requests.get("https://apis.data.go.kr/1160100/service/GetDerivativeProductInfoService/getStockFuturesPriceInfo", params=params)
b = r.json()['response']['body']
print(b['totalCount'])
print(b['items'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment